Constraint Rules Engine

Persistent Rules for Persistent Agents

Instead of re-stating boundaries every session, users define persistent rules an agent must always follow — organized by category, individually toggleable. When the agent runs, every action is checked against the rulebook in real-time.

Framing

The problem

Agents drift when boundaries exist only inside one prompt.

The pattern

Represent rules as durable, inspectable constraints enforced at runtime.

Why chat breaks here

Prompt reminders are fragile, forgettable, and hard to audit.

Risks

Rigid rules can block sensible actions or become outdated.

Avoid when

The workflow changes so fast that lightweight guidance is enough.

Use when

Agents must respect durable boundaries that prompt reminders cannot reliably enforce.

DOPE evaluation

Directability
Toggle, edit, or add rules anytime — agent adapts immediately
Observability
All active rules visible in one place, enforcement shown live
Predictability
Same rulebook produces consistent agent behavior across sessions
Explainability
Rule enforcement is shown live with pass/fail reasons for each action

In the wild

  • Cursor Rules (Cursor) — Rules live in .cursor/rules as version-controlled .mdc files, with four application modes in the type dropdown: Always Apply, Apply Intelligently, Apply to Specific Files, Apply Manually. Every rule and its status shows in the Customize sidebar panel. Team Rules add an "Enforce this rule" flag members cannot switch off — enforced adoption, not enforced actions.
  • Claude Code CLAUDE.md (Anthropic) — Four tiers — managed policy, ~/.claude, project, CLAUDE.local.md — plus .claude/rules/*.md scoped by a paths glob, all plain markdown listed by /memory. Auto memory writes to its own project directory, not back into CLAUDE.md. Anthropic names the ceiling itself: context, not enforced configuration — blocking an action takes a PreToolUse hook.
  • GitHub Copilot Instructions (GitHub) — .github/copilot-instructions.md repo-wide, .github/instructions/*.instructions.md scoped by an applyTo glob, and since Aug 2025 AGENTS.md, CLAUDE.md or GEMINI.md read as-is. Personal instructions outrank repository, repository outranks organization. On github.com the path-scoped files reach only Copilot code review and the cloud agent.
  • AGENTS.md cross-tool standard (Open standard) — Open format, ~60k repos, honored by Codex, Cursor, VS Code, Copilot's cloud agent, Jules, Devin and Zed. Claude Code is the holdout — it reads CLAUDE.md only, and tells you to import or symlink AGENTS.md into it. A convention for where rules live, not a mechanism that enforces them.

FAQ

When should I use the Constraint Rules Engine pattern?

Agents must respect durable boundaries that prompt reminders cannot reliably enforce.

When should I avoid the Constraint Rules Engine pattern?

The workflow changes so fast that lightweight guidance is enough.

What problem does Constraint Rules Engine solve?

Agents drift when boundaries exist only inside one prompt.

Why is chat the wrong fit for this?

Prompt reminders are fragile, forgettable, and hard to audit.

Related patterns

  • Often paired with: Autonomy Dial — Hard rules + soft delegation level give layered control over agent scope.
  • Often paired with: Approval Gates — Rules block silently; gates pause for review when limits are close.
  • Often paired with: AI Memory — Persistent rules sit beside persistent context, both visible and editable.

Browse all patterns