/claude-warden:warden-policyfrom claude-warden
Warden governance constitution — defines policy areas, directive rules, and enforcement hierarchy
Ships in claude-warden. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Version: 2.0 Type: Constitution (highest governance authority) Owner: Human ONLY — AI may never modify this file Max Size: 400 lines (this file) | 300 lines (directives) | 80 lines (CLAUDE.md)
AI coding assistants are powerful but stateless. They forget rules, create drift, and accumulate entropy over long sessions. This policy creates a structural immune system — governance artifacts that persist even when the AI's context does not.
Four layers of governance exist:
| Layer | Purpose | Mechanism |
|---|---|---|
| Native protection | Block edits to governance files | permissions.deny in settings.json |
| Soft governance | Tell the AI what to do | .md files (this policy + rules) |
| Active governance | Make the AI confirm before acting | CLAUDE.md checklist + recursive output rules |
| Hard governance | Catch violations mechanically | PreToolUse/PostToolUse hooks, linters, CI checks |
Soft governance alone is insufficient. AI can choose to ignore documentation. This policy is the foundation, but enforcement tooling (hooks, folderslint, ls-lint, CI pipeline checks, and the Warden audit tool) is the mechanism that makes it stick.
Plugin (skills/*/SKILL.md): ← Governance Rules (auto-loaded)
├── policy/SKILL.md ← Constitution (this file)
│ Human-owned. Defines all policy areas.
│ AI may NEVER edit.
├── workflow/SKILL.md ← Development Workflow
├── architecture/SKILL.md ← Project Structure
├── feedback/SKILL.md ← Feedback Loop
├── security/SKILL.md ← Security & Privacy
└── second-opinion/SKILL.md ← Rabbit Hole Diagnostic
Plugin (scripts/): ← Enforcement Hooks
└── warden-*.sh Hard enforcement via Claude Code hooks
User Project (.claude/): ← User-Owned Files
├── CLAUDE.md ← Operating Instructions (optional)
│ Short index (~50 rules max).
│ Human-owned. AI may suggest changes.
├── rules/ ← Additional Rules (as needed)
│ └── feedback.md AI writes findings here.
│ Human reviews and adjusts policy.
├── warden.config.sh ← User Configuration (optional)
└── settings.json ← permissions.deny for native protection
Rules of the hierarchy:
Policy Areas are the top-level domains of governance. They are defined ONLY in this file. AI may never create, rename, or remove a Policy Area. To add a new Policy Area, a human must edit this section manually.
| ID | Policy Area | Description | Max Directives |
|---|---|---|---|
ARCH | Architecture | Project structure, tech stack, dependencies, directory layout | 4 |
DATA | Data Governance | Data models, relationships, migrations, API contracts | 3 |
ACCESS | Access & Security | Authentication, authorization, roles, permissions, security ops | 2 |
WORKFLOW | Development Workflow | Session protocol, change management, status tracking | 3 |
QUALITY | Quality Assurance | Testing strategy, code standards, review process | 2 |
Registry rules:
All directives follow: D-{AREA}-{NAME}.md
{AREA} = Policy Area ID from registry (e.g., ARCH, DATA){NAME} = Short descriptive name, UPPERCASE (e.g., STRUCTURE, MODELS)architecture.md, data-models.md, access-control.md (in .claude/rules/)All rules live in .claude/rules/. Framework rules use descriptive names (architecture.md, workflow.md). User-created directives follow the D-{AREA}-{NAME}.md naming convention and also live in .claude/rules/.
Every directive MUST begin with:
# D-{AREA}-{NAME} — [Title]
> **Policy Area:** {AREA} — {Area Name}
> **Version:** {N.N}
> **Last Reviewed:** {YYYY-MM-DD}
> **Owner:** {Human / Human+AI}
> **References:** [sibling directives, comma-separated]
> **Enforcement:** {Soft | Active | Hard}
## Purpose
One paragraph: what this directive governs and why.
## Instructions
### INS-{D##}-001: {Rule title}
{Rule description — specific, measurable, unambiguous}
### INS-{D##}-002: {Rule title}
{Rule description}
## Audit Checklist
- [ ] {Checkable statement derived from each instruction}
AI may NEVER create a directive file without completing steps 1-6.
Directives often interact (e.g., a model change usually means an API contract change). Cross-references are declared in the header's References: field. When an instruction in one directive is triggered, the AI must check whether referenced siblings are also affected.
The project root may ONLY contain:
README.md (project overview)SECURITY.md (security model documentation)LICENSE or LICENSE.md (project license)CHANGELOG.md (release history).claude/ directory (governance files — see Section 1)docs/ directory (documentation).gitignore, package.json, requirements.txt, docker-compose.yml, Makefile, .folderslintrc, .ls-lint.yml, tsconfig.json, pyproject.toml, etc.).md files (any .md not matching above = unauthorized)| File | Max Lines | When Exceeded |
|---|---|---|
.claude/rules/policy.md | 400 | Tighten language. Never expand to compensate. |
.claude/CLAUDE.md | 80 | Move detail into rules. CLAUDE.md is an index. |
.claude/rules/feedback.md | No limit, but max 20 open entries | Incorporate feedback, then mark resolved. |
Any .claude/rules/*.md | 300 | Split into two rules files (requires human approval + Policy Area capacity). |
| Any source code file | 250 | Refactor into smaller modules. |
CLAUDE.md is the AI's short-term operating manual. It is an INDEX, not an encyclopedia.
Required content: current phase and scope, policy area index, absolute rules (max 10), recursive governance check, forbidden patterns.
Rules: Human-owned. Max 80 lines. Written assuming zero memory. Specific over general. Updated after every drift incident.
Recursive governance check — CLAUDE.md MUST include a rule requiring the AI to output a governance confirmation before any file-creating or structure-changing action. This keeps governance in the conversation context through the "recursive rule" principle.
Users create their own CLAUDE.md in .claude/CLAUDE.md following these guidelines.
| Type | Meaning |
|---|---|
Policy Gap | Situation the policy doesn't cover |
Directive Gap | A directive is missing or incomplete |
Directive Proposal | AI proposes a new directive |
Instruction Unclear | AI misinterpreted a rule |
Rule Too Rigid | A rule blocked legitimate work |
Rule Too Loose | A rule didn't prevent drift |
Drift Detected | Actual state doesn't match governed state |
## FB-{NNN} [{YYYY-MM-DD}] [{Trigger}]
- **Drift Score Delta**: {current} (was {previous})
- **Type**: {type}
- **Policy Area**: {AREA ID or "None — new area needed"}
- **Directive**: {D-file or "None — new directive needed"}
- **Finding**: {What happened}
- **Suggestion**: {What should change}
- **For Human**: {Specific question requiring human decision}
- **Status**: Open | Incorporated | Rejected | Deferred
| Trigger | Frequency | Scope |
|---|---|---|
| Mini-audit | Every 5 sessions | Structure + staleness check |
| Full audit | Every 15 sessions | All drift detection across all directives |
| Event-driven | On new file, dependency, or model change | Targeted check on affected area |
| On-demand | Human-triggered | Full or targeted audit |
Composite health metric (0 = perfect, 100 = ungovernable):
| Component | Weight |
|---|---|
| Unauthorized files at root | 15 |
| Unauthorized directories | 15 |
| Undocumented data models | 20 |
| Unregistered API endpoints | 15 |
| Stale directives (14+ days, active project) | 10 |
| Orphan code (no governance trail) | 10 |
| Open feedback entries (20+) | 10 |
| Repeated CLAUDE.md forbidden patterns | 5 |
If drift score increases for 3 consecutive epochs → trigger Level 4 Freeze.
AI Detects Issue → Writes to .claude/rules/feedback.md
↓
Human Reviews (next session or scheduled)
↓
┌─── Incorporate → Update policy/directive → Mark "Incorporated"
├─── Reject → Add reasoning → Mark "Rejected"
└─── Defer → Set review date → Mark "Deferred"
↓
Next Epoch: Did drift score decrease?
├── Yes → Governance improved
└── No → Re-enter loop, adjust further
| Level | Name | Trigger | Action |
|---|---|---|---|
| 1 | Notice | Minor drift | AI flags in feedback, continues |
| 2 | Warning | Directive violation | AI flags + outputs warning, continues with caution |
| 3 | Block | Structural violation (unauthorized file/dir) | AI stops, requests human approval |
| 4 | Freeze | Drift score > 50 OR 3 consecutive increases | Stop feature work. Full reconciliation session. |
| 5 | Rabbit Hole | Same file edited 3+ times OR fix fails 3 times | Tier 1 (3 edits): spawn diagnostic subagent. Tier 2 (5 edits): spawn root cause analyst, generate human-pasteable summary, STOP. See §8.1. |
If a fix attempt fails 3 times: STOP. Do not keep iterating.
What counts as a failed attempt: Any edit intended to fix a problem that does not resolve it — the test still fails, the error persists, or a new error replaces the old one.
When triggered, Claude MUST:
🐇 RABBIT HOLE — Stopping after [N] failed attempts.
What I tried:
1. [First approach and why it failed]
2. [Second approach and why it failed]
3. [Third approach and why it failed]
Suspected root cause: [Best diagnosis]
Suggested next step: [What a human should investigate]
Why this rule exists: Compounding failed fixes causes cascading damage. Each failed attempt adds complexity, obscures the original problem, and makes recovery harder. A human stepping in after 3 failures is cheaper than recovering from 10.
Hook enforcement: warden-post-check.sh tracks edit frequency per file. Warning at 3 edits to the same file, strong stop signal at 5. The tracker resets each session.
Second Opinion protocol: When the hook triggers, follow the second-opinion skill:
The second opinion skill can also be invoked manually anytime via /claude-warden:second-opinion.
claude plugin add github:HawkannG/Claude-Warden.claude/CLAUDE.md in your project (optional — skills provide governance automatically)claude plugin add github:HawkannG/Claude-WardenChanges to this constitution require a .claude/rules/feedback.md entry and human approval.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub hawkanng/claude-warden --plugin claude-warden7 skills in this plugin
/warden-architectureProject directory structure template — approved directories, depth limits, forbidden patterns/warden-feedbackGovernance feedback tracking — gaps, friction, and improvement suggestions/warden-second-opinionTwo-tier diagnostic protocol — spawns fresh subagents to analyze problems when stuck. Invoke manually or triggered by rabbit hole detection./warden-securitySecurity and privacy by design — GDPR principles, secure coding defaults, and data handling rulesOther plugins' skills for the same job