/edikt:gov:compile
Compile accepted ADRs, active invariants, and team guidelines into topic-grouped governance rule files.
The output — .claude/rules/governance.md (index) and .claude/rules/governance/*.md (topic files) — is read by Claude automatically every session. Each topic file contains full-fidelity directives for a specific domain, loaded only when relevant files are being edited.
Usage
/edikt:gov:compile
/edikt:gov:compile --checkArguments
| Argument | Description |
|---|---|
| (none) | Compile and write governance index + topic rule files |
--check | Validate only — report contradictions and conflicts without writing |
How it works
Directive sentinels
Each governance document (ADR, invariant, guideline) can contain an LLM directive sentinel block:
## Directives
[edikt:directives:start]: #
paths:
- "**/adapters/redis/**"
- "**/cache*"
scope:
- implementation
- design
directives:
- Use allkeys-lru eviction policy for all Redis instances (ref: ADR-008)
- Max key size: 1MB. Max TTL: 24h for data caches, 5min for ACL caches (ref: ADR-008)
reminders:
- "Before configuring Redis → MUST use allkeys-lru eviction (ref: ADR-008)"
verification:
- "[ ] Redis eviction policy is allkeys-lru (ref: ADR-008)"
[edikt:directives:end]: #When sentinel blocks exist, compile reads them verbatim — no extraction, no distillation. This is full-fidelity compilation.
Run /edikt:gov:review to generate sentinel blocks for documents that don't have them.
Fallback extraction
If a document has no sentinel block, compile falls back to extracting directives from the human content (the Decision section for ADRs, the Rule section for invariants). This is the v0.1.x behavior — it works but at reduced fidelity.
Topic grouping
Directives from all sources are grouped by topic. All caching rules from different ADRs and guidelines merge into governance/cache.md. All database rules merge into governance/database.md. Each directive keeps its source reference.
Three loading mechanisms
paths:frontmatter — Claude Code auto-loads the topic file when editing matching files. Platform-enforced, no reasoning step.scope:tags — the routing table ingovernance.mdmaps activities (planning, design, review) to topic files. Claude matches its current task.- Signal keywords — the routing table lists domain keywords. Claude matches task context to signals.
Output structure
.claude/rules/
├── governance.md ← index + invariants (always loaded)
├── governance/
│ ├── cache.md ← all caching rules from all sources
│ ├── database.md ← all DB rules from all sources
│ ├── multi-tenancy.md ← all tenancy rules
│ └── architecture.md ← cross-cutting decisionsGovernance index (governance.md)
Contains:
- Non-Negotiable Constraints — invariant directives at the top (primacy bias)
- Routing table — maps signals and scopes to topic files
- Reminders — pre-action interrupts aggregated from all sources: "Before writing SQL -> MUST include tenant_id." Capped at 10.
- Verification Checklist — grep-verifiable self-audit items Claude checks before finishing. Capped at 15.
- Reminder: Non-Negotiable Constraints — invariant directives restated at the bottom (recency bias)
The reminders and checklist are generated by /edikt:invariant:compile and /edikt:adr:compile as reminders: and verification: lists inside each sentinel block. gov:compile aggregates them.
Topic files (governance/*.md)
Each contains:
paths:frontmatter for auto-loading- Full-fidelity directives with source references
- Source attribution comments
Compilation summary
✅ Governance compiled
governance/cache.md
← ADR-008 (§Eviction, §TTL Strategy)
← guideline-database.md (§Caching)
governance/database.md
← ADR-003 (§Queries, §Migrations)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5 ADRs + 2 invariants + 1 guideline
→ 3 topic files + index
→ 27 total directives
Sentinel coverage: 6/8 documents (75%)Contradiction detection
Before writing, the command checks for contradictions:
CONTRADICTION DETECTED
ADR-001: "Claude Code only — no multi-tool support"
ADR-007: "Support Cursor for rule distribution"
Resolve before compiling. Supersede one or reconcile both.Invariant conflicts are errors — invariants always win. ADR conflicts are warnings.
Cross-reference validation
Every directive that references an ADR or invariant (ref: ADR-NNN, ref: INV-NNN) is verified against the actual source file. If the referenced identifier doesn't exist in the source document, the reference is stripped — preventing fabricated cross-references from reaching the compiled output.
This also runs in /edikt:gov:review when generating sentinel blocks.
CI validation
/edikt:gov:compile --checkReports contradictions, conflicts, sentinel coverage, and directive counts without writing any files.
Migration from v0.1.x
If you have an existing flat governance.md from v0.1.x, running /edikt:gov:compile automatically migrates to the new format:
- Detects the old format
- Generates topic files from existing directives
- Replaces the flat file with the new index
- Reports what changed
For best results, run /edikt:gov:review first to generate directive sentinel blocks in your source documents.
When to run
Run after:
- Capturing a new ADR with
/edikt:adr:new - Adding an invariant with
/edikt:invariant:new - Updating a guideline file
- Running
/edikt:gov:reviewto generate or update sentinels
What's next
- /edikt:gov:review — generate directive sentinels and review language quality
- /edikt:adr:new — capture an architecture decision
- /edikt:invariant:new — add a hard constraint