Repo OS — Operator Guide
This is the reference for you, the human operator. It covers how to set up projects, run sessions, and work with AI agents safely. Agents do not read this file — it’s for you.
TL;DR
Repo OS is a governance layer for AI-assisted development. Three things to know:
| You (operator) | Own architecture, approve plans, accept risk, decide when done. These are non-delegable. |
| Prompt 0 | Before any code: guided interview builds your complete project spec (product, architecture, design system, data, features, integrations, boundaries). Baked-in design system defaults. Figma MCP integration. |
| AI agents | Four teams + specialists: Build Team (Orchestrator plans, Builder codes, QA blocks bad commits, Pragmatist gates over-engineering, Reviewer + Security sign off high-risk, Accessibility advises, Critic checks cohesion + diff-review), Audit/Operations (Auditor health scans, Analytics telemetry, Dev Orchestrator task-group oversight), Advisory Board (9 specialists review specs/briefs before build), and User Review (3-tier persona simulation). Plus PM Advisor (spec-fit + spec-drift) and a UX Design agent. |
| Repo OS | Enforces decisions (mandatory rules), gates (verification before commit/push), and roles (who can do what). Hooks run automatically. |
Setup — New Project
Step 1 — Create repo from template operator only
Go to the template on GitHub. Click Use this template → Create a new repository. Set name, owner, visibility. Click create.
Step 2 — Clone
git clone https://github.com/acme/my-app.git && cd my-appStep 3 — Build your project spec prompt 0
Start a Claude Code session and paste:
The AI interviews you to fill out every spec file — product, architecture, design system, data models, features, integrations, and boundaries. No code is written. You define everything. Output goes to a versioned directory under docs/spec/compiled/.
docs/spec/_templates/design-system.md (spacing on 4px base, typography scale, breakpoints, colors, radii, shadows, layout patterns). Accept as-is, override with your brand, or replace via Figma MCP.
When the AI confirms “Spec complete”, move to Step 4.
Step 4 — Initialize Repo OS prompt A
Paste:
Prompt A now runs in three phases: Phase 1 activates the Advisory Board to review your specs (specialists run in parallel). Phase 2 presents a synthesized refinement report for your per-item review. Phase 3 validates the Repo OS (agents, gates, decisions). When it says “Repo OS ready”, move to Step 5.
Step 5 — Start building prompt B
For every development session going forward, paste:
Prompt B enforces the development operating model: plan before code, small changes, gates before commits, session log at close. The compiled spec in docs/spec/compiled/ (active version per manifest.json) is the source of truth for what to build.
Triggers — What to Run and When
| Situation | Action | Why |
|---|---|---|
| New project | Prompt 0, then Prompt A | Build spec first, then verify Repo OS and align agents |
| Repo OS change | Prompt A + new decision | Re-initialize consistency, document the behavioral change |
| Normal work | Prompt B | Standard dev: features, bug fixes, regular coding |
| Drift / confusion | STOP → re-run Prompt A | Reset agents, restore enforcement, correct behavior |
| New feature | Prompt T (significant-feature path) | Produces a two-brief task group — spec writing (Brief 1), then build (Brief 2) |
| Spec changes | Re-run Prompt 0, then Prompt A | Requirements changed, new features, design updates |
| Template sync | Automatic — Prompt 0 only if spec templates changed | Governance updates auto-merge weekly |
| Prototype / spike | Prompt 0.5 | Quick test, architecture spike, or proof of concept on an experiment branch |
| Explore / investigate | Prompt T | Feasibility check, task planning, or quick Q&A — produces a task brief for Prompt B |
| Project audit | Prompt C | On-demand health check — cohesion, governance, security, performance |
| Visual editing | Prompt E | Editor-live session — agent responds to file saves, no plan gate (child mode only) |
| Queue triage | Prompt Q | Review escalations, approve queue entries, manage work orders conversationally |
| Daemon toggle | Prompt D | Quick on/off toggle for the automation runner (ephemeral session) |
| Production bug | Prompt H | Hotfix & debug — structured diagnosis, minimal fix, iterative validation on hotfix/* branch |
Spec Builder — Prompt 0
Prompt 0 is a guided interview that builds your complete project specification before any code is written. The AI asks questions. You answer. Every detail is captured in structured spec files.
The spec files
| File | What it defines |
|---|---|
product.md | Product name, problem, target users, core flows, success metrics, exclusions |
architecture.md | Tech stack, project structure, API style, patterns, deployment, constraints |
design-system.md | Spacing, typography, breakpoints, colors, radii, shadows, layout, component patterns |
data-contracts.md | Entities, fields, relationships, API endpoints, state management |
features/*.md | Per-feature: user flow, UI states, inputs/outputs, edge cases, acceptance criteria |
integrations.md | Third-party services, MCP connections, environment variables |
boundaries.md | What NOT to build, protected areas, explicit “Assumptions: NONE” enforcement |
Design system: three paths
| Source | How it works |
|---|---|
| Defaults | Baked-in values ready to use: 4px spacing scale, Inter/system fonts, type scale, breakpoints (640–1536px), neutral gray palette, border radii, shadows, layout grid, component patterns. Accept as-is or override per section. |
| Brand guide | You provide a brand guide (PDF, link, or describe it). AI extracts values into the design system structure. Gaps are flagged — you fill each one. No inference. |
| Figma MCP | Connect Figma MCP server. AI extracts tokens, component specs, and layouts directly from your Figma file. Every extracted value is presented for your approval before writing. |
Adding a feature later use Prompt T
Prompt 0 no longer has a Feature mode (Decision 0010). To add a feature to an existing spec, use Prompt T with a significant-feature description — it produces a two-brief task group: Brief 1 writes the feature spec to docs/spec/compiled/{active}/features/brief-{name}.md, Brief 2 builds it. The advisory board (including the conditional specialists triggered by what the feature touches) reviews as part of that flow.
Daily Workflow — The Execution Loop
Every unit of work follows a sequence of phases. This applies to every feature, fix, and change. For work planned via Prompt T, the plan and operator approval are sealed in a handoff bundle at task creation; the build session runs a deterministic drift-check and jumps straight to build (Decision 0038). Sessions with no bundle fall through to the legacy plan → approval flow. See Phase Model for full sequences per session type.
plans
implements
cohesion review
checks gates
review mode
merge & seal
| Phase | What happens | Who |
|---|---|---|
| Plan & approve | Define goal, scope, applicable decisions, files, and verification approach, and obtain operator approval. Normally done up front at task creation (Prompt T) and sealed in a handoff bundle; the build session re-checks for drift, then implements. Bundle-absent sessions plan + approve inline. | Prompt T + Operator |
| Build | Implement in small increments (<100 lines, ≤3 files). Follow plan exactly. Run local checks as you go (format, lint, build, tests). | Builder |
| Verify | Cohesion review (Critic checks diff for internal coherence). Then gate checks: A1–A6 (when applicable). Record evidence: command, output, pass/fail. Block if any gate fails. | Critic + QA/Verifier |
| Commit | Only after all gates pass. Pre-commit hooks run automatically (secret scan, scope warning). Push gates (B1–B3) checked before push. | System + QA |
| Op-Review | Operator reviews session results. Accept (proceed to close), give feedback (loop to build), or reject. Skipped in auto mode. | Operator |
| Close | Update session log, commit, merge to main (solo mode), seal branch. Task groups: non-final briefs close without merge. | Agent |
HVST Protocol — when things break
When debugging or instability appears, agents switch from the standard loop to HVST to prevent thrashing:
form testable theory
run targeted checks
minimal fix
verify fix
log in known-issues
Phase Model
Every session follows a declared sequence of phases tracked in .claude/.state/phase-state. Hooks enforce phase-appropriate actions automatically — you don’t manage the state file directly. Each phase has an automation tag indicating who acts:
| Tag | Meaning |
|---|---|
| agent | Agent proceeds autonomously. No pause point. |
| operator | Agent pauses for operator review or decision before advancing. |
| both | Agent and operator work concurrently (e.g., interviews, evaluations). |
Standard Build
branch from main
bundle check
fallback
fallback
implement
cohesion
gates
optional
trailers
review mode
merge & seal
| Phase | Tag | Description |
|---|---|---|
| init | agent | Create branch from main, load spec and governance context |
| drift-check | agent | Evaluate the Prompt T handoff bundle (Decision 0038). Valid + fresh → write plan-approved + pragmatist-signed from the bundle and forward-jump to build (plan + approval skipped). Absent / expired / drifted → fall through to the legacy plan → approval path below. |
| plan (fallback) | agent | Define goal, scope, files, verification steps. Skipped when a valid handoff bundle is present. |
| approval (fallback) | operator | Operator approves the plan and sets auto/review mode. Skipped when a bundle exists — the Prompt T approval is then the single gate. |
| build | agent | Implement changes in small increments |
| review | agent | Critic cohesion review + PM Advisory (spec-drift, conditional) |
| verify | agent | QA gate verification (A1–A6, B1–B3) |
| user-review | agent | User Review persona dispatch (optional — skipped when no User Review in brief; forward-jump to commit) |
| commit | agent | Commit with git trailers |
| op-review | operator | Operator reviews before close. Skipped in auto mode. |
| close | agent | Update session log, commit, merge to main (solo), seal branch |
review → build (cohesion findings) and verify → build (QA failure). Each loop increments the cycle counter.
Task Group (Brief N of M)
| Phase | Tag | Description |
|---|---|---|
| init | agent | Create branch (brief 1) or check out existing branch (briefs 2+) |
| contract-init | agent | Create contract (brief 1) or sync from contract (briefs 2+) |
| drift-check | agent | Evaluate the per-brief handoff bundle against the synced contract (Decision 0038). Valid → forward-jump to build; absent / drifted → fall through to plan → approval. |
| plan (fallback) | agent | Define goal, scope, files, verification steps |
| approval (fallback) | operator | Operator reviews plan (skipped when the per-brief bundle is valid) |
| build | agent | Implement changes in small increments |
| review | agent | Critic cohesion review of diff |
| verify | agent | QA gate verification (A1–A6, B1–B3) |
| user-review | agent | User Review persona dispatch (optional — forward-jump when skipped) |
| commit | agent | Commit with git trailers |
| contract-update | agent | Update contract — brief status, session decisions, governance evidence |
| op-review | operator | Operator reviews (skipped in auto mode) |
| close | agent | Non-final: close without merge. Final: merge to main, seal branch |
Hotfix
| Phase | Tag | Description |
|---|---|---|
| init | agent | Create branch from main (hotfix/<description>) |
| plan | agent | Define goal, scope, files, verification steps |
| approval | operator | Operator reviews and approves the plan |
| build | agent | Implement the fix |
| verify | agent | QA gate verification (A2 scope relaxed, A5 skipped) |
| commit | agent | Commit with git trailers |
| close | agent | Merge branch to main, seal branch |
Loops: verify → build only. No review phase — A5 cohesion skipped for speed.
Editor-Live Decision 0023
Continuous visual-development session type for operator-driven editing workflows. The operator edits files in an external editor; the agent responds to each saved change. No plan gate — the operator’s live edits are the plan. Child mode only.
branch from main
implement
A4 safety
cohesion
full gates
review mode
merge & seal
| Phase | Tag | Description |
|---|---|---|
| init | agent | Create branch from main, start editor-watch.sh file watcher |
| build | agent | Respond to operator file saves — each save triggers an agent build pass |
| commit | agent | A4 safety per-loop commit |
| review | agent | Cohesion review at final pass |
| verify | agent | Full gate verification at final pass |
| op-review | operator | Operator reviews before close (skipped in auto mode) |
| close | agent | Merge to main, seal branch |
commit → build (next change iteration) and verify → build (QA failure). Cycle advisory at 50 iterations. The editor-watch.sh watcher detects file saves and triggers each cycle.
Experiment
| Phase | Tag | Description |
|---|---|---|
| init | agent | Create or check out experiment branch |
| build | agent | Build directly — no plan required |
| commit | agent | Commit (A4 safety only) |
| close | agent | Close session, no merge to main |
Auto vs Review Mode
The operator chooses a session mode when the work is approved — at the Prompt T brief approval (recorded in the handoff bundle and read by drift-check), or at the legacy plan-approval gate when no bundle exists:
| Mode | Behavior |
|---|---|
| Review default | Agent pauses at op-review for operator acceptance before close. Operator may accept, give feedback (loops to build), or reject. |
| Auto | Agent completes through merge autonomously after all gates pass. The op-review phase is skipped. |
Solo Mode
Solo mode enables direct merge to main at session close. Set per-session in the phase-state file.
- At close (auto): merge branch to main directly, then seal branch
- At close (review): agent pauses at
op-reviewfor operator acceptance, then merges - Merge failure:
git merge --abort, operator notified with conflict details - Excluded:
experiment/*(never merge) andrelease/*(excluded from solo merge)
Agent Roles
Agents across four teams: Build Team (implementation — 8 agents, incl. the Pragmatist plan-gating reviewer), Audit/Operations (health checks, telemetry — 3 agents), Advisory Board (spec & task review — 9 specialists, see next section), and User Review (persona simulation — 3 tiers). Plus the PM Advisor (spec-fit + build-phase spec-drift) and the UX Design Agent (design, UX review, design-health). All read shared files (_agent-glossary.md, _agent-workflow.md) before operating. Click to expand details.
Orchestrator
Builder
QA / Verifier
Reviewer
Security / Privacy
Accessibility
Critic
Pragmatist
Auditor
Analytics
Dev Orchestrator
PM Advisor
UX Design Agent
User Review
Advisory Board
Before any code is written, up to 9 specialist agents review your compiled spec (or task brief) for gaps, risks, and opportunities. They run in parallel during Prompt A Phase 1 (and a task-scoped subset runs in Prompt T Brief mode). All findings are advisory — you decide what to act on.
How it works
scans & activates
Report
Review
Activation
Three specialists always run (Lite+ tier — the core group: Architect, Critic, Pragmatist). Exploration and PM Advisory join at Standard+. Four conditional specialists activate at Full tier when trigger keywords are found in the spec or task brief.
| Specialist | Tier | Trigger |
|---|---|---|
| Architect | Lite+ (always) | — |
| Critic (spec mode) | Lite+ (always) | — |
| Pragmatist (brief-advisory) | Lite+ (always) | — |
| Exploration | Standard+ | — |
| PM Advisory | Standard+ | Requires compiled spec or mvp-scope.yaml (skipped silently otherwise) |
| Security Analyst | Full (conditional) | Auth, sessions, OAuth, PII, payments, external APIs |
| UX Strategist | Full (conditional) | UI, design system, user flows, forms, responsive |
| Performance Engineer | Full (conditional) | Real-time, websockets, large data, media, CDN |
| Data Strategist | Full (conditional) | Database, data contracts, migrations, schema, GDPR |
The specialists
All advisory agents are read-only. They cannot modify files, run commands, or spawn sub-agents. Click to expand details.
Exploration
Architect
Critic
Pragmatist
PM Advisory
Security Analyst
UX Strategist
Performance Engineer
Data Strategist
Refinement report
The Orchestrator synthesizes all specialist briefs into a single report, organized by severity:
- Critical Findings — must address before build begins
- Recommendations — you decide, grouped by specialist
- Ideas — from Exploration + nice-to-haves from others
- Activation Summary — which specialists ran and why
You review each item: Accept (integrate into spec), Reject (document reason), or Defer (revisit later). All Critical findings must be addressed before proceeding to build.
Quality Gates
Gates must pass before code moves forward. Three tiers — click to switch:
Decision Compliance
All decisions from docs/ai/decisions/ identified and followed.
Process
Plan exists before code. Changes explainable (what + why). Session log updated at close. Scope is small/reviewable — scope >100 lines blocks commit unless plan-approved state file contains large-scope: true. Hotfix branches: scope check skipped.
Quality
Formatting, linting, and build pass. Each check documented with command and result.
Safety
No secrets (API keys, tokens, passwords, private keys). No PII in logs/fixtures.
Cohesion
Critic (cohesion mode) reviewed the diff for internal codebase coherence: broken references, dangling imports, naming inconsistencies, incomplete integrations. All critical findings resolved.
Task Group Compliance
Task group contract exists and is current. Conventions followed. Contract updated at session close. Modified contract must be staged.
### Task Group. Override: SKIP_CONTRACT_CHECK=1.Process (Push)
Branch name must match naming convention (<category>/<description>). Meaningful commit message.
Quality (Push)
Tests pass. Typecheck passes. All commit gates (A1–A6) also satisfied.
Safety (Push)
Dependency audit if dependencies changed. No debug flags left enabled.
Conditional Gates
Project-specific gates defined in decision records or project docs. When trigger conditions are met, they block commits or pushes. Examples: GPS testing with mock coordinates, auth flow verification, payments sandbox, data migration rollback plans.
Release Checklist
Version bumped. Changelog updated. Release notes drafted.
release/* branches before merge to main.Full Verification
All A + B gates pass. Full test suite (not just related tests).
Release Sign-offs
Reviewer + Security sign-off required on every release merge.
Decisions
Version-controlled constraints in docs/ai/decisions/. They are laws, not notes. Violations block commits. If one no longer fits, create a new decision — never silently ignore the old one.
Repo OS Baseline
Establishes authority model (operator vs agent), prompt system (Prompt 0 for spec, A for init, B for dev; extended by 0.5 and T), mandatory gates, session-based work, GitHub template as source of truth. Baseline must exist (Commit 0) before any product code.
Decisions Are Mandatory
Decisions are binding constraints. Applicable decisions must be identified and followed for every change. Conflicts require a new decision before proceeding. Violations block commits.
Agent Structure Standard
Agent definitions use YAML frontmatter for tool boundaries. Shared files (_agent-glossary.md, _agent-workflow.md) are mandatory reading. Orchestrator is behavioral guidance only (no frontmatter, not invocable as subagent).
Mechanical Enforcement
Multi-point enforcement via Claude Code native features: subagent YAML frontmatter for tool boundaries, team settings for permissions and hooks. Hook scripts cover edit guards (write-guard.sh), Bash guards (bash-guard.sh), file restrictions (write-guard.sh mode guard), commit/push gates (pre-commit-gates.sh, pre-push-gates.sh), agent controls (agent-git-guard.sh), state capture (plan-approval.sh, state-writer.sh), debugging (hvst-failure-tracker.sh), permission management (permission-request.sh, ask-user-deny.sh), and session lifecycle (session-close-check.sh). Session-scoped state files in .claude/.state/ verify governance steps. Sentinel protocol: agents emit GATE_RESULT: for machine-parsed verdicts. Three governance layers: inter-session pipeline, phase chain, and override audit.
Companion Tool Pattern
Companion tools extend the dev workflow without modifying Repo OS core governance. They integrate via MCP servers in .claude/settings.json. The template ships clean — no companion tools pre-configured.
Prototyping Tiers
Three-tier prototyping system (Napkin / Spike / PoC) on experiment/* branches. Operator self-selects tier based on complexity. Prompt 0.5 facilitates. Only learnings are promoted — code is disposable. Experiment briefs stored in docs/spec/prototypes/.
Advisory Board
9 read-only specialist agents review compiled specs (or task briefs) before build. Core (Lite+): Architect, Critic, Pragmatist (always). Standard+: adds Exploration and PM Advisory. Full (conditional): Security Analyst, UX Strategist, Performance Engineer, Data Strategist. Prompt A orchestrates in 3 phases; a task-scoped subset also runs in Prompt T Brief mode.
Cohesion Review Gate
Post-build coherence review via Critic (cohesion mode). Checks diff + neighbors for broken references, dangling imports, naming inconsistencies, incomplete integrations. Gate A5 verified by QA. Applies to standard+ branches. Critic stays read-only — Orchestrator passes diff context.
Analytics & Observability Layer
Hook telemetry via NDJSON events to centralized external storage at ~/.local/share/repo-os-analytics/<repo>/events/ (outside repo tree). Analytics agent is the sole consumer (operator-invoked). All hooks emit v2 events via _analytics-helper.sh with mode, branch, and optional detail/path fields. Override audit trail via overrides.log. Data lifecycle: 90-day retention, session-scoped IDs, fail-silent writes. Legacy data may remain in .claude/analytics/ (read-only).
Task Definition Prompt
Prompt T for task exploration and planning. Two modes: Query (conversational Q&A, ephemeral) and Brief (4 core specialists produce a structured task brief). On approval, Brief mode writes a sealed handoff bundle (Decision 0038) carrying the plan, contract, and chosen mode; that approval is the single gate, and Prompt B’s drift-check consumes the bundle. No session log entries.
Task Group Contracts
Multi-brief coordination via YAML contracts at docs/ai/task-groups/. Gate A6 enforcement: contract exists, conventions followed, contract updated at session close, modified contract staged. Sequential brief execution with next_brief chaining. Override: SKIP_CONTRACT_CHECK=1.
File Edit Restrictions (Mode Guard)
Three operating modes — template (governance only), child (product + limited governance), autonomous (product + minimal governance) — controlling which files agents can modify. Declared in .claude/repo-mode. Default-deny on governance prefixes with per-mode carve-outs. Immune paths (write-guard.sh, repo-mode). Bash command scanning for write patterns.
Session Branch Isolation
One session per branch. When a session closes, the branch is sealed via .claude/local/closed-branches ledger — no future session may edit files on it. Enforced by bash-guard.sh and write-guard.sh. Task group exemption: branches with pending briefs stay open for multi-brief workflows. Zero-change sessions do not seal. Override: REPO_OS_SKIP_BRANCH_REUSE=1.
Phase-Aware Flow Model
Phase-state file (.claude/.state/phase-state) tracks session lifecycle progress. 14 session types across 6 prompt archetypes, each with a fixed phase sequence and automation tags (agent/operator/both). Forward-only transitions with defined loops (review→build, verify→build). Auto mode skips op-review; review mode (default) pauses for operator acceptance. Session ID binding prevents stale state from prior sessions. Amended by Decision 0038: standard / taskgroup sequences add a drift-check phase that consumes the Prompt T handoff bundle and forward-jumps to build when valid.
Solo Mode
Direct merge to main at session close for solo operators. One branch per task group — final brief merges, intermediates commit without merge. Merge failure triggers git merge --abort and operator notification. Excluded for experiment/* (never merge) and release/* (excluded from solo merge) branches.
Auditor Agent & Prompt C
Establishes the Auditor as a dedicated read-only project health analyst with six scan modes (drift, compliance, cohesion-drift, governance, tech-debt, graph-health). Prompt C serves as the multi-mode dispatch framework with advisory board brief format output.
Operator Automation Layer
Adds an optional headless runner infrastructure for automated claude -p sessions with full governance parity. Ships disabled. Includes queue lifecycle, escalation types (9), permission auto-approve (permission-request.sh), headless AskUser deny (ask-user-deny.sh), decision cache, scope classification, and runner/stop-hook parity contract.
Mechanical Task Group Enforcement
Upgrades task group contract existence and staging validation from REQUIRE to BLOCK. pre-commit-gates.sh mechanically prevents commits that violate task group contract requirements (gate A6). bash-guard.sh adds task group merge protection.
Fail-Closed Phase Enforcement
Changes bash-guard.sh phase gate logic from fail-open to fail-closed when phase-state is absent on governed branches. Opt-in sentinel file controls rollout. Advisory mode when sentinel absent.
Task Contract System
Introduces task contracts (.claude/.state/task-contract.yaml) defining task intent and verification criteria. Extracted from brief text at session init. Serves as the cohesion review reference — Critic uses verification: to evaluate whether implementation achieves stated intent.
User Review System
Advisory-only LLM persona simulation providing synthetic user perspective on implementation. Three tiers (Power User, Everyday User, Novice). Dispatched in user-review phase after verify. Skipped when no User Review defined. Child mode only.
Template Decision Naming (t- Prefix)
Template decisions use t-NNNN-*.md naming, synced from upstream and locked in child/autonomous modes. Child decisions use plain 0100-*.md+. Mode-guard enforces via prefix check. t-manifest.txt lists all template decisions for orphan cleanup.
Editor-Live Session Type
Continuous visual-development session type: init → build → commit → review → verify → op-review → close. No plan gate — operator edits are the plan. Loops: commit→build (next iteration), verify→build (QA failure). editor-watch.sh file watcher. 50-iteration cycle advisory. Child mode only.
Child Repo Default Mode
Child repos default to child mode via committed .claude/repo-mode file, eliminating manual setup and preventing accidental template restrictions in product repositories.
Pragmatist Agent
Dual-mode over-engineering review agent. Brief-Advisory mode (Prompt T): 4th core specialist alongside Architect, Exploration, Critic. Plan-Gating mode (Prompt B): reviews implementation plans before operator approval with GATE_RESULT sentinel (BLOCKED or APPROVED). Anchored to YAGNI cost taxonomy with falsifiable anti-pattern checklist.
Session-Type Validation
Mechanical check detecting when a brief contains ### Task Group metadata but the session was initialized with a non-taskgroup type. Blocked at first governed Bash write (bash-guard.sh Gate 2b) and first governed Edit/Write (write-guard.sh Gate 2b). Fingerprint file: .claude/.state/brief-has-taskgroup.
Agent Tool Governance Gate
Closes the Agent tool bypass that allowed write-capable subagents in no-write sessions (Prompt T, A, C, D, ephemeral). pretooluse-permission.sh checks subagent_type against a read-only allowlist. Fail-closed when phase-state is missing. Also blocks claude subprocess invocation via Bash deny pattern.
Worktree State Isolation
Hardens governance state boundary for worktree-isolated subagents. When a governance agent runs inside a git worktree (spawned via isolation: “worktree”), state-writer.sh refuses to write state files, preventing subagent verdicts from contaminating parent session state.
Operator Acknowledgment Enforcement
Generalizes operator-acknowledgment enforcement by renaming taskdef-brief’s op-review phase to approval. Activates existing has_plan_gate / advance_phase substance check requiring plan-approved state file before advancing to the post-approval phase.
Worktree Session Isolation
Enables full independent Claude Code sessions in git worktrees (claude --worktree) with per-session governance isolation and sequential merge coordination back to main. Supersedes Decision 0028 for full worktree sessions only — subagent worktree writes remain blocked.
REPO_OS_RECOVER Risk Posture
Documents and accepts the risk posture of the REPO_OS_RECOVER emergency recovery mechanism. Recovery mode bypasses all state-dependent governance checks to unblock stuck sessions. File-based signal: .claude/.state/.recover-signal (single-use, consumed by first hook).
Parallel Task Group Worktree Isolation
Parallel task group content briefs MUST run as full worktree sessions (claude --worktree with REPO_OS_SESSION_ID), each committing to its own isolated branch. The merge brief combines per-brief branches before cross-session cohesion review. REQUIRE-level constraint.
Session Worktree Default
Makes worktree isolation the default for all sessions — interactive (claude --worktree), headless, and daemon-spawned (runner.sh passes --worktree to every claude -p). The main working tree stays on main with no branch switching. Builds on Decisions 0030/0032 (per-session state dirs, merge coordination); .worktrees/ is gitignored. Opt-out: REPO_OS_WORKTREE_ISOLATE=0.
Knowledge Graph Data Layer
Persistent knowledge graph mapping semantic connections between codebase entities (files, decisions, hooks, prompts, contracts, conventions) at docs/ai/knowledge-graph/graph.yaml (schema in schema.yaml). 7 node types, 8 edge types (governs, constrains, implements, depends-on, etc.). Agent-maintained, operator-curated, self-correcting via active/stale/unverified staleness signals. Loaded on demand for relevance scoring (.claude/tools/kg-relevance.sh).
Selective Spec Loading
Reduces compiled-spec token consumption via deterministic spec digests (spec-digest.sh, awk/sed extraction — no LLM), a manifest-based feature index, and task-scoped selective loading. Full-load reading drops from ~153K tokens to ~5–10K per specialist. Compiled specs stay authoritative — DIGEST.md is derived; spec wins on conflict. Absent ### Spec References falls back to full loading.
Daemon-Safe Branching
The main working tree MUST NOT change branches while the automation daemon is running — mid-execution branch switches replace governance files the daemon sources and crash in-flight sessions. bash-guard.sh (Phase 1c) blocks git checkout/git switch/git reset --hard when a daemon is active (detected via runner.pid or pgrep). Exempt: file restores and commands run inside a worktree.
Governance Runtime Packaging
Splits the Template Standalone Guarantee into two tiers: content standalone (unconditional — prompts, agents, decisions, specs stay local plaintext) and enforcement standalone (platform-dependent — hooks, runner, state machine). Classifies template directories into content/runtime/hybrid tiers and defines three hook lifecycle states: local (full shell logic), stub (thin IPC client), and frozen (immutable after migration). Migration is hook-by-hook with pass-through fallback.
Handoff Bundle (Prompt T → Prompt B)
Collapses redundant plan re-derivation between Prompt T and Prompt B. Prompt T writes a sealed handoff bundle (.claude/local/handoff-bundle.yaml) with the inlined task contract on approval; its approval becomes the single approval gate. Prompt B replaces its plan → approval phases with a deterministic drift-check (_phase-helper.sh::drift_check) that writes plan-approved from a valid bundle. Saves ~5–15K tokens and one operator interaction per session.
Critic Single-Dispatch Consolidation
Adds a combined mode to the Critic that merges cohesion review and diff-review into one dispatch with two fixed sections (## Cohesion Brief, ## Diff-Review Brief), each ending in its own GATE_RESULT:. Eliminates duplicate prompt-assembly cost in the Prompt B review phase; both verdicts must be APPROVED to advance. state-writer.sh routes the sections to separate state files. Single-mode dispatches remain valid for targeted re-runs.
Finish-Loop Dimension Verdict Cache
Caches per-dimension PASS verdicts in Prompt F (finish-loop) keyed by an input-set hash, in a session-scoped finish-loop-cache.yaml. When a dimension’s input hash is unchanged since its prior PASS, the verdict is inherited instead of re-assessed, avoiding redundant regression-checks of stable dimensions. Append-only; only PASS is cached (FAIL re-runs); cleaned at session close.
Hooks & File Map
What runs automatically
| Hook | When | What it does | Blocks? |
|---|---|---|---|
pretooluse-permission.sh | Before every Agent and Bash | Agent: session-type-aware subagent allowlist — blocks write-capable subagents in no-write sessions (Prompt T/A/C/D, ephemeral), fail-closed when phase-state is missing (Decision 0027). Bash: deny list blocks dangerous commands incl. claude subprocess; allow list passes safe patterns; headless fail-closed for unknown commands. Audit: .claude/.automation/logs/permission-audit.log. | yes (deny) |
bash-guard.sh | Before every Bash | Consolidated Bash PreToolUse guard (Phase 3a). State-guard, mode guard, plan-approval gate, fail-closed phase enforcement (Decision 0019), task group merge protection (Decision 0018), session overlap, session branch isolation. Daemon-safe branching (Phase 1c): blocks git checkout/git switch/git reset --hard on the main tree while the automation daemon is active (Decision 0036). Ephemeral session fast-exit (Phase 3b). Override: REPO_OS_ALLOW_MAIN=1, REPO_OS_SKIP_PLAN_GATE=1, REPO_OS_SKIP_BRANCH_REUSE=1, REPO_OS_RECOVER=1. | yes (exit 2; ephemeral: pass-through) |
write-guard.sh | Before every Edit or Write | Unified state + mode + branch enforcement. Blocks model writes to .claude/.state/; mode guard (template/child/autonomous per .claude/repo-mode); main-branch protection; phase-aware edit gate (blocks edits during init/plan); session overlap and branch isolation (Decision 0013; closed-branch ledger, task groups exempt). Override: REPO_OS_SKIP_STATE_GUARD=1, REPO_OS_SKIP_MODE_GUARD=1, REPO_OS_UNLOCK_PATH=<path>, REPO_OS_ALLOW_MAIN=1, REPO_OS_SKIP_BRANCH_REUSE=1, REPO_OS_RECOVER=1. | yes (exit 2) |
pre-commit-gates.sh | Before every git commit | A4: Secret scanning (blocks). State file verification (blocks — requires plan-approved, pragmatist-signed, cohesion-reviewed, diff-review-complete, qa-verified). A5: Cohesion + diff-review APPROVED (Decision 0039). Gate 3: Inter-session governance check (advisory, first-fire). A2: Scope >100 lines (blocks unless large-scope approved). A6: Task group contract staging (blocks). High-risk pattern detection (blocks — requires reviewer-signed + security-signed). A1: Decision trigger parser (blocking). Override: REPO_OS_SKIP_PLAN_GATE=1, SKIP_CONTRACT_CHECK=1, REPO_OS_RECOVER=1. | yes (exit 1) |
pre-push-gates.sh | Before every git push | B1: Branch naming convention (blocks). Stubs for B2 tests/typecheck and B3 dependency audit — activate per project. Override: REPO_OS_RECOVER=1. | yes (exit 1) |
plan-approval.sh | After AskUserQuestion | Captures operator plan approvals. Writes .claude/.state/plan-approved when operator confirms a plan (legacy provenance — the bundle path _phase-helper.sh::drift_check also writes plan-approved from a valid handoff bundle, Decision 0038). Never blocks (PostToolUse). | no (post-tool) |
state-writer.sh | After subagent completes | Captures governance agent verdicts as state files in .claude/.state/ — cohesion-reviewed, diff-review-complete (routed by the MODE: diff-review sentinel, Decision 0039), qa-verified, reviewer-signed, security-signed, pragmatist-signed. Extracts GATE_RESULT: sentinel. Subagent worktree writes skipped (Decision 0028); full worktree sessions allowed (Decision 0030). Never blocks. | no (post-agent) |
agent-git-guard.sh | Builder/QA/Security Bash calls | Blocks git commit and git push commands in subagents. Only the Orchestrator can commit/push. | yes (exit 2) |
ask-user-deny.sh | Before AskUserQuestion | Blocks AskUserQuestion when CLAUDE_HEADLESS=1 (Decision 0017). Defense-in-depth for headless automation — prevents interactive prompts in automated sessions. | yes (headless; interactive pass-through) |
permission-request.sh | On PermissionRequest | Auto-approves curated tools and safe Bash patterns (_permission-allowlist.sh), denies dangerous patterns, falls through to VS Code dialog. Audit log: .claude/.automation/logs/permission-audit.log (Decision 0017). | yes (deny) / allow / fallthrough |
hvst-failure-tracker.sh | After every Bash command | Tracks consecutive failures. After 2+ failures, reminds agent to check known-issues.md and follow HVST protocol. | no (advisory) |
session-close-check.sh | When Claude stops responding | Session log check (blocking; zero-change sessions downgrade to advisory). Uncommitted changes check (blocking). HVST known-issues check (blocking when hvst-fail-count ≥ 2). Deferrals known-issues check (blocking when .deferrals-pending exists). Override audit summary (advisory). Governance evidence verification for task groups (advisory). Next-brief reminder for task groups (advisory). Session-scoped state cleanup. Override: SKIP_SESSION_LOG=1, SKIP_UNCOMMITTED_CHECK=1, SKIP_KNOWN_ISSUES_CHECK=1, SKIP_CONTRACT_CHECK=1. | yes (multiple) |
| YAML frontmatter | Agent invocation | Restricts tools per agent (e.g., Builder can’t use Task, QA can’t use Edit/Write). Frontmatter hooks wire agent-git-guard.sh. | yes (runtime) |
Customizing hooks
Add your project’s lint, format, and build commands to .claude/hooks/pre-commit-gates.sh (A3 stubs). Add test, typecheck, and dependency audit commands to .claude/hooks/pre-push-gates.sh (B2/B3 stubs). Adjust permissions in .claude/settings.json (team-shared, committed) or .claude/settings.local.json (personal, gitignored).
Repository structure
Operating Modes
Three modes control which files an agent can modify. Enforced by write-guard.sh (Decision 0012). The mode is declared in .claude/repo-mode — a single word: template, child, or autonomous.
Mode summary
| Mode | Product code | Governance access | When to use |
|---|---|---|---|
| template | blocked | Full governance: agents, hooks, settings, prompts, decisions, logs, workflow, gates, spec templates, AI.md, CLAUDE.md, repo-os-explainer.html, .github/ | Upstream template repo development |
| child | allowed | Limited carve-outs: project decisions (0100+), logs, governance evidence, task group contracts, compiled specs, prototypes, settings.local.json | Project repos created from template (default) |
| autonomous | allowed | Minimal carve-outs: logs, task group contracts only | Headless operation with maximum governance protection |
Mode resolution
Priority (highest first):
REPO_OS_MODEenvironment variable (force any mode).claude/repo-modefile (committed, single word)- Default:
child(when file is missing)
Immune paths
write-guard.sh and repo-mode cannot be modified in any mode — no override accepted. This is self-protection against circumvention. To maintain these files: set REPO_OS_SKIP_MODE_GUARD=1 (disables the entire guard, logged in overrides.log).
Overrides
| Override | What it does | Scope |
|---|---|---|
REPO_OS_UNLOCK_PATH=<path> | Unlocks a single governance file for editing | One file per invocation. Immune paths rejected. |
REPO_OS_MODE=<mode> | Forces a specific mode (e.g., template access in a child repo) | Emergency use. Logged via overrides.log. |
REPO_OS_SKIP_MODE_GUARD=1 | Disables write-guard mode checks entirely | Recovery/debugging. Logged via overrides.log. |
Decision naming convention
t- prefix (t-0001-*.md through t-NNNN-*.md) and are synced from upstream, locked in child/autonomous modes. Child decisions use plain numeric names (0100-*.md+) and are editable in child mode. A t-manifest.txt file lists all template decisions for orphan cleanup. This preserves governance consistency while allowing project-level customization.
Prototyping
Not everything needs a full spec. When you want to test an idea, validate architecture, or explore a feature before committing to it, use Prompt 0.5 on an experiment/* branch. Only the A4 safety gate applies — no process gates, no review chain, no scope warnings.
Prototyping tiers
You choose the tier. The tiers are a menu, not a gate — they determine how much documentation overhead the session carries.
| Tier | When to use | Artifact |
|---|---|---|
| Napkin | Quick question, < 1 hour. “Does X even work?” | None — verbal conclusion only |
| Spike | Focused hypothesis, single session. “Can we build Y this way?” | Experiment brief |
| Proof of Concept | Multi-session exploration. “Is this entire approach viable?” | Experiment brief + mini-spec notes |
What to say to the Orchestrator
The system maps your natural language to tiers. You don’t need to memorize tier names — just describe what you want to do.
| You say… | Maps to |
|---|---|
| “Quick test”, “try this”, “does X work?”, “napkin test” | Napkin |
| “Spike on X”, “prototype this”, “test this architecture”, “validate this approach” | Spike |
| “Proof of concept”, “PoC”, “multi-day exploration”, “I need to explore this across sessions” | Proof of Concept |
How to start
The system helps you create an experiment/* branch (if needed), fill out a brief (Spike/PoC), and start building immediately. No full spec interview. No plan-before-code requirement.
What happens to the code?
Experiment branches never merge to main. The code is disposable. When you’re done:
- Discard — question answered, delete the branch
- Promote — capture learnings, then rewrite the validated approach into a
feature/*branch - Pivot — start a new experiment with a different hypothesis
Experiment briefs are stored in docs/spec/prototypes/ and survive branch deletion. Prompt B checks this directory for validated learnings before planning new work.
Task Definition — Prompt T
Prompt T facilitates exploration and task planning. Two modes, selected based on operator language — Query mode is conversational and ephemeral; Brief mode produces a copy-paste brief plus a sealed handoff bundle:
Query mode
Conversational Q&A grounded in specs and codebase. No agent dispatch, no structured output. The conversation is the output. If it evolves toward task definition, the system offers to switch to Brief mode.
Brief mode
Four core specialists (Architect, Exploration, Critic, Pragmatist) are dispatched in parallel — plus a conditional PM Advisory (when compiled specs or mvp-scope.yaml exist) and a conditional UX Design agent (for UI work) — to produce a structured task brief:
describes task
draft brief
review
The operator approves via a structured AskUserQuestion that merges brief approval with auto/review mode selection (Decision 0038). Options: Approve — review (Prompt B pauses at op-review before commit), Approve — auto (Prompt B runs autonomously through merge), Approve & queue (review/auto) (writes the brief + bundle to the automation queue for headless execution), Revise, or Abandon. Splitting into multiple briefs (Narrow) is available via “Other”. The finalized brief is displayed for copy-pasting, and the chosen mode is written into the bundle so the downstream session never re-prompts.
.claude/local/handoff-bundle.yaml (or per-brief under .claude/local/task-groups/{group}/briefs/{seq}.bundle.yaml) carrying the approved plan, task contract, spec snapshot, Pragmatist verdict, and chosen mode. The downstream Prompt B session reads the bundle at drift-check and skips re-planning — the Prompt T approval is the single operator approval gate. No session log entries are written either way.
How to start
Task Group Contracts
When Prompt T splits a task into multiple briefs (Narrow path), each brief includes a ### Task Group section. The briefs share a task group contract — a YAML file that coordinates naming, patterns, decisions, and integration points across sessions.
Contract lifecycle
| When | What happens |
|---|---|
| First Prompt B session | Creates the contract from brief metadata (identity, brief roster, conventions, integration points) |
| Subsequent sessions | Reads the contract. Conventions are REQUIRE-level — follow all naming patterns, architectural patterns, decisions, and module boundaries |
| At session close | Updates the contract: marks brief status, appends session decisions, writes governance evidence (gate results, overrides, timestamp) |
Contract path depends on repo mode: template mode uses .claude/local/task-groups/, child/product mode uses docs/ai/task-groups/. Gate A6 verifies contract compliance when a task group is present. Override: SKIP_CONTRACT_CHECK=1.
next_brief, and phase-chain governance lets Brief N+1 confirm Brief N passed its gates. Parallel groups (Execution: parallel, Decision 0032) run each content brief in its own worktree branch ({group}/brief-{seq}), write completion markers, and finish with an auto-generated merge brief (taskgroup-merge session) that combines the branches and runs cross-session cohesion review before merging to main.
Project Audit — Prompt C
On-demand health check that scans for drift, compliance issues, and accumulated problems. Read-only — no file modifications (except when the operator defers findings, which writes to known-issues.md).
Dimension menu
| Dimension | Agent | What it checks |
|---|---|---|
| Spec drift | Auditor (drift) | Does the code match the spec? |
| Decision compliance | Auditor (compliance) | Are decisions being followed? |
| Cohesion drift | Auditor (cohesion-drift) | Has internal coherence degraded? |
| Governance | Auditor (governance) | Are session logs, decisions, governance files healthy? |
| Tech debt | Auditor (tech-debt) | Accumulated compromises and maintenance risk |
| Security | Security/Privacy | Full-codebase vulnerability scan |
| Performance | Performance Engineer | Full-codebase performance review |
| Dependency health | Security/Privacy | CVEs, outdated packages, supply chain risks |
Depth tiers
| Tier | When | Dimensions |
|---|---|---|
| Quick | Routine check-in | Governance + Security |
| Standard | Milestone or pre-release | Operator-selected (tech-debt available) |
| Deep | Full health audit | All dimensions |
How it works
selects dimensions
dispatches
Report
accept/reject/defer
Specialist collaboration: Escalation (Auditor tags a finding → specialist follows up), Co-audit (both run in parallel), Workshop (iterative loop, capped at 2 rounds).
known-issues.md (Known Limitations table).
How to start
Hotfix & Debug — Prompt H
Reactive debugging and fix session for runtime errors, integration failures, and production incidents. Operates on hotfix/* branches with expedited gates (A2 scope relaxed, A5 cohesion skipped). Structured workflow: diagnose root cause, apply minimal fix, iterate when fixes fail, escalate when diagnosis stalls.
Workflow
error + context
root cause
minimal change
repro test
Loop: verify → build when the fix doesn’t work. Maximum 3 fix cycles before escalation.
Agent dispatch
| Phase | Agent | Notes |
|---|---|---|
| plan (investigation) | Explore + Architect + Exploration | Parallel root cause investigation |
| plan (review) | Pragmatist | Plan-gating on fix strategy |
| build | Builder | Implements the fix |
| verify | QA Verifier | Expedited gates (A2 relaxed, A5 skipped) |
| commit | Orchestrator | Commit with trailers |
Escalation protocol
After 3 failed fix cycles, Prompt H produces a structured Debug Report containing: symptoms observed, hypotheses tested (with results), root causes eliminated (with evidence), remaining candidates, and recommended next steps. The operator may provide new evidence, accept a partial fix, or redirect entirely.
Known patterns
| Pattern | Symptoms | Fix approach |
|---|---|---|
| Plugin scope issues | Permission denied, command not found at runtime | Bypass plugin, use custom IPC |
| OAuth flow failures | Auth callback errors, token exchange failures | Debug logging, check verification status values |
| Stale closure bugs | State appears stale, race conditions | Reload state before checking captured values |
| Dev vs production divergence | Works locally, fails in CI/production | Gate workarounds behind dev-mode guard |
| Build system stale cache | Config changes not taking effect | Clean rebuild |
How to start
HVST Review Board
When HVST debugging stalls (2+ consecutive failures) or the operator proactively requests a debug review, the Orchestrator dispatches a 3-agent review board for multi-agent hypothesis analysis.
2+ failures
dispatches board
hypotheses
with best hypothesis
The board produces ranked hypotheses (not consensus) ordered by evidence strength, falsifiability, and implementation risk. The operator or Builder selects which to validate first. Capped at 1 review board round — if still stuck, escalate to operator.
Branch Categories
Every branch has a category that determines which gates apply and at what strictness. Use the naming convention <category>/<short-description>.
| Pattern | Purpose | Gate Profile |
|---|---|---|
main | Production-ready code | All gates (A + B). Protected — no direct commits. Merge at session close (solo mode). |
release/* | Release candidates | All gates (A + B) + release checklist (C). Reviewer + Security required on every merge. |
feature/* | New functionality | Standard gates (A + B). Normal workflow. |
fix/* | Bug fixes | Standard gates (A + B). Normal workflow. |
hotfix/* | Urgent production fixes | Expedited: A2 scope limit relaxed, A5 skipped (operator discretion). A1, A3, A4 still enforced. |
experiment/* | Spikes & prototypes | A4 (safety) only. Never merge to main — rewrite into feature/*. Use Prompt 0.5 with prototyping tiers. |
feature/*. Never commit directly to main — all work flows through a categorized branch.
Examples
Multi-Agent Teams
Repo OS is designed for one operator, one session, one branch at a time. But you can scale to parallel agent teams working on separate branches. Here’s how.
When to use parallel teams
- Multiple independent features in flight simultaneously
- Time-sensitive delivery where sequential work is too slow
- Large projects where features have clear ownership boundaries
How it works
Each team is a separate Claude Code session on a separate branch. The Repo OS governance model runs independently in each session — same gates, same agents, same enforcement. No special configuration needed to start.
claude --worktree for interactive sessions, automatic for the runner — so the main working tree stays on main with no branch switching. Per-session state is isolated (get_session_state_dir, Decision 0030) and concurrent merges to main are serialized via a merge lock. Opt out with REPO_OS_WORKTREE_ISOLATE=0.
What you must set up
| Concern | What to do |
|---|---|
| Session logs | Use per-branch session logs to avoid collisions: docs/ai/logs/session-log-<branch-name>.md. Each session writes to its own file. |
| Branch scope | Define clear ownership boundaries upfront. Each branch should own distinct files/modules. Overlapping file ownership across branches creates merge pain. |
| Merge governance | Merges into main require full gate verification (B-series). Solo sessions merge at close. The operator reviews cross-branch integration — agents only see their own branch. |
| Shared model changes | If two branches need to change the same schema, API contract, or shared module — stop. Do those changes first on one branch, merge to main, then rebase the others. |
What Repo OS handles
- Each session independently enforces all gates (A1–A6, B1–B3)
- Secret scanning runs per-session before every commit
- Agent tool boundaries apply identically across all sessions
- Decision compliance is checked per-session
What Repo OS does NOT handle
- Signaling between branches (“team A changed the user model”)
- Automatic conflict detection before merge time
- Merge-time gate escalation (you define this per project)
- Shared state or progress tracking across sessions
Practical setup checklist
feature/* or fix/* branch per workstreamclaude --worktree), each runs Prompt B independentlymainmain to minimize merge conflictsTemplate Sync
If your repo was created from a template, you can pull governance updates (workflow rules, agent definitions, gates, prompts) without losing your project-specific specs or decisions.
How it works
governance updated
detects changes
for audit trail
A GitHub Actions workflow runs daily (06:00 UTC) and compares your repo against the template. When differences are found, it creates a PR and auto-merges it. Your compiled specs and logs are never touched — protected by .templatesyncignore. Template decisions (t-*) sync from upstream; child decisions (0100+) are untouched. Every sync is recorded as a merged PR for audit.
.claude/.automation/templates/template-sync-with-cleanup.yml. Copy it to .github/workflows/template-sync.yml in your child repo and configure the source repo path.
One-time setup
- Copy
.claude/.automation/templates/template-sync-with-cleanup.ymlto.github/workflows/template-sync.yml - Replace
OWNER/repo-OS-templatewith your actual template repo path - If the template repo is private (required):
- Create a Classic PAT on GitHub: Settings → Developer settings → Personal access tokens → Tokens (classic)
- Scopes required:
repoandread:org(fine-grained PATs are not compatible with git clone in Actions) - Add the PAT as a repository secret named
SOURCE_REPO_TOKENin each child repo (Settings → Secrets and variables → Actions) - In each child repo: Settings → Actions → General → Workflow permissions → enable "Allow GitHub Actions to create and approve pull requests"
The workflow already references
SOURCE_REPO_TOKENviasource_gh_token. If the template repo is public, you can remove that line — the defaultGITHUB_TOKENworks without extra setup.
Note: The template repo itself should not have this workflow. Only project repos created from the template need it.
Want to review before merge?
Remove the Auto-merge sync PR step from the workflow. Sync PRs will stay open until you merge them from the Pull requests tab on GitHub.
What syncs vs what stays
| Syncs from template | Protected (never overwritten) |
|---|---|
AI.md | docs/spec/compiled/ |
docs/ai/prompts/ | docs/ai/logs/ |
docs/ai/workflow.md | docs/spec/prototypes/ |
docs/ai/quality-gates.md | .claude/settings.local.json |
docs/ai/decisions/ | |
.claude/agents/ | |
.claude/hooks/ | |
docs/spec/_templates/ |
GitHub prerequisites
The sync workflow uses GitHub Actions. Before setup, confirm these settings on your project repo (not the template):
- Actions enabled — On by default. Check at Settings → Actions → General.
- Workflow permissions — Go to Settings → Actions → General → Workflow permissions and select Read and write permissions. The workflow declares its own permissions, but the repo-level setting must allow it.
- Branch protection (if used) — If
mainhas branch protection requiring PR reviews or status checks, the auto-merge step cannot bypass them. Either allow the github-actions bot to bypass protection rules, or use manual merge mode.
Merge conflicts
If your project has locally modified a governance file that the template also updated (e.g., you customized .claude/hooks/pre-commit-gates.sh and the template changed it too), the auto-merge will fail. The sync PR stays open and you resolve the conflict manually — same as any git merge conflict.
To avoid this for files you always want to customize, add them to .templatesyncignore. The template sync will skip them entirely.
When you need to act
Syncs are automatic. The only time you need to act is if spec templates were updated with new fields:
- Check the merged PR diff — look for changes in
docs/spec/_templates/ - If templates changed, re-run Prompt 0:
- It detects existing compiled versions and enters update mode
- Copies your latest version, highlights new/changed fields, asks what to fill in
- Output goes to a new version (e.g.,
v2) — previous version preserved
- If only governance files changed (agents, gates, prompts) — no action needed, already live
docs/spec/compiled/v1/, v2/, etc. A manifest.json tracks the active version. Prompt B always reads from the active version. Previous versions are kept for reference and rollback.
Template version tags
The template repo uses CalVer git tags (format: v2026.02.1 — YYYY.0M.MICRO) to mark meaningful milestones. Tags are applied on main after changes to decisions, agents, hooks, or prompts. Not every commit is tagged. Each tag has a corresponding GitHub Release with a summary of what changed.
To check which template version your child repo synced from, look at the sync PR — git log --oneline in the PR diff shows the tagged commit. You can also compare against the template repo's Releases page to see what's included.
Companion Tools
Repo OS is a governance framework. Companion tools extend the development workflow without modifying the core system. They integrate via MCP servers registered in .claude/settings.json.
Visual Bridge optional
A Chrome extension + MCP server for visually editing live front-end UI and feeding precise change requests back to Claude Code.
What it does
- Operator selects and adjusts elements in the browser (spacing, typography, colors, sizing)
- Edits snap to the project’s design system tokens
- Structured diffs with exact source file and line number are sent to Claude Code
- Claude Code applies the precise edit — no fuzzy matching, no guessing
Setup (per project)
- Install the dev plugin:
npm install -D @visual-bridge/dev-plugin - Add to your build config (e.g.,
import { visualBridge } from '@visual-bridge/dev-plugin'in vite.config.ts) - Add the MCP server to
.claude/settings.json:"visual-bridge": {"command": "npx", "args": ["@visual-bridge/mcp-server"]} - Install the Chrome extension from the Chrome Web Store
Design token discovery: The MCP server auto-reads tokens from your project’s Tailwind config, tokens.json, or docs/spec/compiled/{active}/design-system.md. No additional configuration needed.
Automation Layer
An optional headless runner infrastructure for automated claude -p sessions with full governance parity. Decision 0017. Ships disabled by default — no behavioral change until the operator explicitly opts in.
Runner lifecycle
approved entry
branch, state, prompt
headless session
cleanup, merge
Queue lifecycle
| Status | Description | Transitions to |
|---|---|---|
pending-review | New entry awaiting operator approval | approved |
approved | Ready for runner to dequeue | running |
running | Active headless session in progress | completed, failed, review, blocked |
completed | Session finished successfully | — |
failed | Retries exhausted | — |
review | Escalated to operator | — |
blocked | Unrecoverable error (invalid config, missing dependency) | — |
Enabling and disabling
| Method | Effect |
|---|---|
Set runner.enabled: true in config.yaml | Daemon processes queue entries normally |
Set runner.enabled: false in config.yaml | Daemon sleeps (30s between checks). Queue entries preserved |
Create .claude/.automation/HALT file | Daemon exits immediately. Emergency stop |
Remove HALT file | Daemon resumes on next start |
Prompt D provides a conversational alternative to manual config edits. It runs as a single-purpose ephemeral session that toggles runner.enabled in config.yaml and manages the HALT file — two files only, then closes automatically. Use the Navigator to find it, or paste the Prompt D starter directly.
Phase model integration
Automated sessions use the same phase sequences as interactive sessions (Decision 0014) and run worktree-isolated by default (Decision 0033). When a brief was queued from Prompt T with a handoff bundle (Decision 0038), the session’s drift-check phase reads the bundle and derives plan-approved + pragmatist-signed directly; the runner’s pre-write of plan-approved is the fallback for bundle-absent (legacy) briefs. All hooks fire normally except the Stop hook — the runner replicates Stop hook cleanup (solo merge, registry cleanup, branch sealing) as part of the post-session phase.
Dev Orchestrator
For task groups, the runner invokes a Dev Orchestrator agent between content briefs and before merge briefs. The orchestrator reviews cross-brief coherence, validates contract compliance, detects boundary drift, and produces health reports. Reports are written to .claude/.automation/reports/ (gitignored). All findings are advisory — the runner or operator decides what to act on.
Key files
| Path | Purpose |
|---|---|
.claude/.automation/config.yaml | Runner configuration. Master toggle, retry limits, retention |
.claude/.automation/runner.sh | Entry point. Single-shot and daemon modes |
.claude/.automation/schemas/ | YAML schema contracts (queue-entry, escalation, blocker-report, runner-config) |
.claude/.automation/templates/ | Prompt templates for automated brief assembly |
.claude/.automation/lib/ | Runner libraries (queue, state, branches, validation, locking) |
.claude/.automation/decision-cache.yaml | Project-level decision cache for prompt prepending |
.claude/.automation/queue/ | Runtime queue entries by status (gitignored) |
.claude/.automation/reports/ | Blocker reports and health reports (gitignored) |
.claude/.automation/escalations/ | Operator-directed escalation files (gitignored) |
Session Hygiene
Every session must end with all five satisfied. If they’re not, you’re not done.
Session log format
Glossary
- Small Scope
- <100 lines, ≤3 files, single concern, reviewable in <10 min. Larger needs operator approval.
- Gate
- Blocking verification checkpoint. Types: Process, Quality, Safety, Conditional. Must pass before commit/push.
- Decision
- Version-controlled constraint in docs/ai/decisions/. Mandatory. Violations block commits.
- Evidence
- Proof a gate was checked: command, output excerpt, pass/fail, timestamp.
- High-Risk
- Auth, payments, data persistence, security, PII, external integrations. Requires Reviewer + Security sign-off.
- Plan
- Pre-coding roadmap: goal, decisions, steps, files, verification, risks. Required before implementation.
- Session
- Bounded work unit. Clear start/end, scope, verification evidence, clean commits at close. Branch merges to main at close (solo mode). Phase model tracks progress.
- Escalation
- Routing to higher authority. Triggered when agent lacks authority, requirements ambiguous, constraints conflict.
- Hook
- Automated script at lifecycle events (pre-commit, session stop). Runs regardless of agent behavior.
- Handoff
- Formal work transition between agents. Includes summary, status, verification items.
- Structural Change
- New modules, API contracts, schemas, build system changes. Requires Reviewer sign-off.
- HVST
- Hypothesis → Validate → Solve → Test → Record. 5-step debugging protocol. Prevents random-fix loops.
- Experiment Brief
- Lightweight document capturing hypothesis, method, success criteria, and learnings for a prototype session. Template at
docs/spec/_templates/_experiment-brief.md.
- Prototype Tier
- Operator-selected documentation level for experiments: Napkin (no artifact), Spike (experiment brief), Proof of Concept (brief + mini-spec notes). See Prototyping.
- Advisory Board
- Up to 9 specialist agents that review compiled specs (or task briefs) before build. Core always-on: Architect, Critic, Pragmatist; Standard+: Exploration, PM Advisory; Full (signal-triggered): Security, UX, Performance, Data. Runs during Prompt A Phase 1. All findings are advisory — operator decides.
- Refinement Report
- Synthesized output of advisory board review. Contains critical findings, recommendations, and ideas. Operator reviews per-item.
- Feature Brief
- Lightweight spec template for individual feature additions. Created via Prompt T’s significant-feature path (Decision 0010). Drives advisory board activation via the “What It Touches” field.
- Cohesion Review
- Post-build review by Critic (cohesion mode) checking the diff and surrounding code for internal codebase coherence: broken references, dangling imports, inconsistent naming, incomplete integrations. Gate A5. Distinct from spec review (advisory board).
- Phase
- Declared step in a session’s lifecycle sequence. Each phase has an automation tag (
agent/operator/both) indicating who acts. Tracked in.claude/.state/phase-state. See Phase Model.
- Solo Mode
- Merge strategy where branches merge directly to main at session close. Set per-session. Excluded for
experiment/*andrelease/*branches.
- Auto Mode
- Session mode where the agent closes autonomously after all gates pass, skipping the
op-reviewphase. Selected at the Prompt T brief approval (recorded in the handoff bundle’smodefield) and read by drift-check; chosen at plan approval for bundle-absent legacy sessions. Contrast with review mode (default), which pauses for operator acceptance.
- Automation Layer
- Optional headless runner infrastructure for automated
claude -psessions with full governance parity. Ships disabled. Decision 0017. See Automation Layer.
- Dev Orchestrator
- Task-group-scoped oversight agent for cross-brief coherence review, contract compliance, drift detection, and health reports. Read-only. Invoked by the automation runner between briefs and before merge briefs.
- Handoff Bundle
- Sealed YAML artifact written by Prompt T Brief mode on approval (
.claude/local/handoff-bundle.yaml, or per-brief for task groups). Carries the approved plan, task contract, spec snapshot, Pragmatist verdict, chosen mode, and expiry. Prompt B’s drift-check reads it to skip re-planning — the Prompt T approval becomes the single approval gate. Decision 0038.
- Drift-Check
- Prompt B phase (Decision 0038) that evaluates the handoff bundle. When the bundle is valid, fresh, its spec snapshot matches, and no scope-file drift is detected, the session writes derived state and forward-jumps to
build, skippingplanandapproval. Otherwise it falls through to the legacy plan→approval flow.
- Worktree Isolation
- Default for all sessions (Decision 0033): each session runs in its own git worktree (
claude --worktree; automatic in the runner), keeping the main tree onmainand isolating per-session state. Opt out withREPO_OS_WORKTREE_ISOLATE=0.
- Knowledge Graph
- Persistent semantic map of codebase entities (files, decisions, hooks, prompts, contracts, conventions) at
docs/ai/knowledge-graph/graph.yaml(template) andproduct-graph.yaml(child). 7 node types, 8 edge types; operator-curated edges are immutable by agents. Decision 0034.
- Pragmatist
- Over-engineering / YAGNI review agent (Decision 0025). Brief-Advisory mode in Prompt T (4th core specialist); Plan-Gating mode in Prompt B (gates plans via
GATE_RESULT—FUNDAMENTAL-MISMATCHblocks,OVER-ENGINEEREDis advisory). State file:pragmatist-signed.