Build a data dictionary from schema exports and sample rows: extract declared types and comments, profile the samples for inferred types, null rates and observed values, merge curated definitions and owners, and produce dictionary.csv/.md plus a gap list flagging every field no source defines. Use when documenting a database, CSV feed, API payload, or warehouse table, when onboarding onto an undocumented dataset, when a schema changed and documentation needs rebuilding, or when someone asks what a field means, who owns it, or what values it can hold.
./install.sh data-dictionary-buildername: data_dictionary_builder description: "Build a data dictionary from schema exports and sample rows: extract declared types and comments, profile the samples for inferred types, null rates and observed values, merge curated definitions and owners, and produce dictionary.csv/.md plus a gap list flagging every field no source defines. Use when documenting a database, CSV feed, API payload, or warehouse table, when onboarding onto an undocumented dataset, when a schema changed and documentation needs rebuilding, or when someone asks what a field means, who owns it, or what values it can hold."
Turn scattered evidence about a dataset into two files a team can trust: a dictionary that states what each field means, and a gap list that names every field where no source states it. The builder merges three kinds of evidence and keeps them labelled, so a reader can tell a declared fact from an observed one:
Never invent a definition to fill a hole. A hole is a gap, with a code, a severity, and a named next step. That rule is the difference between this and a draft document that reads well and lies quietly.
references/extraction-queries.md (PostgreSQL, MySQL, SQL Server, SQLite) or use a JSON Schema file directly. Save the CSV export; do not retype it.references/extraction-queries.md first.assets/example_definitions.csv as a template. Fill in what people already know: definitions, owners, allowed values, what null means per field. Leave blanks blank; blanks become gaps, and gaps get owners later.python3 bin/build_dictionary.py \ --schema schema_export.csv \ --sample orders=orders_sample.csv \ --sample customers=customers_sample.csv \ --definitions definitions.csv \ --outdir ./dictionary-out
--sample repeats. A bare path with --table NAME works for one table. With no database access, pass a JSON Schema as --schema, or skip --schema and profile samples alone (every field starts as GAP-01).
gaps.md before dictionary.md. Triage with references/gap-rules.md: error gaps (GAP-01, 02, 03, 05, 06) block any claim that the dictionary is complete. Assign each gap a person and a decision: define it, fix the data, fix the schema, or record it accepted.python3 bin/check_dictionary.py dictionary-out/dictionary.csv \ --min-definition 0.9 --min-owner 0.9
It prints definition and owner coverage and fails on open error gaps. Start at 0.8 and ratchet up as the dictionary matures.
The bundled example is small and deliberately dirty. One value in total_usd is the text not-a-price, discount_code exists in the data but not in the schema, and legacy_code exists in the schema but not in the data.
cd assets/.. # the skill directory python3 bin/build_dictionary.py \ --schema assets/example_schema.csv \ --sample orders=assets/example_sample_orders.csv \ --definitions assets/example_definitions.csv \ --outdir /tmp/dictionary-out
Real output: wrote 7 fields, 9 gaps. The gap list includes:
check_dictionary.py on this output reports 100 percent definition coverage, 42.9 percent owner coverage, and RESULT: FAIL, which is correct. The example dictionary is a draft until the owners are named.
The build writes four files to --outdir:
dictionary.csv: one row per field, columns specified in references/dictionary-schema.md. This is the machine-readable source other tools should consume.dictionary.md: the same content as tables grouped by table, for humans.gaps.csv and gaps.md: one row per gap with code, severity, and the evidence behind it.Every reported run states: fields documented, gap count split by severity, definition coverage, owner coverage, and where the files went. Report observed facts as observed ("the sample shows 4 values") and declared facts as declared ("the schema declares NOT NULL"). Do not merge the two voices.
--show-pii-examples is passed. Use that flag only on samples already cleared for sharing. The sample files themselves are your responsibility; keep live credentials and unredacted personal data out of them.publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.