Every agent needs a set of rules—a constitution—to guide its actions. In this lesson, we will explore how files like CLAUDE.md and AGENT.md shape agent behavior, enforce codebase safety, and lock down core packages.
AI models process every word in a prompt using self-attention. Writing polite, conversational sentences like:
wastes valuable tokens, is ambiguous, and weakens the model's compliance. In contrast, **high-density directives** use clear, imperative, and structured formatting:
Structured directives eliminate ambiguity, keep context sizes lean, and establish strict error-handling boundaries.
A standard system constitution (e.g. CLAUDE.md or AGENT.md) resides at the root of your repository. It communicates three critical categories of instructions:
Build command: npm run build, Test command: npm run test).To prevent an AI agent from breaking core dependencies or modifying stable frameworks, write a strict boundary constraint block in your root constitution file:
# AI Agent Constraints ## CRITICAL CODEBOUNDS - NEVER modify files in `src/core/` unless explicitly requested. - DO NOT run npm installs or add new package dependencies without human approval. - Always check that `npm run test` compiles and passes before marking a task complete.
Which of the following describes the most effective approach for system constitutions (like CLAUDE.md)?
Let's build a small rule validator utility in Python! Write a script that checks a system instruction string and raises an error or prints a warning if it does not contain the mandatory strict constraint block CRITICAL CODEBOUNDS.
constitution_text containing rules."CRITICAL CODEBOUNDS" is present."Warning: Missing strict codebounds block!". Otherwise, print "Validation Passed.".Write this constraint scanner script in the workspace editor on the right!