| name | schema-readme-generator |
| description | Use this skill to create or update README.md files for BigQuery ETL tables in the mozilla bigquery-etl repository. Follows layout conventions derived from comparing README files across the repo โ rich style with emoji headings, Mermaid data flow diagram, graduated example queries, and concise metadata overview table. Requires schema.yaml with complete descriptions (run schema-enricher first if needed) and a complete metadata.yaml. |
README Generator
Prerequisites: Run schema-enricher first if schema.yaml is missing descriptions; ensure metadata.yaml is present and complete.
When to use: Creating or updating README.md for any shared dataset, derived table, or table with multiple downstream consumers
๐จ REQUIRED READING - Start Here
BEFORE generating any README, review the following:
-
Layout conventions: READ references/layout_conventions.md
- Section order, conciseness rules, anti-patterns to avoid
- Information sources (which file to read for which section)
-
README template: READ assets/readme_template.md and COPY its structure
- Fill every
{placeholder} from the source files
- Do not skip or reorder sections
Workflow
Step 1: Read source files
Read all three files before writing anything:
sql/<project>/<dataset>/<table>/query.sql โ source tables, GROUP BY dimensions, metrics, @param
sql/<project>/<dataset>/<table>/metadata.yaml โ DAG, partitioning, clustering, retention, owners
sql/<project>/<dataset>/<table>/schema.yaml โ field names, types, descriptions for Key Fields section
If only query.py exists (no query.sql): note it โ the Data Flow and How It Works sections may be incomplete or require manual input. Fill what is possible from metadata.yaml and schema.yaml.
Extract and record:
- FROM clause โ source table(s) with fully qualified name
- GROUP BY fields โ these become Dimensions
- Aggregated fields โ SUM/COUNT/DISTINCT targets become Metrics
- WHERE clause โ
@param_name for Implementation Notes
- DAG name, partition field, cluster fields, owners โ for Overview table
- Table version โ from directory name (e.g.,
_v1)
Step 2: Check if README.md already exists
ls sql/<project>/<dataset>/<table>/README.md
- Exists โ read it, identify sections to update or add (do not remove existing content without noting it)
- Does not exist โ generate from template
Step 3: Write README.md
READ assets/readme_template.md and fill every placeholder:
๐ Overview table โ use metadata.yaml for DAG/partition/cluster/retention/owner; derive Version from directory name.
๐บ๏ธ Data Flow โ Mermaid flowchart TD with exactly 3 nodes:
- Node A: source table(s) with short label + fully qualified name
- Node B:
**This query** with filter and GROUP BY description
- Node C:
Partitioned table with time and cluster annotation
- For multiple sources: A1, A2 โ B
๐ง How It Works โ 4โ5 numbered steps. Step 5 MUST explicitly state data inclusion/exclusion policy:
- "All records from source are included; no exclusions applied at this layer."
- OR list specific exclusions (bots, synthetic clients, test populations)
๐งพ Key Fields โ two sub-tables (Dimensions, Metrics). Use {a\|b\|c} shorthand for related field families. Group dimensions by: Date & Geo, Browser, Search, [Product] config, User. Omit dimension rows not applicable to this table.
๐งฉ Example Queries โ exactly 3, graduated:
- Basic aggregation โ date filter + 1โ2 GROUP BY dimensions
- Segmentation โ GROUP BY a user/product dimension with SAFE_DIVIDE ratio
- Attribution/Advanced โ multi-metric, WHERE filter on a dimension, SAFE_DIVIDE
Rules:
- Always use
SAFE_DIVIDE() for ratios โ never raw division
- Use
GROUP BY 1, 2 shorthand
- Comment each:
-- N. Description
- Fully qualified table name in FROM
๐ง Implementation Notes โ 3โ5 bullets extracted from query.sql logic.
๐ Notes & Conventions โ bullet definitions for key fields from schema.yaml descriptions.
๐๏ธ Schema & Related Tables โ one section; combine schema.yaml link + upstream + downstream.
Step 4: Conciseness check
Before finalizing, verify:
If over 170 lines, trim by: shortening SQL examples, collapsing Notes & Conventions bullets, abbreviating How It Works steps.
Step 5: Write and report
Write the README.md to:
sql/<project>/<dataset>/<table>/README.md
Then read back the written file and confirm:
Report:
- Path written
- Line count
- Sections included
- Any placeholders left unfilled (with reason)
Integration with Other Skills
| Skill | When to invoke |
|---|
schema-enricher | Run first if schema.yaml is missing descriptions โ needed for Notes & Conventions |
create-pr | After README.md is written โ stages, commits, and opens a draft PR |
Decision Tree: Rich vs. Minimal Style
Table has multiple downstream consumers OR is a shared dataset?
โ Rich style (this skill)
Table is a UDF, static reference, or simple single-consumer table?
โ Minimal style: title + ## Description with 5โ10 bullet points
โ Do not use this skill for minimal style
Example Invocations
Create a README.md for telemetry_derived.newtab_daily_interactions_aggregates_v1
Update the README.md for firefox_desktop_derived.newtab_clients_daily_v2 โ add missing example queries
Generate README for ads_derived.impressions_v1