Skip to content

Commit 2b5745a

Browse files
authored
Add project instructions for AI agents and update related documentation (#205)
1 parent 1c3abe8 commit 2b5745a

File tree

10 files changed

+2789
-2476
lines changed

10 files changed

+2789
-2476
lines changed

.agents/skills

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.claude/skills

.claude/hooks/run-pre-commit.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
cd "${CLAUDE_PROJECT_DIR:-.}"
5+
6+
output=$(pre-commit run --all-files 2>&1)
7+
status=$?
8+
if [ "$status" -ne 0 ]; then
9+
echo "$output" >&2
10+
exit 2
11+
fi
12+
exit 0

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"Stop": [
4+
{
5+
"hooks": [
6+
{
7+
"type": "command",
8+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/run-pre-commit.sh",
9+
"timeout": 180
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
name: dbt-parser-refresh
3+
description: Refreshes dbt artifact schemas from dbt-labs/dbt-core and regenerates Pydantic parser classes. Use when the user asks to update parsers, sync with upstream, download dbt schemas, or regenerate parser models.
4+
---
5+
6+
# dbt Parser Refresh
7+
8+
## Trigger scenarios
9+
10+
Activate this skill when the user says or implies:
11+
12+
- Refresh parsers, update parsers, sync parsers
13+
- Update from dbt-core, sync with upstream dbt-core
14+
- Download dbt schemas, pull schemas from dbt-core
15+
- Regenerate parser classes, regenerate parser models, run codegen
16+
17+
## Scripts and paths
18+
19+
- Run all commands from the **repository root**.
20+
- **Download:** `bash dev/download_dbt_schemas.sh [--ref REF] [artifact_type] [version ...]`
21+
- **Generate:** `bash dev/generate_parser_classes.sh [artifact_type] [version ...]`
22+
- **Artifact types:** `catalog`, `manifest`, `run-results`, `sources`
23+
- **Versions:** e.g. `v1`, `v7`. Omit args to process all types and versions.
24+
25+
## Order rule
26+
27+
When doing both download and generate, **always run download first**, then generate.
28+
29+
## Three modes
30+
31+
### 1. Download + generate (default)
32+
33+
When the user wants to refresh or update parsers (e.g. "refresh parsers", "update from dbt-core"):
34+
35+
1. Run `bash dev/download_dbt_schemas.sh` with any user-specified `--ref`, artifact_type, or versions.
36+
2. Then run `bash dev/generate_parser_classes.sh` with the same artifact_type and versions (no `--ref`).
37+
38+
If the user did not specify scope, use no arguments for both (download all, then generate all).
39+
40+
### 2. Download only
41+
42+
When the user only wants to fetch schemas (e.g. "download dbt schemas", "pull schemas from dbt-core"):
43+
44+
- Run only `bash dev/download_dbt_schemas.sh` with optional `--ref` and artifact_type/version.
45+
46+
### 3. Generate only
47+
48+
When schemas are already present and the user only wants to regenerate code (e.g. "regenerate parsers", "run codegen"):
49+
50+
- Run only `bash dev/generate_parser_classes.sh` with optional artifact_type/version.
51+
52+
## Passing through user intent
53+
54+
- **Ref:** If the user specifies a ref (e.g. `main` or a branch), pass `--ref REF` only to the download script.
55+
- **Scope:** If they specify an artifact or version (e.g. "just manifest v7"), use the same artifact_type and version(s) for both scripts when running both.
56+
57+
## Example
58+
59+
Full refresh (all types and versions):
60+
61+
```bash
62+
bash dev/download_dbt_schemas.sh
63+
bash dev/generate_parser_classes.sh
64+
```
65+
66+
Refresh only manifest v7:
67+
68+
```bash
69+
bash dev/download_dbt_schemas.sh manifest v7
70+
bash dev/generate_parser_classes.sh manifest v7
71+
```

AGENTS.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Project instructions for AI agents
2+
3+
This file is the single source of project expectations for Codex, Cursor, and other AI agents. Claude Code uses [CLAUDE.md](CLAUDE.md), which references this file.
4+
5+
## Project overview
6+
7+
dbt-artifacts-parser is a Python package that parses dbt artifacts (catalog, manifest, run-results, sources) as Python objects. Pydantic models are generated from the official dbt artifact JSON schemas (from dbt-labs/dbt-core). We do not manually edit generated parser models; we use dbt artifacts from stable dbt versions only; we support only artifacts whose JSON schemas are publicly available.
8+
9+
See [README.md](README.md) for usage and [CONTRIBUTING.md](CONTRIBUTING.md) for full contribution and implementation policy.
10+
11+
## Setup and commands
12+
13+
Run from the **repository root**.
14+
15+
- **Setup:** `make setup` — installs dependencies and pre-commit hooks.
16+
- **Test:** `make test`
17+
- **Lint:** `make lint` (runs pre-commit on all files)
18+
- **Build:** `make build` — clean, lint, test, then build the package.
19+
20+
## Code and contribution
21+
22+
- Follow the implementation policy in [CONTRIBUTING.md](CONTRIBUTING.md): no manual changes to generated Pydantic models; use the download and generate scripts for any parser updates.
23+
- Parser codegen: download schemas with [dev/download_dbt_schemas.sh](dev/download_dbt_schemas.sh), then generate classes with [dev/generate_parser_classes.sh](dev/generate_parser_classes.sh).
24+
25+
## Parser refresh workflow
26+
27+
When updating or adding parsers (syncing with dbt-core, regenerating Pydantic models):
28+
29+
1. **Download first:** `bash dev/download_dbt_schemas.sh [--ref REF] [artifact_type] [version ...]`
30+
2. **Then generate:** `bash dev/generate_parser_classes.sh [artifact_type] [version ...]`
31+
32+
Artifact types: `catalog`, `manifest`, `run-results`, `sources`. Omit arguments to process all types and versions. If the user specifies a ref (e.g. branch), pass `--ref REF` only to the download script.
33+
34+
A project skill **dbt-parser-refresh** encodes this workflow in detail. Skills live in `.claude/skills/` (Cursor and Claude Code). Codex users: this repo provides `.agents/skills` as a symlink to `.claude/skills`, so the same skill is available there.

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
See [AGENTS.md](AGENTS.md) for project overview, setup, commands, and parser refresh workflow.
2+
3+
- When using Claude Code, pre-commit runs as a quality gate on Stop via [.claude/hooks/run-pre-commit.sh](.claude/hooks/run-pre-commit.sh) (configured in [.claude/settings.json](.claude/settings.json)).
4+
- Use the **dbt-parser-refresh** skill when updating parsers: `.claude/skills/dbt-parser-refresh/SKILL.md` or invoke `/dbt-parser-refresh`.

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ It installs the dependencies and set up the pre-commit hooks.
5656
make setup
5757
```
5858

59+
When using [Claude Code](https://code.claude.com/), this repo runs pre-commit as a quality gate when Claude is about to stop. Config lives in [.claude/settings.json](.claude/settings.json) and [.claude/hooks/](.claude/hooks/).
60+
5961
## How to generate Pydantic models
6062

6163
These are the steps to generate the Pydantic models from dbt artifacts in this package.
@@ -68,3 +70,9 @@ We manage the downloaded JSON schemas in the directory of [dbt_artifacts_parser/
6870

6971
[dev/generate_parser_classes.sh](./dev/generate_parser_classes.sh) is a script to generate Pydantic models from the JSON schemas of dbt artifacts.
7072
If we want to add new dbt artifact(s), we need to modify the script to generate the new pydantic models.
73+
74+
## AI agents and tools
75+
76+
Project instructions for AI agents (Codex, Cursor, Claude Code) are in [AGENTS.md](./AGENTS.md). Claude Code also uses [CLAUDE.md](./CLAUDE.md), which references AGENTS.md.
77+
78+
Skills live in [.claude/skills/](./.claude/skills/). Cursor and Claude Code load them from there. Codex reads skills from `.agents/skills`; in this repo that path is a symlink to `.claude/skills`, so the same skills are available. The `.cursor/` directory is reserved for future Cursor-specific rules if needed.

0 commit comments

Comments
 (0)