---
name: lookup-integrity-check
description: "Checks every lookup in the open workbook for the faults that return a wrong row rather than an error: approximate match left on by default, duplicate keys on the lookup side, keys that exist in one table and not the other, mismatched types, and ranges that shift when rows are inserted. Changes nothing. Use when the user asks to check lookups, joins, references between tables, or why two sheets disagree."
title: lookup-integrity-check
canonical_url: https://skilld.dev/gh/kesslernity/awesome-copilot-office-skills/lookup-integrity-check
last_updated: 2026-10-24T10:01:48.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [README.md](https://skilld.dev/api/skills-raw/kesslernity/awesome-copilot-office-skills/lookup-integrity-check/README.md).
>
> If the user asked to install this Skill, run `npx skilld install kesslernity/awesome-copilot-office-skills/lookup-integrity-check`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/lookup-integrity-check`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/kesslernity/awesome-copilot-office-skills/lookup-integrity-check) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/lookup-integrity-check`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/lookup-integrity-check --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/lookup-integrity-check --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Lookup integrity check

## Purpose

A lookup that fails loudly returns an error and gets fixed. A lookup that matches the wrong row returns a real value from a real record, and that value goes into a report. The skill examines every lookup in the workbook for the faults that produce a confident wrong answer, and reports them with the keys involved.

## When to use

- The user asks to check lookups, joins, mappings or references between tables.
- Two sheets that should agree do not, and the cause is not yet known.
- Do not use to repair or rewrite lookups. This skill reports, the builder decides.

## Inputs

1. The open workbook (required).
2. Scope (optional): all lookups (default), or named sheets.
3. Key columns (optional): if the user names the columns that should act as keys, use them; otherwise infer and say what was inferred.

## Procedure

1. Find every lookup, in whatever form the workbook uses: direct lookup functions, index and match pairs, and conditional aggregations acting as lookups.
2. For each, record the lookup value, the table or range searched, the column or index returned, and the match mode as written.
3. Flag approximate match wherever it is used without an explicit reason nearby. Where the match mode argument is omitted and the function defaults to approximate, flag it, because an omitted argument is the most common form of this fault.
4. On the lookup table, test the key column for duplicates. A duplicate key means the lookup returns the first match and silently ignores the rest. Record the duplicated keys and how many times each appears.
5. Compare key sets in both directions: keys present in the source but missing from the lookup table, and keys in the table never used. Report counts and up to twenty examples each way.
6. Check type consistency on the key: numbers stored as text on one side and as numbers on the other, trailing spaces, and differing case where the function is case sensitive.
7. Flag index arguments given as a fixed column number rather than a matched header, because inserting a column silently redirects the result.
8. Flag lookup ranges that are not absolute or named, where copying the formula shifts the table.
9. Assign severity: HIGH if the fault can return a wrong row, MEDIUM if it breaks on edit, LOW if it is style.
10. Stop for the checkpoint.

## Human approval checkpoint

Present the findings. Ask: "Would you like me to add a comment on each HIGH lookup describing the fault, and a sheet listing the unmatched keys? I will not change any formula." Add only what the user approves.

## Output

Summary line: "N lookups checked: H high, X medium, Y low. D duplicate keys, U unmatched keys."

Lookups:

| # | Severity | Sheet | Cell | Lookup value | Table searched | Returns | Match mode | Finding |
|---|---|---|---|---|---|---|---|---|

Duplicate keys: each key, the sheet and column, and the number of occurrences.

Unmatched keys: present in source but not in table, and present in table but never used, each as a list with counts.

Type mismatches: the key, both representations, and the sheets.

## Fallbacks and edge cases

- Where approximate match is correct, as in a banded rate table, still report it, marked "approximate match may be intentional on a banded table".
- Keys that differ only by trailing space: report them as a type or whitespace mismatch, not as unmatched, because the fix is different.
- Very large key sets: report full counts and cap the examples at twenty each way, saying the list is capped.
- A lookup pointing at another workbook: record it and mark the key comparison as CANNOT CHECK rather than opening the file.
- Case sensitivity differs by function. State the assumption used for each finding.

## Rules

- Never change a formula, a key, a table or a cell type.
- Never deduplicate, trim or convert a key, even to test a theory. Report the condition instead.
- Quote keys exactly, including spaces, and say where a space is present.
- Do not report unmatched keys without stating the direction. Missing from the table and unused in the table are different problems.

## Self-check

- [ ] Every lookup in scope has a row, including those inside conditional aggregations.
- [ ] Every row states the match mode, including when the argument was omitted.
- [ ] Key comparison was run in both directions and both counts are reported.
- [ ] Nothing in the workbook was changed.
- [ ] Capped lists say they are capped.
