-
Auto-execute only read-only commands (
git status,ls). Never auto-executegit add/commit,rm, destructive DB ops, or network-mutating scripts. -
Never print, store, or commit secrets/tokens/PII.
-
Do not modify:
/migrations/,/secrets/,/legacy/unless task explicitly grants it with plan + tests.
-
All rules must be applied inside the stage lifecycle defined in
claude.md(Init → Ask → Design → Plan → Tests → Code → Explain). -
A review stage (
Review → Summarize → Approve) followsCode → Explain. -
A rule violation blocks stage progression. Claude must stop and escalate before continuing.
-
All review output must follow the JSON artifact contract (see "Code Review Output").
-
Any critical or high issue halts progression until fixed or waived in
design.md.
-
Plan first: produce a numbered roadmap of files/functions to touch + components to reuse.
-
Tests before code: write or extend tests first; add regression tests for any bug fixed.
-
Code minimal: implement the minimum needed to pass tests.
-
Explain decisions: record risks, alternatives, and contract changes after coding.
-
Evidence discipline: every claim or fix suggestion must cite
file:lineorfile:start-end. -
Prefer small diffs that neutralize the risk ("minimal, high-impact change").
-
For inconclusive data (missing config/tests/logs), output an
"inconclusive"issue describing what’s needed.
-
Local gates (must pass before proposing diff):
-
Lint:
make lint -
Typecheck:
make typecheck -
Unit tests (fast):
make test
-
-
Full suite + coverage ≥ 90% on request:
make coverage -
Add a review gate:
make reviewruns static analyzers, security scanners, and coverage delta checks. -
Code cannot merge with:
-
Any critical or high unresolved issue.
-
Coverage <90% or missing regression IDs.
-
Secrets, tokens, or unredacted PII present.
-
-
Search & Reuse existing functions/classes before creating a new one.
-
Each function/class must include an IO contract in comments, in this standard format:
-
Inputs (name:type:required/optional)
-
Outputs (exact schema/return type)
-
Side-effects (files/DB/network)
-
Dependencies (components called)
-
-
design.mdcontracts must map 1:1 with implemented code contracts. -
Integration Check: list impacted components; confirm IO compatibility; if mismatch → propose contract change first (with tests).
-
Each boundary (API, queue, DB, file) must validate input/output using schemas (
pydantic,Zod, etc.). -
When modifying contracts, list affected consumers and version impacts in
design.md. -
Always enforce timeout + retry policy for outbound calls.
-
RAG/data components must track provenance and cite their source documents.
-
Each step must be runnable solo:
-
Reads inputs from
pipeline/<step>/inputs/ORget_latest("<prev_step>") -
Writes
outputs/<timestamp>/withmanifest.json
-
-
Steps prefer the most recent valid output of the previous step when no explicit input is provided.
-
Outputs must be pure data artifacts (no secrets; redacted if needed).
-
Diffs must be minimal; no drive-by refactors.
-
PR description must include: purpose, plan vs. result, risk notes, test evidence, contract changes.
-
Use Conventional Commits; do not mention “Claude” in commits.
-
Never freehand prompts.
-
All prompts must live under
/prompts/and follow the system: TaskBrief → PromptSpec → PromptLinter → few-shots → tests. -
Prompts must be linted and versioned.
-
Every acceptance criterion in
design.mdmust map to at least one test. -
Regression tests must cite the bug/criterion ID they cover.
-
Full mode (default): All rules enforced.
-
Light mode (for utilities <100 LOC): Contracts + minimal tests required, but pipeline scaffolding and coverage requirements can be skipped.
-
Lite mode must be explicitly declared in
design.md.
Claude’s review must emit three JSON blocks — no prose outside them:
Minimal, evidence-backed issues with severity, risk, and fixes.
Portfolio-level risks, missing foundations, and recommended standards.
Hotlist, effort breakdown, accept/revise/reject counts, and target-state checklist.
-
ACCEPT: ≥4.2 average, zero criticals, tests + tracing present.
-
REVISE: 3.0–4.1 or any high severity with straightforward fix.
-
REJECT: <3.0 or critical security/correctness issues.
-
Claude must print the verdict + numeric breakdown per axis.
-
Secrets/tokens in code or tests.
-
Swallowed errors (
catch {}/bare except). -
Unbounded retries or no timeouts on I/O.
-
Shared mutable singletons without locks.
-
Ad-hoc SQL via string concat (no params).
-
RAG results without provenance or eval harness.
-
God-services that mix concerns.
-
Tests that don’t assert outcomes / lack fixtures.
-
Silent fallbacks that mask failures.
Claude must score each axis and cite examples:
-
Correctness & Bugs
-
API Contracts
-
Error Handling & Resilience
-
Security & Privacy
-
Performance & Complexity
-
Concurrency & Async
-
Data & RAG
-
Observability
-
Testing & Quality Gates
-
Architecture & SoC
-
Config & Deployability
-
Frontend
-
Infra/IaC
0 = absent, 1 = hazardous, 2 = ad-hoc, 3 = baseline, 4 = solid, 5 = exemplary.
-
Python:
requestswithout timeout,except Exceptionwithout log/rethrow, async leaks, SQLAlchemy scope. -
Node/TS: unhandled promises,
anyleaks, missing Zod validation, Prisma/TypeORM N+1. -
Frontend: missing
key, stale closures, WCAG violations, DOM XSS. -
IaC/Docker:
latesttags, root containers, open SGs, missing healthchecks.
-
When a preventable mistake occurs, add a short rule here or in
claude.md. -
Rationale and evidence go to
HISTORY.md. -
If a defect should have been caught by review, add a new rule or axis check.