SQL Skills Generator · from your Postgres, for Claude Code and Codex

A Claude SQL skills generator built from promoted Postgres queries

Generic skill packs ship best practices for a database they have never seen. Chion is a Claude SQL skills generator that reads yours. It compiles the queries your team promoted into a per-role SKILL.md, every evidence line cited to its source row. Running that file still needs a database connection you supply in Claude Code or Codex.

Watch the demo walkthrough

Chion compiles the SQL your team saved and reviewed into CHION.md, the index for your org's SQL skills: one file per role that routes a repeat question to a query your team already reviewed, and runs in Chion Studio or exports as a per-runtime bundle for Claude Code and Codex. Slot bodies carry [src=…] tags back to the saved query that proved them; anything the compiler could not source is emitted marked _inferred, flag for review_. Built on what an AI SQL workforce actually does. Switch models or tools anytime.

Read-only SELECT. Credentials in an AES-256-GCM vault. Results capped at 1,000 rows. Each executed query leaves an audit row, written fire-and-forget so a logging failure never blocks your answer, by the service role and hashed rather than transcribed. The narrative is written from the rows your query returned, so those values reach the model.

Other generators read your repo; Chion reads your database

Repo-file generators

Most agent-file tools scan your codebase and paraphrase the prose they find. They never touch the database your questions actually run against.

Prewritten Claude SQL skills

Prewritten "SQL expert" skill packs ship generic best practices. They don't know your tables, your metrics, or the joins your team already proved.

Chion compiles from your live data

Chion compiles the agent file from the queries your team saved and reviewed, with [src=…] citations tracing each evidence line back to the query that proved it.

Evidence-grounded: each evidence line cites its source row Repeatable: the slot-filling pass runs at temperature 0 Editable, exportable, version-controlled

One agent file per role, exported to Claude Code and Codex

Each CHION.md is one role’s worth of saved SQL: finance, ops, growth. One role compiles per export, and the files you keep become your team’s SQL knowledge base. Same database, scoped knowledge per role. Each file is the agent that role owns, routing to the queries your team saved and reviewed; the library compounds as your team works.

What you get: a SQL analyst agent auto-written from your real queries

A SQL Analytics Agent file for your database, auto-written from your real queries.

Chion's SQL Skills Generator creates a CHION.md file: your portable Postgres SQL skills library. It auto-generates a SQL Analytics Agent file (the .md suffix follows the CLAUDE.md / AGENTS.md / SKILL.md convention). The bundle ships CHION.md, CONNECT.md, and a skills/ folder holding one SKILL.md per role. CHION.md holds the seven Layer 1 rules in full; each SKILL.md inlines them as a seven-line quick reference. Rename CHION.md to CLAUDE.md or AGENTS.md if that is what your agent reads.

CHION.md is a SQL Analytics Agent file for your database: a portable, version-controlled instruction file an AI reads before doing any work. The difference vs. hand-written agent files: yours is auto-written from your real analytics conversations, fully editable, and re-exportable on every refresh. Every saved query teaches it; every PII column closes off; every business rule is cited back to the row that proved it.

The export ships as one folder you point your agent at: CHION.md at the root + a skills/ folder beneath it (an _INDEX.md catalog that groups roles by department, then one folder per role holding its SKILL.md and saved scripts/). Sister-paired roles within each department cover complementary axes (recognized vs. forecast, between-warehouse vs. inside-warehouse, acquisition vs. in-product) so cross-axis questions resolve without the agent inventing a join.

Generate a Claude skill from your Postgres database

Three steps: connect, ask, export. Compiled once, not written fresh on every turn.

Connect and add saved queries

Connect Postgres and add the queries your team already runs in Studio’s data source editor. Chion ingests them as evidence for the agent file.

Ask & chart

Ask analytics questions in plain English. Chion generates SQL, runs it read-only, and returns interactive charts. Every answer enriches the skill.

Compile one role

Chion compiles CHION.md, CONNECT.md, and skills/<role>/SKILL.md, one role per export. Three model passes per role; the slot-filling pass runs at temperature 0, so the same evidence produces the same file structure. Natively compatible with Claude Code and Codex.

One compile per role, in three model passes. The slot-filling pass runs at temperature 0, so the same evidence produces the same file structure.

Each evidence line traces back to the query that proved it

Frontmatter contract, role, curated rule pack, evidence-grounded slots.

A real Northwind Logistics agent file. Each Layer 2 evidence line cites [src=…] back to the row that proved it; anything the compiler could not source is emitted marked _inferred, flag for review_.

Key facts. Frontmatter contract: 11 fields. Framework version: 7. Layer 2: 11–13 density-gated slots, each evidence line [src=…]-cited to its source row. Three model passes per role, with the slot-filling pass at temperature 0. Fully editable; export as CHION.md / CLAUDE.md / AGENTS.md / SKILL.md.

CHION.md · Northwind Logistics
---
artifact_type: domain_sql_sme_prompt
artifact_version: 2.5.0
framework_version: 7
archetype: logistics_supply_chain
chosen_primitives: [pre_aggregate_grain, snapshot_latest,
                    ratio_reconstruction, period_over_period_lag]
