# darkwingtm/claude-code-rules architecture

> Architecture diagram of the GitHub repository darkwingtm/claude-code-rules, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darkwingtm/claude-code-rules
- Repository: https://github.com/darkwingtm/claude-code-rules

## Overview

1. **What this repository is**
   - This is a governed rules/framework repository for Claude Code, not an application backend.
   - Its job is to define assistant behavior through Markdown-based policy, execution, documentation, and validation artifacts.

2. **Primary runtime payload**
   - The live install target is a compact set of **18 active root rule files**.
   - These are copied into a project’s `.claude/rules/` directory and form the runtime behavior surface.
   - The runtime set is intentionally separate from the larger documentation, phase, changelog, and playground surfaces.

3. **Core behavioral layers**
   - The runtime rules are grouped into four main subsystems:
     - **Safety and authority**: authority-and-scope, action-safety, refusal-and-recovery, evidence-discipline
     - **Communication and presentation**: accurate-communication, communication-register, explanation-and-presentation, audience-surface-disclosure-control
     - **Execution and coordination**: coding-discipline, execution-and-goal-frame, worker-routing-and-context, phase-todo-artifact
     - **Governance and context**: document-governance, document-integrity, safe-io, external-verification-and-source-trust, memory-governance-and-session-boundary, portable-implementation-and-hardcoding-control

4. **Source-of-truth hierarchy**
   - `design/*.design.md` defines intended target behavior.
   - Root `*.md` rule files define the active runtime behavior.
   - `changelog/` records versioned synchronization history.
   - `TODO.md`, `phase/`, and `patch/` carry execution state, phased work, and review/change artifacts.
   - This makes the repo a controlled documentation system with clear authority separation.

5. **Install and deployment path**
   - The operator entrypoint is `script/launcher.sh` and `script/launcher.ps1`.
   - The helper installers perform the actual copy/sync work into the target project’s `.claude/rules/`.
   - The install model is launcher-first, project-local by default, and deliberately scoped to Claude Code.

6. **Ownership and cleanup boundary**
   - Cleanup is **manifest/owner-aware**, not filename-wildcard based.
   - The repo removes only its own previously installed runtime files when they still match the recorded install snapshot.
   - Files already present in the destination but not proven to belong to this repo are preserved by default.
   - That boundary is a major architectural constraint: it protects shared `.claude/rules/` folders from collateral deletion.

7. **Lifecycle and documentation topology**
   - `done/` and `history/` folders are used to compact older material out of the active scan path:
     - `changelog/done/`
     - `phase/done/`
     - `phase/history/`
     - `todo/history/`
     - `todo/done/`
   - Active documents stay small and current; completed detail is archived without being treated as junk.
   - There is no default `design/done/` pattern, because design remains the active blueprint authority.

8. **Phase planning subsystem**
   - `phase/SUMMARY.md` is the live index for phased work.
   - `phase/phase-NNN-*.md` and `phase/phase-NNN-NN-*.md` hold major-phase and subphase execution detail.
   - `phase-todo-artifact.md` acts as the startup posture gate that decides whether a phase, TODO, patch, or design companion is needed.
   - This subsystem turns governed design into staged execution rather than ad hoc task notes.

9. **Changelog subsystem**
   - `changelog/changelog.md` is the repository-level synchronization authority.
   - Each active chain has an authoritative parent changelog, with version detail shards stored under nested chain folders when needed.
   - The changelog layer tracks release/version state separately from runtime rules, so history does not become the runtime contract.

10. **Playground subsystem**
   - `playground/` is a governed but **non-runtime** validation and scenario area.
   - It contains cases, coverage mapping, a matrix, and observed examples for behavior exploration.
   - It is explicitly excluded from the `.claude/rules/` install payload.

11. **Operational verification model**
   - The repo emphasizes evidence-first behavior, runtime parity, body sufficiency, and controlled release verification.
   - The architecture is meant to keep claims, docs, runtime files, and install output aligned.
   - GitHub releases and tagged version history are part of the publication/verification story, but the actual operational surface remains the Markdown rule set plus the installer scripts.

