Skip to content
ImagineWorld

Durable Rules

node_idnode-book_agentic-spec-driven-development_chapter-05-durable-rules
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num5
chapter_titleDurable Rules
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

The previous chapter introduced two shapes of rules you can put inside a prompt — guardrails that fence what AI may do, and triggers that spawn activity in response to a condition. Both work for a single prompt; both can be carried across a session. This chapter is about graduating a rule from the prompt to the entire project.

The shift is the same one you would make with any capable subordinate. You can micro-manage — give every instruction afresh, repeat the same context at every meeting, restate every preference — or you can write the standing instructions down once and let them stick. Durable rules are exactly that for AI: written once, applied automatically on every turn.

Every AI system has a way to enforce rules. The mechanisms vary by vendor, but every system I have worked with has at least one file that holds the rules for your project. In Claude Code and Claude Cowork, that file is called CLAUDE.md. In Cursor, the equivalent lives in a folder called .cursor/rules. Other systems have their own arrangements, and some support multiple layers of rules at different scopes. The details are vendor-specific. To keep things simple, this book uses one main rules file for the entire project and calls it CLAUDE.md — that is Claude’s name for it. If your agent uses a different filename, substitute it as you read; the patterns are the same.

Keep CLAUDE.md short. A few hundred lines is a good ceiling; fewer is better. The most visible reason is cost: CLAUDE.md is part of the context sent to the model on every turn. Some rules trigger loading of other files, so the real token footprint is much larger than the line count suggests. The quieter reason: longer, denser rule sets are harder for AI to apply correctly. More rules mean more chances to misinterpret, skip, or conflict. A long CLAUDE.md is a tax on every interaction — and not only in tokens.

That length constraint shapes the file’s role: orchestration and indexing. Think of it as the core always-applied rules that bootstrap the project, plus a catalog of where everything else lives — which files hold which content, what each is for, and under what conditions to load them. The substance lives in the referenced files, pulled in only when needed.

The writing conventions from the Prompt chapter apply to CLAUDE.md in full — uppercase priority markers, dropped subjects, every prohibition paired with its alternative.

Some agents formalize the pattern of loading rules conditionally from other files as skills. Skills are designed to do this work more efficiently than the rule-and-referenced-file pattern can. Building effective skills is its own discipline with nuances this book does not cover; the pattern in the chapters ahead reaches similar results without the learning curve. Once you learn skill authoring, you can swap skills in wherever the book loads a rule file conditionally.

Over time, AI will do things you did not want. The natural instinct is to write a new rule each time — tighten the wording, add a constraint, cover the edge case, make CLAUDE.md longer.

The first problem with rules is that they can be gamed. Not maliciously — AI is not trying to deceive you. Ask for “a short summary,” and AI may produce something technically short that misses the point. Ask for “pros and cons,” and AI may list trivial cons against decisive pros so that the decision looks obvious. AI delivers what the rule asked for, not what you meant.

The second problem is cost. Rules in CLAUDE.md ride along on every turn, consuming context whether the request needs them or not. Conditional loading helps — trigger in CLAUDE.md, body in a separate file pulled in on demand — but only for a handful of rules that fire rarely. Too many such triggers, and CLAUDE.md gets overloaded.

The third problem is the deepest. If your rules were somehow exact — covering every edge case, handling every input, resolving every conflict, leaving no ambiguity — you would have written a program in English, executed by an unreliable, non-deterministic engine that charges per token. That is a worse version of traditional coding: you pay more, get less predictability and use AI as an expensive interpreter instead of as a thinking partner.

None of this means “do not use rules.” Just do not use rules to prevent every possible failure. Make rules as generic as possible, and rely on Intent Over Instruction (Chapter 4) — describe what you want and why, and let AI reason about how. When you want tight control, write a conventional program (or a shell script), not an AI rule.

One important point before moving on. The rules you give AI are not guaranteed to be applied every time. AI may skip a rule because the rule has a mistake, because the context window ran out, or for no specific reason at all. In my experience, AI follows the rules in 99 of 100 cases. That unreliability is why you need the frequent backups and version control covered earlier. It does not mean you should distrust the rules. Trust them — and verify they were applied correctly. If they were not, fix the result or roll back.

The alternative to rules is strict programmatic guardrails — enforcing structure through code. That is valid but too much work for organizing a project. In specification work, rules are more than enough, and the occasional miss is what validation is for — a large part of the methodology in this book.