bi-sql-knowledge
Skill2 starsChanged 4 months agoApache-2.0View on GitHub
SQL reasoning, validation, reconciliation, transformation, diagnostics, and anti-pattern knowledge layer for Seshat BI agents. Use when a task involves reasoning about source SQL: source profiling, table grain, keys & uniqueness, joins & fan-out amplification, aggregation correctness, COUNT/NULL semantics, deduplication, validation queries, reconciliation queries, silver/gold transformation logic, window/date-time analytics, SQL anti-patterns, or basic SQL performance reasoning, or interpretation of a supplied sanitized PostgreSQL JSON execution plan. The SQL counterpart to bi-dax-knowledge. It is a thinking & validation layer, not a database executor, runtime validator, dbt/Dagster project, or automatic tuning service.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- approval-consoleSkill
- approval-evidence-packSkill
- business-knowledge-interviewSkill
- capabilitiesSkill
- consumer-data-dictionarySkill
- cross-table-lineageSkill
- dagster-orchestration-adapterSkill
- dashboard-designSkill
- dashboard-intelligenceSkill
- dbt-transformation-adapterSkill
- evidence-pack-generatorSkill
- first-hour-compassSkill
- friendly-pr-reviewerSkill
- grain-confidence-reviewerSkill
- kpi-contract-builderSkill
- pbi-mcp-write-adapterSkill
- pbip-workflowSkill
- pbip-xraySkill
- pbir-authoring-adapterSkill
- portfolio-watchSkill
- powerbi-dashboard-designSkill
- pr-readiness-reviewerSkill
- readiness-viewerSkill
- release-notes-generatorSkill
- report-intent-interviewSkill
- retail-build-warehouseSkill
- retail-control-roomSkill
- retail-discover-portfolioSkill
- retail-governSkill
- retail-initSkill
- retail-onboard-tableSkill
- retail-orchestrateSkill
- retail-scaffoldSkill
- retail-semantic-checkSkill
- retail-validateSkill
- run-next-readinessSkill
- seshat-studioSkill
- showcase-buildSkill
- source-mappingSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-git-commitSkill
- speckit-git-featureSkill
- speckit-git-initializeSkill
- speckit-git-remoteSkill
- speckit-git-validateSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
- bi-analyst-knowledgeSkill
- bi-bigdata-knowledgeSkill
- bi-dax-knowledgeSkill
- bi-python-knowledgeSkill
- retail-kpi-knowledgeSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 51
Not a SQL tutorial; not a chapter-by-chapter book summary.
- Very specific: line 79
Stop and ask for metadata, do not guess: When two cheap checks -- a COUNT(*) comparison and a uniqueness check -- can't localize a problem, …
- Distinctive: line 83
Stop at the routing boundary: If the real task is DAX, a dashboard, or source mapping, hand off to the skill above instead of answering …
- Distinctive: line 101
Not implementation, not database execution, not dbt/Dagster, not a runtime validator (validation patterns are reasoning templates, not an …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
BI SQL Knowledge (Seshat BI)
A navigational interface to a SQL reasoning and validation knowledge base. It teaches an
agent to reason about SQL correctly -- with table grain and aggregation correctness as
its foundation, the way filter context is the foundation of bi-dax-knowledge.
This file is short by design. It does not contain the knowledge base. Do not read every file in this skill. Follow the flow below.
Mandatory flow (do not skip a step, do not lose the compass)
Router -> this SKILL.md -> INDEX.md -> ONLY the relevant file(s) -> output contract / checklist- Open
INDEX.mdfirst. It routes by task and by symptom to the specific file(s) you need. - Read only what the route names -- one or two knowledge files, one JSON, one checklist. Reading the whole base is an anti-pattern; it wastes context and dilutes the answer.
- Ground the grain before anything else. State what one row of the input/result means
(
knowledge/sql-core-concepts.md, SC-003). Most SQL bugs are grain errors. - End on an artifact: a validation gate (
patterns/sql-validation-patterns.json, VP-), a checklist (checklists/), or a diagnostic verdict (knowledge/sql-diagnostics-playbook.md, PB-SQL-). Never end on prose alone.
What this skill is for
Reasoning about, reviewing, and validating SQL used in BI pipelines: profiling a source;
grain / keys / uniqueness; joins and fan-out amplification; aggregation correctness
(COUNT / SUM / AVG, GROUP BY); COUNT and NULL semantics; deduplication; validation
and reconciliation queries; silver/gold transformation logic (DML, reshaping, cleaning,
set operations, date recipes, gaps/islands, hierarchy, metadata-driven profiling); window and
date/time analytics; SQL anti-patterns (including shell/encoding pitfalls like matching a
non-ASCII/RTL literal on a command line); basic performance reasoning; and evidence-gated,
read-only interpretation of supplied PostgreSQL JSON execution plans.
What this skill is NOT for
Not a SQL tutorial; not a chapter-by-chapter book summary; not a replacement for any book; not a database execution tool; not a runtime validator; not a dbt/Dagster project; not an automatic PostgreSQL tuning service; not the Power BI dashboard or DAX layer. It reasons about SQL and supplied plans; it never runs them.
Routing boundaries (pick the right skill before working)
| The task is about... | Route to |
| Source mapping / retail pipeline readiness | source-mapping / retail-onboard-table (the readiness spine) |
| SQL reasoning / profiling / validation / reconciliation / transformation logic | bi-sql-knowledge (this skill) |
| DAX generation / review / performance / model prerequisites | bi-dax-knowledge |
| Dashboard / visual / page design | powerbi-dashboard-design |
Where it sits in the pipeline:
source -> [source-mapping / retail-onboard-table: mapping / readiness]
-> [bi-sql-knowledge: profile / validate / reconcile / transform -> silver/gold]
-> [bi-dax-knowledge: measures / model]
-> [powerbi-dashboard-design: visuals / pages]A validated gold table with a known grain and verified unique keys is the hand-off to
bi-dax-knowledge: grain and uniqueness feed DAX additivity reasoning.
Stop rules
- Stop and ask for metadata, do not guess. When two cheap checks -- a
COUNT(*)comparison and a uniqueness check -- can't localize a problem, request schema/source metadata (primary keys, expected grain, null semantics, SLA, expected volumes). Establishing these facts is the job; inventing them is not. - Stop at the routing boundary. If the real task is DAX, a dashboard, or source mapping, hand off to the skill above instead of answering here.
- Stop before executing. This layer produces SQL reasoning and gate shapes. It does not run queries, wire a runtime, build a CLI, or publish anything.
- Stop without plan evidence. Bare SQL can support a hypothesis, not a PostgreSQL performance verdict. Plan review requires a supplied, sanitized JSON plan and representative context.
- Never fake a pass. Validation/reconciliation results are evidence-based; a gate with no
evidence is
blocked, neverpass.
ID conventions (full detail in references/id-conventions.md)
Concepts SC-001..070 - plan concepts EP-001..014 - plan patterns EP-PAT-* -
anti-patterns SQL-AP-001..061 - validation gates VP-* - diagnostic playbooks
PB-SQL-01..19 - analyzer-rule candidates SARC-* (staged) - promoted draft analyzer rules
SAR-* (static draft, not runtime-enforced).
Boundaries
Not implementation, not database execution, not dbt/Dagster, not a runtime validator
(validation patterns are reasoning templates, not an executing engine), not a replacement for
any book, not automatic PostgreSQL tuning. An agent knowledge layer. All examples are original
Seshat BI / retail examples on a fictional schema; no book text or datasets are reproduced
(references/copyright-safety.md).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