Main entry points: [`design/design/runtime-architecture.design.md`](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/runtime-architecture.design.md) (Runtime arch), [`script/setup-claude-code-rules.sh`](https://github.com/darkwingtm/claude-code-rules/blob/master/script/setup-claude-code-rules.sh) (Setup sync), [`design/design.md`](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design.md) (Design specs), [`design/design/verification-and-integration.design.md`](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/verification-and-integration.design.md) (Verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime rules"]
  node_authority_scope["Authority & scope<br/>runtime rule"]
  node_safety_refusal["Safety & refusal<br/>runtime rule<br/>[action-safety.md]"]
  node_evidence_comm["Evidence & comms<br/>runtime rule"]
  node_execution_frame["Execution frame<br/>runtime rule"]
  node_doc_governance["Doc governance<br/>runtime rule"]
end

subgraph group_governance["Governance docs"]
  node_design_blueprint["Design specs<br/>blueprint<br/>[design.md]"]
  node_runtime_arch["Runtime arch<br/>architecture spec"]
  node_installer_arch["Installer arch<br/>installer spec"]
  node_repo_model["Repo model<br/>repository spec"]
  node_verify_integration["Verification"]
  node_changelog_root["Changelog root<br/>version log<br/>[changelog.md]"]
end

subgraph group_execution["Execution state"]
  node_phase_index["Phase index<br/>execution index<br/>[SUMMARY.md]"]
  node_phase_tasks["Phase tasks<br/>execution plan"]
  node_todo_root["TODO<br/>work ledger<br/>[TODO.md]"]
  node_patches["Patches<br/>change artifacts"]
end

subgraph group_validation["Validation area"]
  node_playground_cases["Playground cases<br/>validation scenarios"]
  node_playground_matrix["Coverage matrix<br/>validation map<br/>[matrix.md]"]
  node_playground_obs["Observed examples<br/>observations<br/>[2026-05.md]"]
end

subgraph group_install["Install tooling"]
  node_launcher_sh["Launcher<br/>install script<br/>[launcher.sh]"]
  node_setup_rules["Setup sync<br/>install script"]
end

node_design_blueprint -->|"defines"| node_runtime_arch
node_design_blueprint -->|"defines"| node_installer_arch
node_design_blueprint -->|"defines"| node_repo_model
node_design_blueprint -->|"defines"| node_verify_integration
node_runtime_arch -->|"shapes"| node_authority_scope
node_runtime_arch -->|"shapes"| node_safety_refusal
node_runtime_arch -->|"shapes"| node_evidence_comm
node_runtime_arch -->|"shapes"| node_execution_frame
node_runtime_arch -->|"shapes"| node_doc_governance
node_changelog_root -->|"records"| node_runtime_arch
node_changelog_root -->|"tracks"| node_design_blueprint
node_phase_index -->|"indexes"| node_phase_tasks
node_phase_tasks -->|"feeds"| node_todo_root
node_phase_tasks -->|"produces"| node_patches
node_todo_root -->|"aligns"| node_phase_index
node_playground_matrix -->|"maps"| node_playground_cases
node_playground_cases -->|"captures"| node_playground_obs
node_verify_integration -->|"uses"| node_playground_matrix
node_verify_integration -->|"checks"| node_launcher_sh
node_launcher_sh -->|"delegates"| node_setup_rules
node_setup_rules -->|"installs"| node_authority_scope
node_setup_rules -->|"installs"| node_safety_refusal
node_setup_rules -->|"installs"| node_evidence_comm
node_setup_rules -->|"installs"| node_execution_frame
node_setup_rules -->|"installs"| node_doc_governance
node_installer_arch -->|"specifies"| node_setup_rules
node_repo_model -->|"bounds"| node_phase_index
node_repo_model -->|"excludes"| node_playground_cases
node_verify_integration -->|"audits"| node_changelog_root

click node_authority_scope "https://github.com/darkwingtm/claude-code-rules/blob/master/authority-and-scope.md"
click node_safety_refusal "https://github.com/darkwingtm/claude-code-rules/blob/master/action-safety.md"
click node_evidence_comm "https://github.com/darkwingtm/claude-code-rules/blob/master/evidence-discipline.md"
click node_execution_frame "https://github.com/darkwingtm/claude-code-rules/blob/master/execution-and-goal-frame.md"
click node_doc_governance "https://github.com/darkwingtm/claude-code-rules/blob/master/document-governance.md"
click node_design_blueprint "https://github.com/darkwingtm/claude-code-rules/blob/master/design/design.md"
click node_runtime_arch "https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/runtime-architecture.design.md"
click node_installer_arch "https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/installer-architecture.design.md"
click node_repo_model "https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/repository-model.design.md"
click node_verify_integration "https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/verification-and-integration.design.md"
click node_changelog_root "https://github.com/darkwingtm/claude-code-rules/blob/master/changelog/changelog.md"
click node_phase_index "https://github.com/darkwingtm/claude-code-rules/blob/master/phase/SUMMARY.md"
click node_phase_tasks "https://github.com/darkwingtm/claude-code-rules/blob/master/phase/phase-001-01-create-tactical-strategic-rule.md"
click node_todo_root "https://github.com/darkwingtm/claude-code-rules/blob/master/TODO.md"
click node_patches "https://github.com/darkwingtm/claude-code-rules/blob/master/patch/active-runtime-body-sufficiency-corrective-validation.patch.md"
click node_playground_cases "https://github.com/darkwingtm/claude-code-rules/blob/master/playground/cases/case-01-authority-collision-resolver.md"
click node_playground_matrix "https://github.com/darkwingtm/claude-code-rules/blob/master/playground/matrix.md"
click node_playground_obs "https://github.com/darkwingtm/claude-code-rules/blob/master/playground/observed/2026-05.md"
click node_launcher_sh "https://github.com/darkwingtm/claude-code-rules/blob/master/script/launcher.sh"
click node_setup_rules "https://github.com/darkwingtm/claude-code-rules/blob/master/script/setup-claude-code-rules.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authority_scope,node_safety_refusal,node_evidence_comm,node_execution_frame,node_doc_governance toneBlue
class node_design_blueprint,node_runtime_arch,node_installer_arch,node_repo_model,node_verify_integration,node_changelog_root toneAmber
class node_phase_index,node_phase_tasks,node_todo_root,node_patches toneMint
class node_playground_cases,node_playground_matrix,node_playground_obs toneRose
class node_launcher_sh,node_setup_rules toneIndigo
```

## Components

### Runtime rules

Active Markdown rules that form the installable Claude Code behavior surface.

- [Authority & scope](https://github.com/darkwingtm/claude-code-rules/blob/master/authority-and-scope.md): runtime rule · Defines boundaries, ownership, and who may act on what. · `authority-and-scope.md`
- [Safety & refusal](https://github.com/darkwingtm/claude-code-rules/blob/master/action-safety.md): runtime rule · Covers action safety, refusal, recovery, and safe I/O behavior. · `action-safety.md`
- [Evidence & comms](https://github.com/darkwingtm/claude-code-rules/blob/master/evidence-discipline.md): runtime rule · Controls evidence discipline, communication register, and presentation style. · `evidence-discipline.md`
- [Execution frame](https://github.com/darkwingtm/claude-code-rules/blob/master/execution-and-goal-frame.md): runtime rule · Sets coding discipline, goal framing, and worker routing for active work. · `execution-and-goal-frame.md`
- [Doc governance](https://github.com/darkwingtm/claude-code-rules/blob/master/document-governance.md): runtime rule · Manages document authority, integrity, memory, and portable implementation constraints. · `document-governance.md`

### Governance docs

Design, changelog, and integrity documents that define and track intended behavior.

- [Design specs](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design.md): blueprint · Target-behavior source of truth under design/*.design.md. · `design/design.md`
- [Runtime arch](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/runtime-architecture.design.md): architecture spec · Defines the active runtime rule surface and how it is composed. · `design/design/runtime-architecture.design.md`
- [Installer arch](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/installer-architecture.design.md): installer spec · Defines launcher-first install and sync behavior into project-local Claude Code rules. · `design/design/installer-architecture.design.md`
- [Repo model](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/repository-model.design.md): repository spec · Explains the repository’s layered authority model and content surfaces. · `design/design/repository-model.design.md`
- [Verification](https://github.com/darkwingtm/claude-code-rules/blob/master/design/design/verification-and-integration.design.md): verification spec · Defines parity, evidence, and release verification expectations. · `design/design/verification-and-integration.design.md`
- [Changelog root](https://github.com/darkwingtm/claude-code-rules/blob/master/changelog/changelog.md): version log · Repository-level synchronization authority for versioned behavior changes. · `changelog/changelog.md`

### Execution state

Phase, TODO, and patch artifacts that stage and record governed work.

- [Phase index](https://github.com/darkwingtm/claude-code-rules/blob/master/phase/SUMMARY.md): execution index · Live index of phased work and staged execution paths. · `phase/SUMMARY.md`
- [Phase tasks](https://github.com/darkwingtm/claude-code-rules/blob/master/phase/phase-001-01-create-tactical-strategic-rule.md): execution plan · Major-phase and subphase work items that drive governed changes. · `phase/phase-001-01-create-tactical-strategic-rule.md`
- [TODO](https://github.com/darkwingtm/claude-code-rules/blob/master/TODO.md): work ledger · Current operational task surface and handoff boundary. · `TODO.md`
- [Patches](https://github.com/darkwingtm/claude-code-rules/blob/master/patch/active-runtime-body-sufficiency-corrective-validation.patch.md): change artifacts · Review and change companions that capture concrete edits and transitions. · `patch/active-runtime-body-sufficiency-corrective-validation.patch.md`

### Validation area

Playground scenarios and observed examples used to test behavior.

- [Playground cases](https://github.com/darkwingtm/claude-code-rules/blob/master/playground/cases/case-01-authority-collision-resolver.md): validation scenarios · Governed but non-runtime scenarios for behavior exploration and coverage. · `playground/cases/case-01-authority-collision-resolver.md`
- [Coverage matrix](https://github.com/darkwingtm/claude-code-rules/blob/master/playground/matrix.md): validation map · Maps scenarios, coverage, and observed behavior in the playground. · `playground/matrix.md`
- [Observed examples](https://github.com/darkwingtm/claude-code-rules/blob/master/playground/observed/2026-05.md): observations · Captured scenario observations used to validate rule behavior. · `playground/observed/2026-05.md`

### Install tooling

Launcher and setup scripts that sync the rules into project-local Claude Code paths.

- [Launcher](https://github.com/darkwingtm/claude-code-rules/blob/master/script/launcher.sh): install script · Primary operator entrypoint for syncing rules into a target project. · `script/launcher.sh`
- [Setup sync](https://github.com/darkwingtm/claude-code-rules/blob/master/script/setup-claude-code-rules.sh): install script · Copies and synchronizes the governed rule set into .claude/rules/. · `script/setup-claude-code-rules.sh`

## Connections

- Design specs → Runtime arch: defines · Blueprints the intended runtime rule architecture.
- Design specs → Installer arch: defines · Blueprints the install and sync architecture.
- Design specs → Repo model: defines · Defines the repository’s layered authority model.
- Design specs → Verification: defines · Defines verification and parity expectations.
- Runtime arch → Authority & scope: shapes · Sources the runtime authority boundary rule.
- Runtime arch → Safety & refusal: shapes · Sources safety, refusal, and recovery rules.
- Runtime arch → Evidence & comms: shapes · Sources evidence and presentation rules.
- Runtime arch → Execution frame: shapes · Sources execution and routing rules.
- Runtime arch → Doc governance: shapes · Sources document integrity and memory governance rules.
- Changelog root → Runtime arch: records · Tracks synchronized rule changes and releases.
- Changelog root → Design specs: tracks · Tracks authority changes to design intent.
- Phase index → Phase tasks: indexes · Indexes the live phase work chain.
- Phase tasks → TODO: feeds · Turns phase work into current operational tasks.
- Phase tasks → Patches: produces · Generates change artifacts and review companions.
- TODO → Phase index: aligns · Keeps current work tied to the active phase structure.
- Coverage matrix → Playground cases: maps · Maps coverage onto scenario cases.
- Playground cases → Observed examples: captures · Produces observed behavior examples.
- Verification → Coverage matrix: uses · Uses validation coverage and scenario mapping.
- Verification → Launcher: checks · Verifies install/runtime parity through the launcher path.
- Launcher → Setup sync: delegates · Operator entrypoint delegates to install synchronization helpers.
- Setup sync → Authority & scope: installs · Copies active runtime rules into the project-local rules surface.
- Setup sync → Safety & refusal: installs · Copies active safety and refusal rules.
- Setup sync → Evidence & comms: installs · Copies active communication and evidence rules.
- Setup sync → Execution frame: installs · Copies active execution and routing rules.
- Setup sync → Doc governance: installs · Copies active governance and integrity rules.
- Installer arch → Setup sync: specifies · Defines the helper installer behavior.
- Repo model → Phase index: bounds · Separates active execution state from other documentation surfaces.
- Repo model → Playground cases: excludes · Keeps playground scenarios out of the runtime install payload.
- Verification → Changelog root: audits · Uses changelog state for release and parity checks.
