Use when writing or editing CLAUDE.md rules, agent frontmatter, hook prompts, skill procedures, or any text intended to control AI agent behavior. Triggers on "write a rule", "add to CLAUDE.md", "agent instruction", "system prompt", "rule not followed", "agent ignores instruction".
Optimize for: compliance > context efficiency. Both matter; compliance wins ties.
Every effective rule answers exactly three questions:
run_in_background: true not "run in background."If any part is missing, the rule has a hole.
Choose based on the rule's nature:
| When | Format | Why |
|---|---|---|
| Clear, no edge cases | Direct statement | Lowest token cost, highest compliance |
| Ordering matters | Numbered steps |
| Agents derive wrong sequences from principles |
| Context-dependent judgment | Socratic question | Agent applies the question to its situation and derives correct behavior |
Default to principles. Escalate to procedures when you observe agents deriving the wrong sequence from the principle. If the same misordering recurs after one rewrite of the principle, the ordering is inherently non-obvious — encode it as a procedure.
Agent and Bash: always `run_in_background: true`. Never call TaskOutput to block — completion notifications arrive automatically.
One sentence per rule. If it needs two, the second closes a loophole or names the mechanism.
1. Run tests 2. Read output 3. Only then commit
Use only when misordering causes real harm.
Before abstracting: can I point to two call sites that need this? If not, inline it.
Encodes the principle AND the edge cases. The agent reasons about its current context rather than pattern-matching a static rule. Use when the correct behavior depends on circumstances.
run_in_background: true) instead of a description ("run things in the background")? Identifiers are unambiguous and usually shorter.