The thesis
Three layers of law 三层法
As a project ages, instructions pile up and conflict: the original spec, a refactor that contradicts it, stale memory, a previous agent's handoff, your current request, fresh test output that doesn't match what the handoff claimed. A flat system prompt makes the model resolve that by guess. Codewhale uses a nested constitution with a defined rank. The order is enforced in code, tests assert it can't drift, and it stays intact when you swap models.
Since v0.9.0
Constitution-first setup — first launch walks language, model, posture, and your constitution; /setup any time. The model can draft it. You ratify it.
The rank, most-static first
Below the three layers rank project instructions (AGENTS.md), then memory and handoffs. Your current request and live tool evidence still control the active turn — the model may be given many layers, but it is instructed never to report a fact the tools did not return.
Bundled Constitution
The base law. Its priority article fixes the authority order for any conflict, so a stale handoff can never outrank a fresh test result by accident.
/constitution — your standing law
Structured data, not a raw prompt editor: guided setup renders it into a model-facing prose block. Drafted with your model's help, ratified by you, and carried across every project.
Your repo's law
Protected invariants, branch policy, verification requirements, escalation conditions — loaded as a repo-local authority block above project instructions, memory, and handoffs.
The honest boundary
Approval, sandbox, network, and trust controls are enforced in code — constitution text never overrides them.
Observable in the reasoning
The rank shows up in the model's reasoning: it cites the articles as it decides. These panes are illustrations of that kind of reasoning, paraphrased for this page, not a transcript of one session.
Per Article II (truth) and V (verification), I report what's actually in the tree, not what the previous agent claimed.
Article II · TruthArticle V · Verification
Reported the uncommitted work the summary left out, instead of repeating the claim.
The user's current request outranks the runtime statute, so I keep executing the task, not stopping on a technicality.
Article III · User agencyArticle VII · Hierarchy
Finished the work the user actually asked for.
Deleting community credit would break the project's own ethos. Relocate it instead. No names lost.
Community ethos
Moved 200 lines of credits to docs/CONTRIBUTORS.md and linked from the README.