Backend Review
Make new complexity prove its necessity. Review production behavior and ownership boundaries rather than maximizing the number of findings.
Operating contract
- Problem: backend review often produces generic risk lists or defensive complexity without proving the real caller, owner, contract, writer, or side-effect boundary.
- Use when: the user requests backend review or a change touches the high-risk production surfaces named in the description.
- Do not use when: the work is mechanical, documentation-only, or test-only without a production-path change.
- Produce: a mode-appropriate decision with admitted findings, ablation of new concepts, targeted verification, and the first meaningful unresolved risk.
Modes
quick: inspect a concrete diff for unnecessary complexity and the smallest safe implementation. Stay read-only.
plan: review an implementation plan before editing. Read references/plan-review.md.
deep: review a completed or nearly completed diff using independent lenses. Read references/deep-review.md.
- No explicit mode: during an authorized high-risk implementation, apply only the compact gate below. Do not silently start a multi-agent review.
Review is read-only unless the user explicitly asks to fix or apply findings. Commit, push, PR publication, external messages, and production changes always require separate authorization.
Resolve the review target
Before judging the work, establish:
- repository, base, head, staged and unstaged changes;
- requested behavior and acceptance criteria;
- applicable repository instructions and public contracts;
- the current owner, valid callers, sibling writers, and direct consumers;
- verification already performed and the first meaningful unverified surface.
Ask one concise question only when an undiscoverable decision would materially change correctness, ownership, public behavior, or risk.
Compact gate
Before implementation
Fix these six facts internally:
- acceptance criterion;
- existing owner and canonical path;
- allowed files and public surfaces;
- out-of-scope work;
- acceptable residual risk;
- a complexity budget for new branches, helpers, types, settings, and flags.
Search the repository before claiming that a pattern, helper, owner, or invariant exists.
After implementation
Inspect the complete branch diff from the real merge base, including staged, unstaged, and relevant untracked files.
For Python changes, run scripts/complexity_inventory.py --base <ref>. Treat its output as candidates, never as findings.
Apply this ablation question to every new concept:
If this code is removed, do the acceptance criteria, repository requirements, invariants, public contracts, valid production paths, and side effects remain unchanged?
Classify each candidate:
keep: required by an acceptance criterion, invariant, trust boundary, or reproduced failure;
narrow: the problem is real but belongs in a smaller owner, type, or call site;
remove: deletion is behaviorally neutral or the branch is speculative;
blocked: a material product or contract decision is missing.
Remove or narrow accepted candidates only when the user authorized changes, then rerun targeted verification.
Cold-read the final diff. Do not report completion while a validated blocking issue or unresolved public-behavior decision remains.
Conditional review surfaces
Open only the references needed by the diff:
- ORM, evaluation, query shape, state writers, or migrations: references/django-orm-review.md
- API, permission, transaction, side effects, or migration risk: references/risk-gates.md
- aggregate authority, snapshots, ledgers, or model boundaries: references/domain-model-review.md
Finding admission
Admit a finding only when it contains:
- the concrete location and production entry path;
- repository, contract, data, test, or runtime evidence;
- likelihood, reach, and impact;
- whether the current change creates or worsens the problem;
- the smallest safe action.
Classify evidence as one of:
observed-production;
normal-path-reproduced;
code-proven-required-invariant;
crafted-only;
hypothetical.
Report only:
P1/P2 fix-required: a consequential defect introduced or worsened by the current change;
decision-required: a product or public-contract choice blocks a correct judgment;
measure: realistic measurement would materially change a performance decision.
Do not surface P3 style preferences, generic hardening, impossible mocks, or speculative edge cases unless the user explicitly asks for every observation.
Output
For quick and the automatic compact gate, use:
Verdict: CLEAN | TRIM | BLOCKED
Scope: <base, head, working tree, and intended outcome>
Findings: <location, evidence, and smallest action, or none>
Ablation: <removed concepts and retained complexity with reasons>
Verification: <performed checks and meaningful gaps>
Use the output contracts in the plan and deep references for those modes. Keep the final answer decision-oriented and omit internal candidate inventories.
1---2name: backend-review3description: Review backend plans and code changes using evidence from the actual repository, callers, contracts, data writers, and runtime boundaries. Use for explicit backend review requests and for changes involving transactions, concurrency, permissions, public APIs, migrations, backfills, multi-model writes, external side effects, or new fallback and compatibility branches. Supports `quick`, `plan`, and `deep` modes. Do not trigger for formatting, imports, localized mechanical edits, documentation-only work, or tests that do not change production behavior.4---56# Backend Review78Make new complexity prove its necessity. Review production behavior and ownership boundaries rather than maximizing the number of findings.910## Operating contract1112- **Problem:** backend review often produces generic risk lists or defensive complexity without proving the real caller, owner, contract, writer, or side-effect boundary.13- **Use when:** the user requests backend review or a change touches the high-risk production surfaces named in the description.14- **Do not use when:** the work is mechanical, documentation-only, or test-only without a production-path change.15- **Produce:** a mode-appropriate decision with admitted findings, ablation of new concepts, targeted verification, and the first meaningful unresolved risk.1617## Modes1819- `quick`: inspect a concrete diff for unnecessary complexity and the smallest safe implementation. Stay read-only.20- `plan`: review an implementation plan before editing. Read [references/plan-review.md](references/plan-review.md).21- `deep`: review a completed or nearly completed diff using independent lenses. Read [references/deep-review.md](references/deep-review.md).22- No explicit mode: during an authorized high-risk implementation, apply only the compact gate below. Do not silently start a multi-agent review.2324Review is read-only unless the user explicitly asks to fix or apply findings. Commit, push, PR publication, external messages, and production changes always require separate authorization.2526## Resolve the review target2728Before judging the work, establish:2930- repository, base, head, staged and unstaged changes;31- requested behavior and acceptance criteria;32- applicable repository instructions and public contracts;33- the current owner, valid callers, sibling writers, and direct consumers;34- verification already performed and the first meaningful unverified surface.3536Ask one concise question only when an undiscoverable decision would materially change correctness, ownership, public behavior, or risk.3738## Compact gate3940### Before implementation4142Fix these six facts internally:43441. acceptance criterion;452. existing owner and canonical path;463. allowed files and public surfaces;474. out-of-scope work;485. acceptable residual risk;496. a complexity budget for new branches, helpers, types, settings, and flags.5051Search the repository before claiming that a pattern, helper, owner, or invariant exists.5253### After implementation54551. Inspect the complete branch diff from the real merge base, including staged, unstaged, and relevant untracked files.562. For Python changes, run `scripts/complexity_inventory.py --base <ref>`. Treat its output as candidates, never as findings.573. Apply this ablation question to every new concept:5859 > If this code is removed, do the acceptance criteria, repository requirements, invariants, public contracts, valid production paths, and side effects remain unchanged?60614. Classify each candidate:62 - `keep`: required by an acceptance criterion, invariant, trust boundary, or reproduced failure;63 - `narrow`: the problem is real but belongs in a smaller owner, type, or call site;64 - `remove`: deletion is behaviorally neutral or the branch is speculative;65 - `blocked`: a material product or contract decision is missing.665. Remove or narrow accepted candidates only when the user authorized changes, then rerun targeted verification.676. Cold-read the final diff. Do not report completion while a validated blocking issue or unresolved public-behavior decision remains.6869## Conditional review surfaces7071Open only the references needed by the diff:7273- ORM, evaluation, query shape, state writers, or migrations: [references/django-orm-review.md](references/django-orm-review.md)74- API, permission, transaction, side effects, or migration risk: [references/risk-gates.md](references/risk-gates.md)75- aggregate authority, snapshots, ledgers, or model boundaries: [references/domain-model-review.md](references/domain-model-review.md)7677## Finding admission7879Admit a finding only when it contains:8081- the concrete location and production entry path;82- repository, contract, data, test, or runtime evidence;83- likelihood, reach, and impact;84- whether the current change creates or worsens the problem;85- the smallest safe action.8687Classify evidence as one of:8889- `observed-production`;90- `normal-path-reproduced`;91- `code-proven-required-invariant`;92- `crafted-only`;93- `hypothetical`.9495Report only:9697- `P1/P2 fix-required`: a consequential defect introduced or worsened by the current change;98- `decision-required`: a product or public-contract choice blocks a correct judgment;99- `measure`: realistic measurement would materially change a performance decision.100101Do not surface P3 style preferences, generic hardening, impossible mocks, or speculative edge cases unless the user explicitly asks for every observation.102103## Output104105For `quick` and the automatic compact gate, use:106107```text108Verdict: CLEAN | TRIM | BLOCKED109Scope: <base, head, working tree, and intended outcome>110Findings: <location, evidence, and smallest action, or none>111Ablation: <removed concepts and retained complexity with reasons>112Verification: <performed checks and meaningful gaps>113```114115Use the output contracts in the plan and deep references for those modes. Keep the final answer decision-oriented and omit internal candidate inventories.