The constitution: a brief the agent reads before every session
The cheapest thing I did to keep an AI agent coherent, and the one with the most leverage, was write it a constitution: a file called CLAUDE.md at the root of the repo that the agent reads at the start of every session, before it touches any code.
It isn't documentation for humans. It's a standing instruction to a collaborator who arrives each session with full skill and no memory of the last one.
Why an agent needs one
An agent is sharp on the task in front of it and blind to everything around it. Give it a job and it will reach for whatever solves that job — and with no memory of the surrounding decisions, "whatever solves it" can be a network call in the pure combat engine, a random number in a generator that was supposed to be deterministic, or a quiet decision to let the language model settle something that should be settled in code. Each choice is locally reasonable. Each one breaks the project.
The constitution puts the load-bearing decisions in front of the agent at the exact moment it's most likely to violate them: the start of a task.
What goes in, and what stays out
The temptation is to pour everything you know into it, but a long brief is one the agent skims. Ours stays short. Most of it is a numbered list of architecture rules, introduced in plain terms — these are invariants, not preferences, and they are not up for renegotiation on a given task.
The rules are the genuinely structural ones: the engine is pure and deterministic, and never does I/O or calls the model; randomness lives only in generation; the model may propose but never write game state; any mandatory encounter is verified winnable before it ships. Each is a sentence or two, phrased as a boundary rather than a suggestion.
Around them sits only what the agent would otherwise waste a session guessing: the commands to build and test, a short map of where things live, the house style. The test for inclusion is narrow — if getting this wrong breaks an invariant or burns a session, it belongs; if it's nuance, it lives in the deeper design doc (part 3), not here.
The framing carries weight
Calling the rules "invariants, not preferences" reads like a throwaway wording choice. It changes what a violation is.
Without that framing, a questionable change is a judgement call the agent will make on its own — "a network call here is probably fine." With it, the same change has a fixed status: it breaks rule #1, and that's the end of the discussion. A hundred fuzzy design negotiations collapse into rule-checks. The part I didn't expect is that the agent starts catching the violations itself, mid-task, often in its own first draft, because the rule is right there and reads as a line it can see it's about to step over. You stop being the only thing between the agent and architectural drift.
It changes — but out loud
A constitution that can never change becomes a fiction the moment the project outgrows it, so ours is editable. The one condition is that it changes on purpose, in writing, never by being ignored on a single task.
One rule held that meta-progression may only ever unlock options, never permanent power. Later the design wanted persistent equipment carried between runs — the very thing the rule forbade. The wrong move would have been to let the agent quietly bend the rule for that one feature. Instead the rule was rewritten, with the specific conditions that make persistence safe spelled out inside it, so every later task is measured against the amended version. The contract stays honest by being edited with its reasoning attached.
Why it matters
For an afternoon's work, this is the best return I know of: your load-bearing decisions in a short file the agent reads every session, written as rules it can't cross. It won't hold alone — a stated rule is still one an agent can rationalise around when a task really seems to demand it. What makes the rules bite is verification it can't argue with, which is where this series goes next. First, though, the other half of the memory problem: the documents that hold what the constitution deliberately leaves out.