refreshed_at: 2026-04-30T18:22:11Z
---

# Analyst Persona
You are Northwind Logistics' supply-chain analyst. Your day is
shipments, lanes, carriers, and SLA breaches. You reason in
on-time-delivery rates and cost-per-mile. You refuse avg_of_ratios;
you reconstruct ratios from numerator + denominator at lane-grain.

# Curated SQL Rule Pack
### snapshot_latest
  use-when: balance-style metrics (inventory_on_hand)
  sql-shape: SELECT … ORDER BY ts DESC LIMIT 1 per entity
  guards: never SUM across snapshots

### ratio_reconstruction
  use-when: on_time_rate, fill_rate, defect_rate
  guards: SUM(numerator) / NULLIF(SUM(denominator),0)

# Layer 2 — Domain Profile
## 2.1 Questions You Compute
- on_time_rate = SUM(delivered_on_time) / NULLIF(SUM(shipments),0)
  [src=column_profiles:shipments.delivered_on_time, kpi_metrics:otd]
- avg_cost_per_mile = SUM(total_cost) / NULLIF(SUM(miles),0)
  [src=metric_concepts:cpm_lane]

## 2.6 Stop Signals
- never SUM(inventory_on_hand) across days
  [src=donts:snapshot_sum, decision_record:wh_audit_2026q1]
- never AVG(rates) — reconstruct from numerator + denominator
  [src=donts:avg_of_ratios, decision_record:metric_audit_2026q1]
Frontmatter is the contract. 11 fields. Your agent parses this before reading anything else.
Role is curated, not invented. Names verbatim tables and metrics from your schema.
Every Layer 2 line cites [src=…]. Trace every claim back to the row that proved it.
11–13 slots, density-gated. Empty slots are bugs, not filler.

Workspace cascade, indexes, and frontmatter

Three tiers: workspace → department → role SKILL.md with saved scripts under each.

Department is the top-level axis; role is the brain. Each department contains two sister-paired roles: finance (finance-analystfp-and-a-analyst), operations (ops-supply-chainwarehouse-operations), growth (growth-marketingproduct-analytics). Saved queries land under the role that owns the data shape; cross-axis questions route to both sister roles.

Each role's scripts/ folder mirrors every saved query under that role as a {README.md, query.sql} pair the agent wraps as a CTE rather than rewriting. For how Claude Code discovers and loads one of these files, read how to build a Claude Code SQL skill. The tree below shows the layout after activation. The export arrives with skills/ un-dotted; one move or symlink puts it under .claude/skills/ where Claude Code looks.

chion-skills-workspace/
├── CHION.md                                      ← root agent file (canonical)
├── README.md
├── LICENSE
└── .claude/skills/
    ├── _INDEX.md                                 ← workspace catalog · vocabulary · routing
    │
    ├── finance/                                  ← department · 2 sister-paired roles
    │   ├── _INDEX.md                             ← department catalog · sister-pair logic
    │   ├── finance-analyst/                      ← recognized revenue · ARR/MRR · margin
    │   │   ├── SKILL.md                          ← role brain · rule pack · scripts index
    │   │   └── scripts/
    │   │       ├── arr-by-segment/{README.md, query.sql}
    │   │       ├── mrr-trend-12mo/{README.md, query.sql}
    │   │       └── …
    │   └── fp-and-a-analyst/                     ← forecast · variance · runway · burn
    │       ├── SKILL.md
    │       └── scripts/…
    │
    ├── operations/                               (between-warehouse + inside-warehouse)
    │   ├── _INDEX.md
    │   ├── ops-supply-chain/{SKILL.md, scripts/}
    │   └── warehouse-operations/{SKILL.md, scripts/}
    │
    └── growth/                                   (acquisition + in-product)
        ├── _INDEX.md
        ├── growth-marketing/{SKILL.md, scripts/}
        └── product-analytics/{SKILL.md, scripts/}

A typical SKILL.md frontmatter: name + description drive native AI-tool skill discovery; trigger-keywords + department/role drive the CHION.md cascade:

---
name: finance-analyst
description: |
  The default analyst role for the finance department.
  Owns recognized-revenue P&L, segment-margin reconstruction,
  ARR/MRR roll-ups, and renewal recognition.
must-read: [_INDEX.md, ../_INDEX.md]
trigger-keywords: [revenue, recognized revenue, ARR, MRR,
                   GAAP, gross margin, segment margin, renewal]
department: finance
role: finance-analyst
archetype: saas_finance
chosen_primitives: [pre_aggregate_grain,
                    period_over_period_lag,
                    ratio_reconstruction]
status: verified
---

Bottom of every SKILL.md carries a fixed Scripts Index: trigger phrases mapped to saved scripts/ folders. No LLM judgment between trigger match and SQL execution.

Run it in Claude Code or Codex

One agent file. Three integration paths: Claude Code, Codex, or chat with it inside Chion.

Claude Code

~/.claude/skills/

Copy skills/<role>/ into ~/.claude/skills/, or drop CHION.md at the repo root. Claude Code reads it on every conversation. Fully editable. Re-export anytime.

Codex

