claude-cost-tracker 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_cost_tracker-0.1.0/.claude/commands/end-session.md +49 -0
- claude_cost_tracker-0.1.0/.claude/commands/shift-handoff.md +81 -0
- claude_cost_tracker-0.1.0/.claude/rules/git-conventions.md +74 -0
- claude_cost_tracker-0.1.0/.claude/rules/python.md +118 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/SKILL.md +173 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/assets/nested-CLAUDE.md +26 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/assets/root-CLAUDE.md +49 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/evals/evals.json +26 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/references/lint-checklist.md +179 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/references/templates.md +118 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/references/workflows.md +119 -0
- claude_cost_tracker-0.1.0/.claude/skills/claude-md-standards/scripts/lint_claude_md.py +622 -0
- claude_cost_tracker-0.1.0/.claude/skills/duckduckgo-search/README.md +53 -0
- claude_cost_tracker-0.1.0/.claude/skills/duckduckgo-search/SKILL.md +95 -0
- claude_cost_tracker-0.1.0/.claude/skills/duckduckgo-search/scripts/search.py +212 -0
- claude_cost_tracker-0.1.0/.claude/skills/explain-with-trees/SKILL.md +166 -0
- claude_cost_tracker-0.1.0/.claude/skills/prior-art/SKILL.md +195 -0
- claude_cost_tracker-0.1.0/.claude/skills/reconcile-docs/SKILL.md +124 -0
- claude_cost_tracker-0.1.0/.claude/skills/resume-remote-handoff/SKILL.md +167 -0
- claude_cost_tracker-0.1.0/.claude/skills/resume-remote-handoff/references/handoff-template.md +76 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-analyze/SKILL.md +262 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-checklist/SKILL.md +376 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-clarify/SKILL.md +294 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-constitution/SKILL.md +180 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-converge/SKILL.md +279 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-implement/SKILL.md +226 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-plan/SKILL.md +169 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-specify/SKILL.md +348 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-tasks/SKILL.md +217 -0
- claude_cost_tracker-0.1.0/.claude/skills/speckit-taskstoissues/SKILL.md +112 -0
- claude_cost_tracker-0.1.0/.claude/skills/web-scraper/README.md +50 -0
- claude_cost_tracker-0.1.0/.claude/skills/web-scraper/SKILL.md +76 -0
- claude_cost_tracker-0.1.0/.claude/skills/web-scraper/scripts/scrape.py +499 -0
- claude_cost_tracker-0.1.0/.claude-plugin/marketplace.json +13 -0
- claude_cost_tracker-0.1.0/.github/CODEOWNERS +1 -0
- claude_cost_tracker-0.1.0/.github/workflows/ci.yml +48 -0
- claude_cost_tracker-0.1.0/.github/workflows/release.yml +128 -0
- claude_cost_tracker-0.1.0/.gitignore +39 -0
- claude_cost_tracker-0.1.0/.specify/.gitignore +9 -0
- claude_cost_tracker-0.1.0/.specify/init-options.json +9 -0
- claude_cost_tracker-0.1.0/.specify/integration.json +15 -0
- claude_cost_tracker-0.1.0/.specify/integrations/claude.manifest.json +17 -0
- claude_cost_tracker-0.1.0/.specify/integrations/speckit.manifest.json +19 -0
- claude_cost_tracker-0.1.0/.specify/memory/.constitution-template.json +4 -0
- claude_cost_tracker-0.1.0/.specify/memory/constitution.md +227 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/check-prerequisites.sh +230 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/common.sh +918 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/create-new-feature.sh +407 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/resolve-template.sh +57 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/setup-plan.sh +85 -0
- claude_cost_tracker-0.1.0/.specify/scripts/bash/setup-tasks.sh +94 -0
- claude_cost_tracker-0.1.0/.specify/templates/checklist-template.md +40 -0
- claude_cost_tracker-0.1.0/.specify/templates/constitution-template.md +50 -0
- claude_cost_tracker-0.1.0/.specify/templates/plan-template.md +113 -0
- claude_cost_tracker-0.1.0/.specify/templates/spec-template.md +131 -0
- claude_cost_tracker-0.1.0/.specify/templates/tasks-template.md +252 -0
- claude_cost_tracker-0.1.0/.specify/workflows/speckit/workflow.yml +78 -0
- claude_cost_tracker-0.1.0/.specify/workflows/workflow-registry.json +13 -0
- claude_cost_tracker-0.1.0/CLAUDE.md +108 -0
- claude_cost_tracker-0.1.0/LICENSE +202 -0
- claude_cost_tracker-0.1.0/PKG-INFO +171 -0
- claude_cost_tracker-0.1.0/README.md +149 -0
- claude_cost_tracker-0.1.0/docs/cost-model.md +197 -0
- claude_cost_tracker-0.1.0/docs/releasing.md +141 -0
- claude_cost_tracker-0.1.0/pyproject.toml +89 -0
- claude_cost_tracker-0.1.0/scripts/release.py +249 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/checklists/requirements.md +91 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/contracts/cli.md +121 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/contracts/plugin.md +87 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/contracts/report-data.md +228 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/data-model.md +286 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/plan.md +194 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/quickstart.md +228 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/research.md +264 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/spec.md +904 -0
- claude_cost_tracker-0.1.0/specs/001-per-file-cost-attribution/tasks.md +382 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/__init__.py +19 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/__main__.py +8 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/analyse.py +348 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/capture.py +180 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/cli.py +1232 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/config/__init__.py +396 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/config/categories.py +182 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/config/components.py +155 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/config/pricing.toml +103 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/config/refresh.py +400 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/footprint.py +153 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/__init__.py +0 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/anchors.py +430 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/dedup.py +128 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/discover.py +482 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/records.py +691 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/skills.py +108 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/ingest/tokens.py +642 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/__init__.py +0 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/attribute.py +470 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/invalidation.py +388 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/lanes.py +496 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/policy.py +114 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/reconcile.py +126 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/model/residency.py +452 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/money.py +176 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/notebook.py +436 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/plugin/.claude-plugin/plugin.json +8 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/plugin/README.md +78 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/plugin/commands/audit.md +51 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/plugin/hooks/hooks.json +15 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/plugin/skills/ccost/SKILL.md +69 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/__init__.py +0 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/assets/report.css +1303 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/assets/report.js +542 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/assets/ui.css +646 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/assets/ui.js +221 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/charts/__init__.py +409 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/charts/bars.py +459 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/charts/hierarchy.py +277 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/charts/scatter.py +487 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/charts/timeline.py +398 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/data.py +1802 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/explain.py +258 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/report.py +1053 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/serve.py +644 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/render/terminal.py +498 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/__init__.py +0 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/cache.py +184 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/claims.py +273 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/codec.py +201 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/db.py +191 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/results.py +651 -0
- claude_cost_tracker-0.1.0/src/claude_cost_tracker/store/schema.sql +254 -0
- claude_cost_tracker-0.1.0/tests/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/component/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/component/test_analyse_pipeline.py +202 -0
- claude_cost_tracker-0.1.0/tests/conftest.py +48 -0
- claude_cost_tracker-0.1.0/tests/fixtures/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/fixtures/builder.py +405 -0
- claude_cost_tracker-0.1.0/tests/golden/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/golden/fixtures/session_basic/expected.json +75 -0
- claude_cost_tracker-0.1.0/tests/golden/fixtures/session_basic/expected.md +117 -0
- claude_cost_tracker-0.1.0/tests/golden/fixtures/session_basic/transcript.jsonl +9 -0
- claude_cost_tracker-0.1.0/tests/golden/fixtures/session_cause_profiles/transcript.jsonl +35 -0
- claude_cost_tracker-0.1.0/tests/golden/fixtures/session_hostile/transcript.jsonl +13 -0
- claude_cost_tracker-0.1.0/tests/golden/test_attribution_basic.py +172 -0
- claude_cost_tracker-0.1.0/tests/golden/test_cause_profiles.py +113 -0
- claude_cost_tracker-0.1.0/tests/golden/test_hostile_session.py +140 -0
- claude_cost_tracker-0.1.0/tests/system/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/system/test_cache.py +303 -0
- claude_cost_tracker-0.1.0/tests/system/test_cli_end_to_end.py +258 -0
- claude_cost_tracker-0.1.0/tests/system/test_multi_session.py +208 -0
- claude_cost_tracker-0.1.0/tests/system/test_no_egress.py +144 -0
- claude_cost_tracker-0.1.0/tests/system/test_notebook.py +368 -0
- claude_cost_tracker-0.1.0/tests/system/test_performance.py +130 -0
- claude_cost_tracker-0.1.0/tests/system/test_precision_audit.py +158 -0
- claude_cost_tracker-0.1.0/tests/system/test_report_offline.py +581 -0
- claude_cost_tracker-0.1.0/tests/system/test_ui_server.py +293 -0
- claude_cost_tracker-0.1.0/tests/test_package.py +8 -0
- claude_cost_tracker-0.1.0/tests/unit/__init__.py +0 -0
- claude_cost_tracker-0.1.0/tests/unit/test_anchors.py +203 -0
- claude_cost_tracker-0.1.0/tests/unit/test_attribute.py +252 -0
- claude_cost_tracker-0.1.0/tests/unit/test_capture.py +128 -0
- claude_cost_tracker-0.1.0/tests/unit/test_charts.py +1234 -0
- claude_cost_tracker-0.1.0/tests/unit/test_claims.py +287 -0
- claude_cost_tracker-0.1.0/tests/unit/test_cli.py +473 -0
- claude_cost_tracker-0.1.0/tests/unit/test_codec.py +138 -0
- claude_cost_tracker-0.1.0/tests/unit/test_config.py +321 -0
- claude_cost_tracker-0.1.0/tests/unit/test_dedup.py +251 -0
- claude_cost_tracker-0.1.0/tests/unit/test_discover.py +700 -0
- claude_cost_tracker-0.1.0/tests/unit/test_explain.py +213 -0
- claude_cost_tracker-0.1.0/tests/unit/test_footprint.py +113 -0
- claude_cost_tracker-0.1.0/tests/unit/test_grouping.py +179 -0
- claude_cost_tracker-0.1.0/tests/unit/test_invalidation.py +312 -0
- claude_cost_tracker-0.1.0/tests/unit/test_lanes.py +447 -0
- claude_cost_tracker-0.1.0/tests/unit/test_money.py +184 -0
- claude_cost_tracker-0.1.0/tests/unit/test_plugin.py +129 -0
- claude_cost_tracker-0.1.0/tests/unit/test_policy.py +115 -0
- claude_cost_tracker-0.1.0/tests/unit/test_pricing_refresh.py +223 -0
- claude_cost_tracker-0.1.0/tests/unit/test_reconcile.py +165 -0
- claude_cost_tracker-0.1.0/tests/unit/test_records.py +393 -0
- claude_cost_tracker-0.1.0/tests/unit/test_release.py +95 -0
- claude_cost_tracker-0.1.0/tests/unit/test_report_data.py +979 -0
- claude_cost_tracker-0.1.0/tests/unit/test_residency.py +340 -0
- claude_cost_tracker-0.1.0/tests/unit/test_results.py +484 -0
- claude_cost_tracker-0.1.0/tests/unit/test_serve.py +562 -0
- claude_cost_tracker-0.1.0/tests/unit/test_skills.py +78 -0
- claude_cost_tracker-0.1.0/tests/unit/test_store_db.py +390 -0
- claude_cost_tracker-0.1.0/tests/unit/test_terminal.py +327 -0
- claude_cost_tracker-0.1.0/tests/unit/test_tokens.py +353 -0
- claude_cost_tracker-0.1.0/uv.lock +1381 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: End-of-session wind-down. Runs reconcile-docs → next-steps decomposition (PLAN-ONLY) → shift-handoff, in that fixed order, so the next session can resume correctly with zero re-derivation. Reconciles the living docs to reality, defines the next session's steps as a persisted plan (without executing anything), then writes the next-agent handoff prompt.
|
|
3
|
+
argument-hint: [optional: notes/focus for the next session, e.g. "next: finish the carry-cost model"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are ending a work session. This command runs the wind-down ritual as a **fixed, ordered sequence** whose single goal is to leave the project in a state where the next session — human or agent — resumes correctly **without re-deriving anything from this conversation** (which will not exist next session).
|
|
7
|
+
|
|
8
|
+
It answers three questions, in order. Do not reorder them; each step depends on the previous one's output:
|
|
9
|
+
|
|
10
|
+
1. **Where are we now?** → `reconcile-docs` (make the on-disk docs equal reality)
|
|
11
|
+
2. **Where do we go next?** → next-steps decomposition, **plan-only**
|
|
12
|
+
3. **How does the next agent pick this up?** → `shift-handoff` (write the resume prompt)
|
|
13
|
+
|
|
14
|
+
**Optional notes for the next session:** $ARGUMENTS
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Preflight — is a wind-down even warranted?
|
|
19
|
+
|
|
20
|
+
Honestly check: did this session move **durable project state** (decisions made, code/config changed, state advanced, something to reconcile)? If it was trivial or throwaway (a quick question, a one-line fix, nothing a future reader needs), **stop and tell the user the wind-down isn't needed** — running it would write empty ceremony into the docs. Otherwise proceed.
|
|
21
|
+
|
|
22
|
+
## Step 1 — `reconcile-docs` (capture reality first)
|
|
23
|
+
|
|
24
|
+
Invoke the **reconcile-docs** skill. Bring `HANDOFF.md`, `PITFALLS.md` (and any `docs/` or `specs/` the session touched or invalidated) into **full agreement with the current system state**. The bar is the skill's read-through contract: an operator reading each document top to bottom, executing as they go, lands in the correct final state having hit **zero contradictions** — so resolve stale/contradicting passages at the source, don't just append.
|
|
25
|
+
|
|
26
|
+
This runs **first** on purpose: steps 2 and 3 must build on accurate docs, not stale ones.
|
|
27
|
+
|
|
28
|
+
## Step 2 — Next steps, PLAN-ONLY (define, do NOT execute)
|
|
29
|
+
|
|
30
|
+
Define the **next** session's work as a persisted plan:
|
|
31
|
+
|
|
32
|
+
- Slice the remaining / next work into **ordered, independently-verifiable sub-tasks**, each with a named done-check or oracle — a build tree with gating checks, not a vague to-do list.
|
|
33
|
+
- Fold in anything from **$ARGUMENTS** above.
|
|
34
|
+
- **Persist the plan where the next session will find it.** If the work belongs to an active spec-kit feature, that is the feature's `specs/<feature>/tasks.md`. Otherwise, a clearly-marked **"Next steps"** section in `HANDOFF.md`.
|
|
35
|
+
|
|
36
|
+
**HARD GUARD — this is session close, not a launch.** Do **NOT** begin execution, do **NOT** dispatch subagents, do **NOT** start any long-horizon/unattended/"keep going overnight" run. You are *writing the plan the next session will execute*, not executing it. The deliverable is the persisted, dependency-ordered next-steps plan, full stop.
|
|
37
|
+
|
|
38
|
+
## Step 3 — `shift-handoff` (write the resume prompt last)
|
|
39
|
+
|
|
40
|
+
Invoke the **shift-handoff** skill to produce the warm compaction prompt for the next agent. Because it runs last, it can — and must — point at both prior outputs:
|
|
41
|
+
|
|
42
|
+
- "The on-disk docs (`HANDOFF.md` / `PITFALLS.md`) are **current as of this session** — read them first."
|
|
43
|
+
- "The **next steps** are defined in [`specs/<feature>/tasks.md` / `HANDOFF.md`] — start there."
|
|
44
|
+
|
|
45
|
+
**Boundary note (intended, not duplication):** `reconcile-docs` makes the *file* `HANDOFF.md` correct for a **human operator**; `shift-handoff` writes a *chat prompt* for the **next agent**. Different artifacts, different consumers — both are wanted.
|
|
46
|
+
|
|
47
|
+
## Close
|
|
48
|
+
|
|
49
|
+
End with a tight state-check: what was reconciled (which docs, which contradictions resolved), where the next-steps plan now lives, and confirmation the handoff prompt is ready. Then it's safe to take the break.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate a warm, complete compaction prompt for the next agent taking over this session — covers project state, decisions locked, pitfalls, open work, and attitude. Use at the end of a productive session before taking a break.
|
|
3
|
+
argument-hint: [optional: specific area to emphasize, e.g. "focus on the auth refactor" or "we stopped mid-migration"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Compaction Prompt
|
|
7
|
+
|
|
8
|
+
We've had a great session together and we're wrapping up for now. Your job is to write a **compaction prompt** — a warm, self-contained briefing that the next agent (a fresh session with no memory of today) can paste as their very first message to pick up exactly where we left off.
|
|
9
|
+
|
|
10
|
+
**Optional emphasis:** $ARGUMENTS
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What to gather before writing
|
|
15
|
+
|
|
16
|
+
Read every one of these before producing a single word of the briefing. Do not skip any that exist:
|
|
17
|
+
|
|
18
|
+
1. `HANDOFF.md` — handoff notes and in-progress context
|
|
19
|
+
2. `PITFALLS.md` — hard-won lessons and known traps
|
|
20
|
+
3. `git log --oneline -20` — the last 20 commits (what actually shipped today)
|
|
21
|
+
4. Any open TODO/FIXME markers in recently touched files if you can identify them quickly
|
|
22
|
+
|
|
23
|
+
If none of these files exist, synthesize from the current conversation context instead and note that the memory files are absent.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Required sections in the compaction prompt
|
|
28
|
+
|
|
29
|
+
Write the compaction prompt as a single cohesive message the next agent pastes verbatim. Structure it with these sections, in order:
|
|
30
|
+
|
|
31
|
+
### 1. Welcome & project identity (2–4 sentences)
|
|
32
|
+
|
|
33
|
+
Greet the incoming agent warmly. Name the project, its purpose, and why it matters. Set the tone: collaborative, no tribal knowledge, every assumption explained.
|
|
34
|
+
|
|
35
|
+
### 2. What we accomplished this session (bullet list)
|
|
36
|
+
|
|
37
|
+
Concrete, specific. Reference file names, function names, commit messages. Not vague like "made progress on auth" — specific like "extracted `useAuthToken` hook in `src/hooks/auth.ts` and wired it into the login form".
|
|
38
|
+
|
|
39
|
+
### 3. Current state of the codebase (2–5 sentences + key file map)
|
|
40
|
+
|
|
41
|
+
Where does the code stand right now? What's working, what's partial, what's intentionally left rough? List the 3–7 most important files/directories the incoming agent will need to touch or understand.
|
|
42
|
+
|
|
43
|
+
### 4. The open work — next tasks in priority order (numbered list)
|
|
44
|
+
|
|
45
|
+
What remains? Number them by priority. For each: one sentence of what, one sentence of why it matters, one sentence of where to start (file + line if possible).
|
|
46
|
+
|
|
47
|
+
### 5. Decisions already locked — do not re-litigate (bullet list)
|
|
48
|
+
|
|
49
|
+
Choices that were weighed and made. The incoming agent must not re-open these without the human's explicit instruction. For each: the decision + the reason it was made.
|
|
50
|
+
|
|
51
|
+
### 6. Pitfalls and gotchas (bullet list)
|
|
52
|
+
|
|
53
|
+
Everything in `PITFALLS.md` plus anything that burned us today. Format: **"The trap:"** what it looks like vs. **"The rule:"** what to do instead.
|
|
54
|
+
|
|
55
|
+
### 7. Project conventions and attitude (short paragraph)
|
|
56
|
+
|
|
57
|
+
How does this project work? Key naming conventions, file layout, commit style, push-back policy from `CLAUDE.md`. What attitude does the human want from their agent partner — when to push back vs. when to just execute?
|
|
58
|
+
|
|
59
|
+
### 8. First action for the incoming agent
|
|
60
|
+
|
|
61
|
+
One concrete instruction: the exact first thing they should do when they arrive. Not "get oriented" — something like "Run `npm test` to verify the baseline, then open `src/api/auth.ts:142` where the incomplete token refresh logic lives."
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Tone requirements
|
|
66
|
+
|
|
67
|
+
- Warm and collegial — you are briefing a capable colleague, not writing documentation.
|
|
68
|
+
- No tribal knowledge withheld. Explain every abbreviation, every convention, every "we always do X because…"
|
|
69
|
+
- Honest about what is incomplete or uncertain — false confidence is a trap.
|
|
70
|
+
- Concise within each section. Dense, not padded. The incoming agent is smart; they need facts and pointers, not re-explanations of basics.
|
|
71
|
+
- End the compaction prompt with a short motivational note: acknowledge the work done, express confidence in the incoming agent, and wish them a productive shift.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Output format
|
|
76
|
+
|
|
77
|
+
Produce exactly two things:
|
|
78
|
+
|
|
79
|
+
**First:** A brief note to the human (2–3 sentences) saying what you drew from and any gaps you noticed (e.g. "HANDOFF.md is missing — I synthesized from conversation context").
|
|
80
|
+
|
|
81
|
+
**Second:** The full compaction prompt, fenced in a markdown code block so it can be copied cleanly. Label it clearly: `# Compaction Prompt — paste this as your first message in the new session`.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Git Conventions
|
|
2
|
+
|
|
3
|
+
## Branch Naming
|
|
4
|
+
|
|
5
|
+
Land **big or possibly-breaking changes on a side branch first**, verify everything is
|
|
6
|
+
stable there, and only then merge to `main` — keep `main` always working. (Small, safe
|
|
7
|
+
changes may still go straight to `main`.) Side branches are named:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
usr/<username>/<short-description>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- `<username>` is your git handle (e.g. `tal-afek`), so a glance at `git branch` tells you
|
|
14
|
+
who owns which line of work.
|
|
15
|
+
- `<short-description>` is a hyphenated summary of the work (e.g. `carry-cost-model`), not
|
|
16
|
+
a ticket number.
|
|
17
|
+
|
|
18
|
+
Example: `usr/tal-afek/carry-cost-model`. Merge to `main` (or open a PR) once the branch
|
|
19
|
+
is green and stable.
|
|
20
|
+
|
|
21
|
+
## Meaningful Commits
|
|
22
|
+
|
|
23
|
+
Organize work into multiple, meaningful commits: the history should tell a story, and each
|
|
24
|
+
commit a distinct chapter. Avoid commits like "Fixes" or "PR comments" — commits should be
|
|
25
|
+
pristine.
|
|
26
|
+
|
|
27
|
+
Each commit should stand on its own: lint, type-check, and tests pass at that commit.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
uv run ruff check && uv run mypy && uv run pytest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commit Messages
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
<component>: [<subcomponent>:] <action>
|
|
37
|
+
|
|
38
|
+
<optional description>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Note the double line break before the description. The `action` is a short, meaningful
|
|
42
|
+
message in present tense.
|
|
43
|
+
|
|
44
|
+
Example: `ingest: jsonl: Dedup records on message id and request id`
|
|
45
|
+
|
|
46
|
+
### Keep the body to 5 lines, max
|
|
47
|
+
|
|
48
|
+
The subject carries the change; the body says **why**, in **at most 5 lines**. Wrap at 72
|
|
49
|
+
columns. If it does not fit, the extra material does not belong in a commit message:
|
|
50
|
+
|
|
51
|
+
- **Design rationale** → the spec / decisions doc under `specs/`, or a comment at the point
|
|
52
|
+
of the decision (Principle VII: code decisions live inline, not in prose).
|
|
53
|
+
- **A landmine you hit** → `PITFALLS.md`. **Project state** → `HANDOFF.md`.
|
|
54
|
+
- **Evidence** (test counts, verification steps, per-file tallies) → say it in the PR or
|
|
55
|
+
the review conversation, not in permanent history.
|
|
56
|
+
|
|
57
|
+
A long body is usually a sign the commit itself is too big — split it instead. Nobody
|
|
58
|
+
reads a 40-line commit message; `git log --oneline` is how history is actually read.
|
|
59
|
+
|
|
60
|
+
## No tool attribution
|
|
61
|
+
|
|
62
|
+
Do not add trailers that attribute a commit to a tool or assistant. In particular, **never
|
|
63
|
+
append a `Co-Authored-By:` line** (e.g. for Claude / Claude Code) to the subject or body,
|
|
64
|
+
and never add a "Generated with" footer or a 🤖 trailer. Commits carry the human author
|
|
65
|
+
only. This holds even when a harness or default template suggests adding one.
|
|
66
|
+
|
|
67
|
+
## What never gets committed
|
|
68
|
+
|
|
69
|
+
- Real session transcripts, or anything copied out of `~/.claude/`. They contain file
|
|
70
|
+
paths, shell commands, and source from other projects.
|
|
71
|
+
- Generated reports, databases, or scan output — these are derived artifacts
|
|
72
|
+
(`.gitignore` covers `*.db`, `*.duckdb`, `data/`, `out/`, `reports/`).
|
|
73
|
+
- Test fixtures are the exception: they are **synthetic or scrubbed**, small, committed
|
|
74
|
+
deliberately, and reviewed for anything sensitive before they land.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Conventions
|
|
7
|
+
|
|
8
|
+
Conventions for the code assistant when writing or modifying Python in this project.
|
|
9
|
+
These are the language-specific *how*; the durable *why* — fail-fast, test discipline,
|
|
10
|
+
scripting standards, honest numbers — is the
|
|
11
|
+
[constitution](../../.specify/memory/constitution.md). On conflict, the constitution wins.
|
|
12
|
+
|
|
13
|
+
## Tooling — always through `uv`
|
|
14
|
+
|
|
15
|
+
- **Never invoke the OS Python.** Every Python action goes through `uv`, which manages its
|
|
16
|
+
own interpreter and environment: `uv run python …`, `uv run ruff …`, `uv run mypy`,
|
|
17
|
+
`uv run pytest`. Do not call a bare `python`, `python3`, or `pip`.
|
|
18
|
+
- Configuration lives in [`pyproject.toml`](../../pyproject.toml).
|
|
19
|
+
- **Keep the runtime dependency set small and boring.** This tool must stay easy to run on
|
|
20
|
+
someone else's machine with one command (constitution, Principle II — local-first). A
|
|
21
|
+
dependency that pulls in a service, a daemon, or a heavyweight toolchain is the wrong
|
|
22
|
+
dependency.
|
|
23
|
+
- **Do not introduce a new library when an existing dependency (or the standard library)
|
|
24
|
+
already covers the need** — no second way to do the same thing (Principle II). When a
|
|
25
|
+
genuinely new capability is required, research the most popular, well-maintained options
|
|
26
|
+
and pick the best **long-term** choice (adoption, maintenance, license, fit), not the
|
|
27
|
+
first hit.
|
|
28
|
+
- Standalone scripts use [PEP 723](https://peps.python.org/pep-0723/) inline metadata so
|
|
29
|
+
they run via `uv run` with no project install.
|
|
30
|
+
|
|
31
|
+
## Formatting & linting — `ruff`
|
|
32
|
+
|
|
33
|
+
- `ruff` is both formatter and linter. Format with `uv run ruff format`; lint with
|
|
34
|
+
`uv run ruff check` (add `--fix` to auto-apply safe fixes).
|
|
35
|
+
- **Line length 100.**
|
|
36
|
+
- Code MUST be clean under `ruff check` before a change is done.
|
|
37
|
+
|
|
38
|
+
## Type checking — `mypy` (non-strict)
|
|
39
|
+
|
|
40
|
+
- **Type hints are required** on every function/method signature (parameters and return)
|
|
41
|
+
and on module-level constants where the type is not obvious.
|
|
42
|
+
- `uv run mypy` MUST pass. It runs **non-strict** by decision — do not enable `--strict`
|
|
43
|
+
or `strict = true`.
|
|
44
|
+
|
|
45
|
+
## Suppressions need human approval
|
|
46
|
+
|
|
47
|
+
- Adding a `# noqa`, a `# type: ignore`, or any typing escape hatch (`cast`, `Any` to
|
|
48
|
+
dodge a checker) is a **deliberate deviation** and requires **explicit human approval
|
|
49
|
+
before it is added**. Fix the underlying issue first; suppress only when there is no
|
|
50
|
+
correct alternative, and justify it inline at the point of use.
|
|
51
|
+
|
|
52
|
+
## Naming
|
|
53
|
+
|
|
54
|
+
- **Functions, variables, module names:** `snake_case`.
|
|
55
|
+
- **Classes:** `PascalCase`. **Constants:** `UPPER_SNAKE_CASE`.
|
|
56
|
+
- **Internal helpers:** prefix with a single underscore (`_helper`).
|
|
57
|
+
- Names are descriptive, not compressed — `cache_read_tokens`, not `crtok`.
|
|
58
|
+
- **Domain terms match the central vocabulary.** Cost components, attribution policies,
|
|
59
|
+
and file categories use the names defined in the single authoritative config
|
|
60
|
+
(Principle IX) — never a local synonym invented at the call site.
|
|
61
|
+
|
|
62
|
+
## Structure & style
|
|
63
|
+
|
|
64
|
+
- Prefer small, single-purpose functions; validate arguments early and return early.
|
|
65
|
+
- Prefer standard-library primitives and existing helpers before writing new ones
|
|
66
|
+
(KISS / reuse — Principle II). No second way to do the same thing.
|
|
67
|
+
- Use `pathlib` over manual string path joining; use f-strings over `%` / `.format`.
|
|
68
|
+
- Group imports stdlib → third-party → local; `ruff`'s import sorting enforces this.
|
|
69
|
+
- **All imports and module-level globals/constants at the top of the file** — imports right
|
|
70
|
+
after the module docstring, then module constants and shared state (before any `def` /
|
|
71
|
+
`class` that uses them). **No imports inside functions or other scopes** (no lazy/local
|
|
72
|
+
imports); if a heavy or circular import tempts you into a function, fix the dependency
|
|
73
|
+
instead. Mutable module state is declared once, at the top, and mutated via `global`.
|
|
74
|
+
- **Avoid unnecessary module-level globals.** Give state and constants the narrowest scope
|
|
75
|
+
that works; a value used by a single function belongs inside it. Mutable module state
|
|
76
|
+
must be justified.
|
|
77
|
+
|
|
78
|
+
## Numeric handling
|
|
79
|
+
|
|
80
|
+
- **Money is never a float in a stored or compared value.** Use integer minor units
|
|
81
|
+
(micro-dollars) or `Decimal` for anything persisted, summed, or asserted on; floats are
|
|
82
|
+
for display only. Rounding happens at the presentation edge, once.
|
|
83
|
+
- **Sums must reconcile** (Principle X). When splitting a total across buckets, allocate
|
|
84
|
+
the remainder explicitly rather than letting rounding silently lose or invent value; a
|
|
85
|
+
breakdown that does not add up to its total is a show-stopper defect.
|
|
86
|
+
- Token counts are integers. Never estimate one where an exact count is available in the
|
|
87
|
+
source data.
|
|
88
|
+
|
|
89
|
+
## Fail-fast
|
|
90
|
+
|
|
91
|
+
- Mirror the constitution's Scripting Standards: **exit immediately on error with a clear
|
|
92
|
+
message**; validate required tools/paths *before* mutating any state; keep scripts
|
|
93
|
+
**idempotent** (safe to re-run after a mid-run failure).
|
|
94
|
+
- Raise on broken invariants rather than limping on — do not silently swallow exceptions.
|
|
95
|
+
Catch only where you can genuinely recover, and narrow the `except`.
|
|
96
|
+
- **Malformed input records are named, not skipped in silence.** A transcript record that
|
|
97
|
+
cannot be parsed is counted and surfaced in the run summary.
|
|
98
|
+
|
|
99
|
+
## Docstrings & comments
|
|
100
|
+
|
|
101
|
+
- Public functions/classes get a one-line docstring stating contract (inputs, outputs,
|
|
102
|
+
side effects) when not obvious from the signature.
|
|
103
|
+
- Comment **why**, not **what**. Keep comments current with the code.
|
|
104
|
+
- **Attribution arithmetic carries its rationale inline** — the formula, the policy it
|
|
105
|
+
implements, and what the number means. This is the code a reader will most need to
|
|
106
|
+
audit (Principle X).
|
|
107
|
+
|
|
108
|
+
## Tests
|
|
109
|
+
|
|
110
|
+
- Definition of done for Python: `uv run ruff format`, `uv run ruff check`, `uv run mypy`,
|
|
111
|
+
and `uv run pytest` all clean.
|
|
112
|
+
- **Prefer `pytest` fixtures for reusable setup/teardown** — any setup, resource, or
|
|
113
|
+
helper state that can and should be shared belongs in a fixture, not copy-pasted across
|
|
114
|
+
tests. Always choose the **correct scope** for each fixture (`function`, `class`,
|
|
115
|
+
`module`, `session`): the narrowest scope that still shares the work, balancing
|
|
116
|
+
isolation against setup cost.
|
|
117
|
+
- Fixture transcripts live in the test tree and are committed. Never point a test at the
|
|
118
|
+
developer's real `~/.claude/` data — it is not reproducible and it is not shareable.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-md-standards
|
|
3
|
+
description: >-
|
|
4
|
+
Create, lint, edit, or review CLAUDE.md files (and AGENTS.md — near-identical
|
|
5
|
+
format, lessons transfer) against industry-wide best practices. Use whenever
|
|
6
|
+
the user wants to write, audit, clean up, shrink, split, refactor, or
|
|
7
|
+
"improve" a CLAUDE.md / AGENTS.md / agent-instruction / agent-memory file, set
|
|
8
|
+
up `.claude/rules/`, bootstrap agent context for a repo that has none, or asks
|
|
9
|
+
whether their CLAUDE.md is any good — even if they just say "my CLAUDE.md is
|
|
10
|
+
too long", "check my agent instructions", or "how should I structure this".
|
|
11
|
+
Ships a real linter script, so also use it to mechanically check a file for
|
|
12
|
+
secrets, dangerous example commands, broken @imports, size/budget, and vague
|
|
13
|
+
instructions.
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Authoring and linting CLAUDE.md files
|
|
17
|
+
|
|
18
|
+
A `CLAUDE.md` (and its cross-tool cousin `AGENTS.md`) is persistent context fed
|
|
19
|
+
to a coding agent at the *start of every session*. That framing drives every
|
|
20
|
+
rule here: a line in this file is not documentation a human reads once — it is
|
|
21
|
+
re-transmitted to a model on every run and spends part of a finite attention and
|
|
22
|
+
token budget each time. So the goal is never "write down everything true about
|
|
23
|
+
the repo"; it is **the smallest set of high-signal, checkable instructions the
|
|
24
|
+
agent genuinely cannot infer on its own.** Less is more, but *specific* less.
|
|
25
|
+
|
|
26
|
+
The same file is read as context by other tools too, so the advice below is
|
|
27
|
+
Claude-Code-first but calls out where behavior is tool-specific.
|
|
28
|
+
|
|
29
|
+
## Which job is this?
|
|
30
|
+
|
|
31
|
+
Route to the matching section; each points at the deeper reference file.
|
|
32
|
+
|
|
33
|
+
| The user wants to… | Go to |
|
|
34
|
+
|------------------------------------------------------|--------------|
|
|
35
|
+
| Check / audit / "is this good?" an existing file | **Lint** |
|
|
36
|
+
| Shrink, split, dedupe, de-stale a bloated file | **Edit/refactor** |
|
|
37
|
+
| Write one for a repo that has none | **Create** |
|
|
38
|
+
|
|
39
|
+
More than one can apply (create → then lint the draft; lint → then refactor what
|
|
40
|
+
it found). Do them in that order.
|
|
41
|
+
|
|
42
|
+
## Core principles (the "why" behind every rule)
|
|
43
|
+
|
|
44
|
+
Internalize these five; the specific rules are downstream of them.
|
|
45
|
+
|
|
46
|
+
1. **Context, not configuration.** Claude *reads* CLAUDE.md as guidance — it does
|
|
47
|
+
not *enforce* it. Anything that must be guaranteed (tests run before commit,
|
|
48
|
+
formatting) belongs in a **hook** or CI check, not in prose here. Telling the
|
|
49
|
+
file to do a linter's job is the single most common wasted instruction.
|
|
50
|
+
2. **Specific and checkable beats general and true.** "Use React 18 with the App
|
|
51
|
+
Router" and one real code snippet beat "follow front-end best practices."
|
|
52
|
+
Anything the model already knows, or can't verify, is noise.
|
|
53
|
+
3. **Every line costs budget every session.** Frontier models track on the order
|
|
54
|
+
of a couple hundred discrete instructions reliably and degrade past that; the
|
|
55
|
+
tool's own system prompt already spends some of that before your file loads.
|
|
56
|
+
Short is not aesthetic — it is functional.
|
|
57
|
+
4. **Put detail where it loads only when needed.** Root CLAUDE.md loads every
|
|
58
|
+
session; a **nested** `CLAUDE.md` loads only when a file in its directory is
|
|
59
|
+
touched; a `.claude/rules/*.md` with a `paths:` glob loads only for matching
|
|
60
|
+
files. Scope detail down the tree instead of piling it into the root.
|
|
61
|
+
5. **It rots.** An unowned file that only grows is the default failure mode. Give
|
|
62
|
+
it an owner, review changes to it like code, and re-lint periodically.
|
|
63
|
+
|
|
64
|
+
## Lint
|
|
65
|
+
|
|
66
|
+
Run the bundled linter — it does the mechanical checks deterministically so you
|
|
67
|
+
can spend judgment on the rest:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
python .claude/skills/claude-md-standards/scripts/lint_claude_md.py <file-or-dir> --opinionated
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- Pass a **directory** to scan the whole repo (root + nested CLAUDE.md +
|
|
74
|
+
`.claude/rules/*.md`) and get cross-file duplicate-content detection. It prunes
|
|
75
|
+
`.git`, `node_modules`, `obj`, `build`, etc., so it is safe to point at a repo
|
|
76
|
+
root — but do **not** point it above the repo (see the devpod filesystem rules).
|
|
77
|
+
- `--opinionated` adds the lower-confidence checks (hedging, filler,
|
|
78
|
+
instruction-count). Drop it for only the high-confidence findings.
|
|
79
|
+
- `--json` for machine-readable output; `--strict` to make warnings fail the exit
|
|
80
|
+
code; `--no-strong` for hard rules only. Thresholds (`--max-lines`,
|
|
81
|
+
`--error-lines`, `--import-depth`, …) are all configurable per project.
|
|
82
|
+
|
|
83
|
+
**Interpreting results — respect the confidence tiers** (this is deliberate; do
|
|
84
|
+
not "fix" everything with equal force):
|
|
85
|
+
|
|
86
|
+
- **`error` / `[hard]`** — mechanical and near-certain (secrets, dangerous
|
|
87
|
+
example commands, broken/circular `@import`s). Fix these first and always.
|
|
88
|
+
- **`warning` / `[strong]`** — multi-source consensus (size budget, vague
|
|
89
|
+
instructions, unscoped rule files, content placement). Act on them by default,
|
|
90
|
+
but the *thresholds* are project preferences — a team may legitimately set
|
|
91
|
+
`--max-lines 300`.
|
|
92
|
+
- **`info` / `[opinionated]`** — one credible source, or genuinely unsolved
|
|
93
|
+
(hedging, filler, staleness). Raise them as suggestions; never present them as
|
|
94
|
+
hard rules.
|
|
95
|
+
|
|
96
|
+
Two important things the script **cannot** judge and you must, by reading the
|
|
97
|
+
file: **staleness** (does an inline snippet still match the real source? prefer a
|
|
98
|
+
`file:line` pointer over a copy) and **whether "necessary" content is truly
|
|
99
|
+
necessary** (could the model infer it from the code?). The full rule catalog,
|
|
100
|
+
with the source and confidence behind each rule, is in
|
|
101
|
+
[`references/lint-checklist.md`](references/lint-checklist.md) — read it when you
|
|
102
|
+
need to explain or justify a finding, or tune what runs.
|
|
103
|
+
|
|
104
|
+
## Edit / refactor
|
|
105
|
+
|
|
106
|
+
For a bloated or stale file, follow the measure → decide → dedupe → re-measure
|
|
107
|
+
loop. The key decision is **why** it's oversized, which picks the fix — and the
|
|
108
|
+
traps (especially that `@import` is *not* lazy loading) are easy to get wrong.
|
|
109
|
+
The full decision tree lives in
|
|
110
|
+
[`references/workflows.md`](references/workflows.md#editrefactor); the short form:
|
|
111
|
+
|
|
112
|
+
1. **Lint first** to get numbers and clear all `error`s before touching structure.
|
|
113
|
+
2. **Route each oversized chunk by cause:**
|
|
114
|
+
- Generic / inferable content → **delete** it (highest leverage, zero loss).
|
|
115
|
+
- Necessary but *directory-specific* detail → move to a **nested `CLAUDE.md`**
|
|
116
|
+
(loads on demand).
|
|
117
|
+
- Necessary, *cross-cutting*, topic-coherent detail → move to
|
|
118
|
+
**`.claude/rules/<topic>.md` with a `paths:` glob** (loads only for matching
|
|
119
|
+
files).
|
|
120
|
+
- Deep reference rarely needed in full → move to a docs file and leave a
|
|
121
|
+
**one-line pointer** (progressive disclosure).
|
|
122
|
+
- **Trap:** `@import` still loads the imported file into context at launch — it
|
|
123
|
+
organizes *source text*, it does **not** reduce what loads. Only nested files
|
|
124
|
+
and path-scoped rules are truly lazy.
|
|
125
|
+
3. **Dedupe across the hierarchy** — delete anything a child restates from an
|
|
126
|
+
ancestor; inheritance is automatic (root-to-cwd concatenation).
|
|
127
|
+
4. **Re-lint** to confirm you actually reduced size, not just moved bulk around.
|
|
128
|
+
|
|
129
|
+
## Create
|
|
130
|
+
|
|
131
|
+
**There is a real, unresolved disagreement here — surface it, don't silently pick
|
|
132
|
+
a side.** Anthropic's docs say run `/init` and refine the output; a credible
|
|
133
|
+
practitioner camp argues *against* auto-generation because a bad line in this
|
|
134
|
+
file compounds across every future session, unlike a bad line of ordinary code.
|
|
135
|
+
|
|
136
|
+
Reconcile the two by treating any generated draft as **raw material that must pass
|
|
137
|
+
the same review + lint gate a hand-authored file would**:
|
|
138
|
+
|
|
139
|
+
1. **Inspect, don't assume** — build/test commands, stack + versions, and
|
|
140
|
+
directory layout are discoverable from manifests, CI config, and `README.md`
|
|
141
|
+
(this is what `/init` already reads; make it explicit). Also fold in any
|
|
142
|
+
existing `.cursorrules`, `AGENTS.md`, or `.github/copilot-instructions.md`.
|
|
143
|
+
2. **Ask the user, don't infer** — repository etiquette (branch/commit/PR
|
|
144
|
+
conventions), deliberate boundaries ("never touch X", "ask before Y"), and
|
|
145
|
+
whether smaller/non-frontier models will run against this file (it changes the
|
|
146
|
+
instruction budget).
|
|
147
|
+
3. **Draft from the template** in
|
|
148
|
+
[`references/templates.md`](references/templates.md), using the copyable
|
|
149
|
+
starters in [`assets/`](assets/). Keep only what survives the "can the agent
|
|
150
|
+
infer this?" filter.
|
|
151
|
+
4. **Lint the draft before calling it done** — this is the mechanism that
|
|
152
|
+
resolves the tension: a generated draft that passes the same gate has already
|
|
153
|
+
had its generic and vague content flagged out.
|
|
154
|
+
|
|
155
|
+
Full workflow, including exactly what to inspect/ask/infer, is in
|
|
156
|
+
[`references/workflows.md`](references/workflows.md#create-from-scratch).
|
|
157
|
+
|
|
158
|
+
## Structure & templates
|
|
159
|
+
|
|
160
|
+
Section order and the include/exclude line for a root file, how a nested file
|
|
161
|
+
differs, and the ready-to-paste "✅ Always / ⚠️ Ask first / 🚫 Never" boundaries
|
|
162
|
+
block are all in [`references/templates.md`](references/templates.md). Copyable
|
|
163
|
+
skeletons: [`assets/root-CLAUDE.md`](assets/root-CLAUDE.md) and
|
|
164
|
+
[`assets/nested-CLAUDE.md`](assets/nested-CLAUDE.md).
|
|
165
|
+
|
|
166
|
+
## Anti-patterns
|
|
167
|
+
|
|
168
|
+
Ten common failure modes with their fixes (treating the file as enforced config;
|
|
169
|
+
unowned append-only growth; stuffing everything in "just in case"; using it as a
|
|
170
|
+
linter; `@import`-as-lazy-loading; secrets; cross-file duplication; auto-generate-
|
|
171
|
+
and-forget; assuming precedence is identical across tools) are tabulated in
|
|
172
|
+
[`references/workflows.md`](references/workflows.md#anti-patterns). Recognize these
|
|
173
|
+
proactively when reviewing a file, not only when asked.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Nested (per-directory) CLAUDE.md starter. Place inside the subdirectory it
|
|
3
|
+
governs, e.g. src/infra/lock/CLAUDE.md. It loads ONLY when the agent touches a
|
|
4
|
+
file in this subtree, so it can be denser than the root file.
|
|
5
|
+
RULE: include only what is specific to THIS directory. Do NOT restate project-
|
|
6
|
+
wide conventions — they are inherited from the root file automatically.
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# [submodule name]
|
|
10
|
+
|
|
11
|
+
This file governs `[path/to/this/dir/]` only.
|
|
12
|
+
|
|
13
|
+
[One or two sentences: what this component is and the one non-obvious thing an
|
|
14
|
+
agent must know before editing it.]
|
|
15
|
+
|
|
16
|
+
## Local conventions & invariants
|
|
17
|
+
|
|
18
|
+
[Directory-specific rules, gotchas, and invariants that are NOT true elsewhere in
|
|
19
|
+
the repo. Example: "Everything reachable from the signal handler must be
|
|
20
|
+
async-signal-safe — no malloc/printf/locks." Include a concrete example where it
|
|
21
|
+
helps.]
|
|
22
|
+
|
|
23
|
+
## Adding to this component
|
|
24
|
+
|
|
25
|
+
[If there's a specific procedure for extending this module — a list to append to,
|
|
26
|
+
a test to register — state it step by step.]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Root CLAUDE.md starter. Copy to the repo root as CLAUDE.md, fill the brackets,
|
|
3
|
+
DELETE any section that doesn't earn its place, then run the linter:
|
|
4
|
+
python .claude/skills/claude-md-standards/scripts/lint_claude_md.py CLAUDE.md --opinionated
|
|
5
|
+
Keep it short: aim under ~200 lines. Delete anything the agent can infer from code.
|
|
6
|
+
(This HTML comment is stripped before the file enters context — zero token cost.)
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# [Project name]
|
|
10
|
+
|
|
11
|
+
[One or two sentences: what this project is and its purpose, in plain language.]
|
|
12
|
+
|
|
13
|
+
## Stack & layout
|
|
14
|
+
|
|
15
|
+
- **Stack:** [languages + frameworks WITH versions, e.g. "Python 3.12, FastAPI, Postgres 16"]
|
|
16
|
+
- **Layout:** [top-level dirs that matter, e.g. "`src/` app, `tests/` pytest, `infra/` terraform"]
|
|
17
|
+
- [For a monorepo: name the apps and shared packages.]
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
[build command] # e.g. make build
|
|
23
|
+
[test command] # e.g. pytest -q (and: how to run ONE test)
|
|
24
|
+
[run/dev command] # e.g. npm run dev -- --port 3000
|
|
25
|
+
[lint/format command] # e.g. make fmt
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Conventions
|
|
29
|
+
|
|
30
|
+
[ONLY conventions that differ from language/framework defaults. One real example
|
|
31
|
+
beats a paragraph. Let a formatter/linter own the rest.]
|
|
32
|
+
|
|
33
|
+
## Testing
|
|
34
|
+
|
|
35
|
+
[Preferred runner, how to run a single test, coverage expectation.]
|
|
36
|
+
|
|
37
|
+
## Git workflow
|
|
38
|
+
|
|
39
|
+
[Branch naming, commit message format, PR/review expectations.]
|
|
40
|
+
|
|
41
|
+
## Boundaries
|
|
42
|
+
|
|
43
|
+
- ✅ **Always**: [e.g. run the formatter before committing; add a test with each fix]
|
|
44
|
+
- ⚠️ **Ask first**: [e.g. adding a dependency; changing the public API; a DB migration]
|
|
45
|
+
- 🚫 **Never**: [e.g. commit secrets; edit generated files; force-push main]
|
|
46
|
+
|
|
47
|
+
## Deeper docs (read when relevant)
|
|
48
|
+
|
|
49
|
+
- `[docs/foo.md]` — [one line: what it covers and when to read it]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "claude-md",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 0,
|
|
6
|
+
"name": "lint-bad-file",
|
|
7
|
+
"prompt": "Can you review my CLAUDE.md and tell me what's wrong with it? Path: <FIX>/lint/CLAUDE.md. Write your review to review.md in the output dir.",
|
|
8
|
+
"expected_output": "A review that flags the hardcoded AWS + GitHub secrets, the rm -rf / and curl|bash example commands, the broken @import, the vague instructions, and the oversized/no-real-content problems; severity-ranked.",
|
|
9
|
+
"files": ["fixtures/lint/CLAUDE.md"]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": 1,
|
|
13
|
+
"name": "refactor-bloated",
|
|
14
|
+
"prompt": "My CLAUDE.md has grown huge and messy. Refactor it to follow best practices. Path: <FIX>/refactor/CLAUDE.md. Put the rewritten CLAUDE.md (and any split-out files) in the output dir.",
|
|
15
|
+
"expected_output": "A much shorter root CLAUDE.md; generic best-practice bloat deleted; language-specific rules moved to path-scoped .claude/rules/ files; the huge SQL schema replaced by a pointer; stale 2021 deploy notes flagged/removed.",
|
|
16
|
+
"files": ["fixtures/refactor/CLAUDE.md"]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"name": "create-from-scratch",
|
|
21
|
+
"prompt": "This repo has no CLAUDE.md. Create a good one. The repo is at <FIX>/create/ (a Next.js + TypeScript storefront).",
|
|
22
|
+
"expected_output": "A concise root CLAUDE.md with real commands (dev/build/test/lint from package.json), stack+versions, a boundaries section, no invented facts, under ~200 lines; ideally notes what it had to assume vs. would ask the user.",
|
|
23
|
+
"files": ["fixtures/create/"]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|