An HR operations team runs an agent that helps managers with onboarding: it drafts offer paperwork, opens accounts, schedules training. Its instructions file is long and careful, and somewhere in the middle of it is the sentence the whole team agrees matters most: never change a compensation field without an approved change ticket. For months nothing goes wrong. Then a manager in a hurry asks the agent to "fix the start salary, the offer letter had a typo", and the agent, reading a direct request from an authorised user against one line among two hundred, edits the field. Nothing was broken. The rule was in the context. It was weighed, and it lost.

Thesis: Law is the set of constraints an agent must obey whatever its direction says. A model does not obey text, it weighs it, so a hard constraint written only as prose is direction with a stern voice. Put each hard constraint where the harness enforces it, in a permission, a check in code or a test every change must pass, and place that check where every writer of the work passes through it, not only the agent you happened to configure. Keep the prose as the explanation of why.


Direction Is Not Law took the first of the four kinds of context on its own: what the work is for, and how a decision ends by supersession. This chapter takes the second, law: what it holds, where it has to live, and who may change it. The HR team, its agent and its ticket are invented for the example; the reuse guard later in the chapter is from this site's own repository.

What Law Holds

Law is the kind of context that holds no matter what the work is for. Three things belong in it.

  • Hard limits. Actions that must never happen: writing to a system of record without approval, sending data outside a boundary, deleting what cannot be restored.
  • Policies. Required ways of working that apply across every objective: every change goes through review, every customer-facing message uses approved wording.
  • Who may instruct. Which sources of text may tell the agent what to do at all. The system prompt and the person running the agent may; a web page, a document or a tool result is data to analyse, never an instruction, however it is worded. No check can read every sentence for intent, so the enforceable part of this law is the reach: what a tool lets text do, whoever wrote the text.

Law has a different writer and a different lifetime from direction. Its writer is the owner of the policy, usually a governance or platform team, not the owner of the work. It lives long and changes only on purpose, through a review, so every version can be named. Four Kinds of Context gives law's failure in one line of its comparison table: "Written as prose, it is weighed like direction and loses." This chapter is about not writing it as prose.

The Model Weighs; the Harness Enforces

Everything in the window is text to the model, and text is evidence, not command. A rule in an instructions file sits beside the user's request, the tool results and the history, and the model resolves them together. Usually the rule wins. Nothing guarantees it.

Claude Code's documentation says so plainly. Of its instruction files it says Claude "treats them as context, not enforced configuration", and that to block an action regardless of what Claude decides, you use a hook that runs before the tool call (memory documentation). Of output styles, which shape every response in a session: "It's an instruction Claude follows, so nothing enforces it" (output styles). Hooks are its documented alternative because they give "deterministic control": the harness runs them at a point in its loop, rather than relying on the model choosing to comply (hooks guide). Hooks Are a Channel, Not a Rule covers what a hook can and cannot do, and the permissions and sandbox beside it.

So law has two layers with different jobs.

Enforced law Advisory law
What it is A check the harness runs A sentence the model reads
Where it lives A permission rule, a tool allowlist, the code behind a tool, a hook, a test every change must pass An instructions file, a rules file, a system prompt
When it is ignored It cannot be: the action is blocked The action happens
Its job Make the constraint true Explain the constraint, so the agent plans around it instead of hitting it
Who changes it The owner of the policy, through review and tests The same owner, in the same review as the check

The prose copy is not useless. An agent that knows why compensation fields are locked will ask for the ticket before it tries the edit, instead of discovering the block. But the prose is the explanation. The check is the law.

Prose Law Fails the Way Direction Does

A hard constraint that lives only as prose inherits every failure of the text around it.

It drowns. The alwaysApply Tax audited one setup with 22 always-on rules totalling about 2,700 lines, loaded into every conversation. The one rule that must never be broken is one of those lines, competing for the model's attention with formatting preferences.

It becomes noise. A sentence repeated on every call carries no information about this call, and Hooks Are a Channel, Not a Rule explains why the model then has every reason to treat it as background. Saying a rule more often does not make it law.

It contradicts other prose. Your Rules Are Fighting Each Other argues that when an AI ignores a rule, two rules probably disagree and it is picking one arbitrarily; its fix is to find conflicts early and declare a winner, the more specific rule over the general. That advice holds for advisory law. For enforced law the conflict is settled by the checks themselves: if one allows a call and another blocks it, the call is blocked.

It does not always travel. In Claude Code, most subagents load the project's instruction files, but each one except a fork runs its own system prompt, and an output style shapes only the main conversation and a fork (subagents documentation). A constraint that lives only in the main agent's system prompt or style reaches a delegated agent only if someone writes it into the brief.

A Check Is Law Only Where It Runs

Moving a rule into the harness is half the work. The other half is putting it where every writer of the work passes through it. A check that only one agent meets is law for that agent and nothing for the rest.