~/.codex/skills/

Copy skills/<role>/ into ~/.codex/skills/. Codex reads the same SKILL.md. Fully editable. Re-export anytime.

Inside Chion

Chion runtime

Chat with your CHION.md inside Chion. A repeat question anchors on the saved query that owns it; a new SELECT is generated against it and code-validated before it runs.

See a real CHION.md.

Chion's open-source skills workspace: a published mock you can read end-to-end.

GitHub

jonfdag-dot / postgres-claude-skills-generator

The Chion Skills Workspace: six analyst roles, 15 saved Postgres scripts, three sister-role pairings, published as the exact folder shape Chion exports. Natively compatible with Claude Code and Codex; every answer cites the saved script that produced it.

Open-source · MIT Re-compilable from your DBBrowse on GitHub

Scope skills per role.

Connect, use, skills auto-generate. No data pipeline migrations required.

Promoted queries  →  3 model passes per role  →  one role per export today

Six role archetypes in the compiler:
                 ┌─ finance-analyst, fp-and-a-analyst
                 ├─ ops-supply-chain, warehouse-operations
                 └─ growth-marketing, product-analytics

Max plan economics. ~20 credits per role compile · 750 credits/month on Max → up to ~37 compiles, one role per export today, each carrying 10+ promoted queries. Re-compile any role anytime; supersedes the prior version cleanly.

Per-query skill capture: building the SQL skill library

Every query your team saved and reviewed becomes a candidate skill in your team’s SQL skill library, indexed at skills/<name>/SKILL.md with auto-generated frontmatter, trigger keywords, and reference docs.

Per-employee scoping

Database permissions already scope data; CHION.md scopes knowledge, organized by role. Finance gets roles/finance-analyst/skills/revenue-recognition/; Ops gets roles/ops-supply-chain/skills/lane-comparisons/; Growth gets roles/growth-marketing/skills/cohort-retention/. Same database, different agent files.

Indexable, navigable, version-controlled. Diff your agent file across releases the same way you diff code.

Frequently asked questions

Answers about CHION.md and the SQL Analytics Agent file pattern.

Can I export saved SQL queries to Claude Code or Codex?

Yes. A query you save and review compiles into a portable SQL skill for Claude Code and Codex. The bundle ships CHION.md, CONNECT.md, and a skills/ folder holding one SKILL.md per role. CHION.md carries the seven Layer 1 rules in full; each SKILL.md inlines the seven-line quick reference. You activate it with a move or a symlink: skills/ goes into the directory your tool reads, which is .claude/skills/ for Claude Code. From there the tool routes a matching question to your saved query. Renaming CHION.md to CLAUDE.md or AGENTS.md is a host convention you adopt, not something the compiler writes. No lock-in: the compiled files are yours to take with you.

What is a SKILL.md file for an AI coding agent?

A SKILL.md file is a markdown file that packages one capability for an AI tool like Claude Code. Chion's SQL skills generator compiles the SQL your team saved into SKILL.md files, one per role, so Claude Code and Codex CLI run the same read-only queries.
See the SQL skills generator →

How do I give Claude Code reusable SQL skills for my database?

Connect your Postgres in Chion Studio, ask the questions your team cares about, save the ones a reviewer accepts, then compile and download your skills as a CHION.md file plus the skills folder. Claude Code reads CLAUDE.md at a repo root, so rename or symlink CHION.md to CLAUDE.md and move the skills folder to .claude/skills/. On the next conversation the agent picks both up and anchors a matching question on the saved read-only query that owns it, instead of writing one from the raw schema. The file and skills folder travel with the export; your live query history, the profiled semantic layer, and the audit log stay in Chion Studio. To update, save new questions and recompile: the slot-filling pass runs at temperature 0, so the same saved queries produce the same file structure and you can diff it across releases.
Generate SQL skills →

Which file does Chion export, and how does it relate to CLAUDE.md?

Chion compiles only one of those three. SKILL.md is the per-role file, one folder per role under skills/. It inlines the seven Layer 1 rules as a seven-line quick reference, next to that role's trigger keywords and saved scripts. The full rule text lives in CHION.md at the workspace root. CLAUDE.md and AGENTS.md are host conventions, not compiler output. Claude Code reads CLAUDE.md at a repo root and Codex reads AGENTS.md, so rename or symlink CHION.md to whichever your tool expects.
CLAUDE.md, AGENTS.md, and SKILL.md compared →

How do you scope an AI SQL agent to a role like finance or ops?

A role is an archetype like finance-analyst or product-analytics. Each export compiles one role today.

What does it take to save an AI-generated SQL query?

A saved query is one your team ran in Chion Studio with the exact read-only SQL visible beneath the chart, reviewed, and accepted. Every saved query becomes a candidate skill, tagged by role and ranked by how often it is reused. When you compile, the high-confidence queries land in the agent file, each carrying a [src=] tag back to the query that proved it, and anything the compiler could not source is marked for review. The skill is the SQL your team already read, not a fresh guess.

Last reviewed: September 2, 2026

Generate your SQL Analytics Agent file

Connect Postgres. Ask a few questions.

Watch the demo walkthrough GitHub