Case study · Data Engineering · AI Engineering · Architecture
Claude Code Data Template: Guardrails for AI on Data Projects
A dbt + DuckDB starter where Claude Code follows data rules, and hooks block DROP, production targets and secrets before they run.
The problem
AI coding agents write SQL fast. They can also run DROP TABLE, point dbt at production, or make a failing test pass by turning a LEFT JOIN into an INNER JOIN. Rules in a prompt help, but they are only advice.
Constraints
- Guardrails live in the repository, so every session and every teammate gets them
- Hooks must be plain Python with no dependencies, and tested exactly as Claude Code calls them
- Normal work must stay fast: dbt runs, tests and dev queries need no approval
Architecture and decisions
Click a box to see why it was chosen.
Why · CLAUDE.md
Project rules: layers, naming, grain in every description, tests on every key, and what "done" means: row counts compared before and after.
Results
- hook tests, each run the way Claude Code runs it
- 34
- hook tests, each run the way Claude Code runs it
- risky commands blocked before they run, plus secrets in files
- 6
- risky commands blocked before they run, plus secrets in files
- dbt data tests, including a reconciliation test
- 12
- dbt data tests, including a reconciliation test
- subagents and skills for review, incidents, new models and reconciling
- 2 + 2
- subagents and skills for review, incidents, new models and reconciling
What I would do next
- 01A Stop hook that runs dbt tests before Claude ends a turn
- 02Warehouse versions of the guards for Snowflake and BigQuery targets