This site had that problem on the day this chapter was written. Notes on which existing diagrams each post should reuse kept getting lost between sessions, and on 16 November, after I had raised it for the third time, a rule went in: every figure brief, the plan an agent writes before drawing a figure, must name the reuse items catalogued for its post, or say "none". The obvious home was a hook in the session plugin I use to keep a record of decisions, which already watches the session. But subagents write the figure briefs, and that plugin's hooks are written to do nothing inside a subagent: each one checks whether its call comes from a subagent and returns early if so. The harness itself would have run them; Claude Code fires settings and plugin hooks for a subagent's tool calls the same way as for the main conversation's (subagents documentation). The gap was in where the check chose to act, and it was exactly where the rule mattered.

So the rule went into the repository as a test. reuses-required, in scripts/figures.test.mjs (pull request #262), fails when a brief has no reuses field, names an item that does not exist or belongs to another post, or gives a malformed value. The pull-request checks run every test on every change, so the rule meets every figure brief whoever wrote it: the main agent, a subagent, another tool, or a person editing by hand. That pull request's own validation removed the field from one brief and watched the test fail. Two limits stay honest. On this repository a red check blocks a merge by practice, not by a rule: main requires a pull request and an approval but not passing checks, and an admin can bypass even that, so the last gate is still a person honouring them. And the test reads the figure briefs only; the briefs for the short guided tours sit outside it, a route the check does not yet cover.

Where the rule sits The main agent A subagent A person editing by hand
A sentence in the instructions file Weighed Weighed, if its instructions load Not reached
A hook that skips subagents Enforced Not reached Not reached
A test every change must pass Enforced Enforced Enforced

The choice is not hook against test. It is the narrowest point that every route to the outcome crosses. For a tool call that is the code behind the tool or a permission rule; for a change to a repository, the checks every change must pass; for a database, the database's own permissions.

Law Is Not Direction, in Either Direction

Direction Is Not Law showed the mistake one way round: a decision treated as law goes rigid and outlives its reversal. The opening of this chapter is the mistake the other way round: law treated as direction is weighed, balanced and sometimes traded away for a good reason.

The two kinds also end differently. A decision ends when the owner of the work supersedes it, often in one sentence of conversation. A law ends when the owner of the policy changes it through review. If an agent finds that its direction requires breaking a law, that is not a judgment call for the agent. It is a conflict between two owners, and the right action is to stop and escalate.

An Enterprise Illustration

Typed properly, the HR agent's compensation rule lives in three places, each with one job, the same split Four Kinds of Context gave its payments ledger.

The check sits in the code behind the agent's update tool: a compensation field accepts a change only with an approved ticket id that the HR system confirms. The agent's permission configuration denies direct writes to that system through any other tool. Those two make the law true, and because the check is in the tool rather than in the agent, any other agent or script that calls the tool meets it too.

The instructions file keeps one sentence: compensation changes need an approved change ticket; if a manager asks for one without a ticket, open the request and tell them it is waiting for approval. That sentence makes the agent useful when it meets the law, instead of failing against it.

The policy's owner, the HR systems lead, owns all three and changes them together. When the policy changes, the check and its test change in the same review, and the sentence follows. No agent and no manager can amend it in conversation.

When the Opposite Wins

Not every rule should be code. Most of what teams call rules are conventions: tone, formatting, naming, which library to prefer. They are direction about style, and enforcing them in checks blocks legitimate work for no gain. A check that fires on a judgment call will be wrong often enough that people learn to route around it, and a law people route around is worse than none.

Checks have costs prose does not. They run on every matching event, they can be wrong, and a broken one can block a session or a release. A check written too broadly blocks the work it was meant to protect; one written too narrowly passes the case that mattered. Claude Code offers hooks that ask a model to judge a condition, "for decisions that require judgment rather than deterministic rules" (hooks guide), but a gate judged by a model inherits the model's fallibility: it is a second opinion, not a law.

The test is the cost of one violation. If a single instance would need an incident report, a refund or a regulator's letter, it belongs in the harness. If it would need a review comment, prose is enough.

What to Do Next

  • List your never-rules. Pull every sentence containing "never", "must not" or "always" from your instructions and rules files. For each, ask what one violation would cost.
  • Move the expensive ones into the harness. Each high-cost rule gets a check in the tool's code, a permission rule, a hook or a test every change must pass, with a test of its own that proves it blocks.
  • Find every route to the outcome. For each check, list who can reach the thing it protects: the main agent, subagents, other tools, people. Move the check until all of them cross it.
  • Keep one sentence of why. Leave a short explanation in the prose so the agent plans around the check. Delete the long restatements.
  • Name one owner per law. The owner changes the check, its test and the sentence in one review. No conversation can amend it.
  • Declare winners for the rest. For the advisory rules that remain, resolve conflicts on paper before the model has to: specific beats general, project beats base.

Next: How an Agent Builds Its Context, how direction, law and the other kinds get into the window call by call, and what is cut when they do not all fit. Related reading: Hooks Are a Channel, Not a Rule for what a hook can and cannot enforce; Permissions Decide What Runs Unasked for the layer that decides what runs without a person; Your Rules Are Fighting Each Other for conflicts between advisory rules; and The alwaysApply Tax for the cost of rules that load everywhere.