1---2name: codebase-singularity3description: Apply the codebase singularity approach: reliable codebase understanding and change with a repeatable workflow, guardrails, and verification gates. Use for repo work (feature, bugfix, refactor, migration) when you need high trust, minimal diffs, and explicit validation and exit criteria.4---5
6# Codebase Singularity
7
8## Quick start
91. Collect inputs: repo path, goal, constraints, risk tolerance, and validation commands.
102. Prime: list files, read README, and inspect entry points.
113. Summarize: explain repo shape and where the change belongs; ask questions if ambiguous.
124. Plan: write a short plan with success criteria and validation steps.
135. Change: implement the smallest viable patch; avoid unrelated refactors.
146. Validate: run the requested command(s) or the closest available; record results.
157. Wrap up: report changes, evidence, risks, and next steps.
16
17## Inputs
18- Repo path and task goal.
19- Constraints (files to avoid, time or risk limits, API stability).
20- Validation commands (tests, lint, build, or targeted checks).
21
22## Outputs
23- Short plan with success criteria.
24- Minimal patch.
25- Evidence: commands run and results.
26- Wrap-up: what changed, why, risks, and next steps.
27
28## Grades (maturity ladder)
29
30### Grade 1: Prime only
31- Prime, summarize, and stop on ambiguity.
32
33### Grade 2: Specialized roles + verification
34- Add role prompts (e.g., test_writer, docs_fetcher, reviewer).
35- Require a verification step for each role.
36
37### Grade 3: Tooling expansion
38- Declare required tools or services and expected outputs.
39- Prefer tools over guessing (e.g., query schema instead of inferring).
40
41### Grade 4: Closed-loop autonomy
42- Run cycles: request -> validate -> resolve.
43- Add hard exits: max iterations, evidence of progress, stop after repeated failures.
44
45## Guardrails
46- Keep diffs small.
47- Always validate; if you cannot, say so and propose a safe next step.
48- Ask before broad refactors or scope expansion.
49
50## Templates
51
52### Safe bugfix
53```
54Goal: Fix <bug> with minimal change.
55Constraints: Do not modify public API; avoid touching <paths>.
56Validation: Run `...` and paste output.
57Exit conditions: Stop after 2 failed attempts; summarize hypotheses and logs.
58Deliverables: Patch + explanation + risks.
59```
60
61### Add a feature
62```
63Goal: Add <feature>.
64Constraints: Keep scope to <module>; no new dependencies.
65Validation: Run `...`.
66Deliverables: Patch + tests + short doc update.
67```
68
69## References
70- Read `references/video.md` for a concise source summary.
71- Read `references/transcript.md` for full context.
72- Read `references/visual-notes.md` for a visual outline.