‹ Aigile Playbook Architecture
Engineering Playbook · Architecture Reference

Claude Code Local Architecture

Projectaigile
ModeCLI interactive mode
StatusStable · March 2026
Slash command (user-invoked)
Hook (system-enforced, Python)
Agent (team worker, tmux pane)
Native / always-on
Advantage over Copilot

~/.claude/ — global user configuration

all files present
~/.claude/
settings.json always-on wires all hook events · sets CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 · enables tmuxSplitPanes + teammateMode: tmux · global permissions
commands/ slash commands, user-invoked
plan_to_build.md /plan_to_build analyze codebase → design solution → compose team from agents/team/ → write exhaustive spec to specs/ → Stop hook validates 7 sections
build.md /build TeamCreate → TaskCreate graph with addBlockedBy deps → deploy builders + validator + spec-updater in parallel tmux panes → monitor via SendMessage → TeamDelete
agents/team/ self-organizing team workers
builder.md builder polls TaskList → claims unblocked task → executes → marks completed → loops until no tasks remain
validator.md validator read-only — runs validation commands, checks acceptance criteria, creates fix tasks on FAIL (max 2 cycles), posts PASS/FAIL to team-lead
spec-updater.md spec-updater runs after all other tasks — re-runs validation commands, writes ## Build Evidence section into spec file with PASS/FAIL per criterion
bug-creator.md bug pipeline investigates codebase, reproduces bug, writes JIRA-format 8-section report to bugs/BUG-NNN/report.md
bug-router.md bug pipeline read-only classifier — reads report + .claude/bug-modules.json, routes to correct fixer agent
bug-fixer-api.md bug pipeline API/routes/controllers specialist — reads bug report, creates fix plan at specs/fix-NNN.md
bug-fixer-frontend.md bug pipeline React/components/hooks specialist — reads bug report, creates fix plan at specs/fix-NNN.md
bug-fixer-database.md bug pipeline database/migrations specialist — reads bug report, creates fix plan at specs/fix-NNN.md
bug-reviewer.md bug pipeline adversarial read-only reviewer — 5-point checklist, APPROVE/REJECT verdict, deployed twice in isolation (alpha + beta)
pr-agent.md bug pipeline creates structured PRs via gh pr create with bug summary, root cause, fix description, test evidence
hooks/ system-enforced Python, fires on lifecycle events
pre_tool_use.py PreToolUse blocks dangerous commands (rm -rf, force push) — safety gate before every tool call
enforce_team_lead.py PreToolUse blocks Write/Edit to .claude/ or specs/ from non-team-lead agents during active build sessions
require_team_create.py PreToolUse enforces TeamCreate before TaskCreate — prevents orphaned tasks with no team
validate_plan_format.py PreToolUse blocks Write to specs/*.md if any of the 7 required sections are missing
validate_task_description.py PreToolUse blocks TaskCreate if description is under-specified — enforces exhaustive task descriptions
enforce_test_evidence.py PostToolUse ensures test output is captured to bugs/NNN/test-results.md before PR creation in bug pipeline
merge_gate.py PreToolUse blocks merge commands unless both adversarial reviewer verdicts are APPROVE — prevents unreviewed merges
enforce_review_isolation.py PreToolUse prevents reviewer-alpha and reviewer-beta from reading each other's verdicts before both complete
session_start.py SessionStart loads CONTEXT.md + TODO.md from .claude/ if present — ambient session context on every start
stop.py Stop final gate — wires to plan_to_build Stop hook validators before session ends
validators/
validate_new_file.py Stop hook blocks session end unless a new .md file was written to specs/ in the last 30 minutes
validate_file_contains.py Stop hook blocks session end unless newest specs/*.md contains all 7 required sections: Task Description, Objective, Relevant Files, Step by Step Tasks, Acceptance Criteria, Team Orchestration, Team Members
skills/ always-on engineering philosophy library (48 skills)
writing-plans/ planning ≥50-word task descriptions, bite-sized tasks, design assertions per task, section minimums
test-driven-development/ building RED-GREEN-REFACTOR enforced — write failing test first, then minimal passing code, then refactor
systematic-debugging/ building reproduce → isolate → root cause → fix. No random changes. Mandatory 4-phase process.
verification-before-completion/ validation never declare done without running commands and showing actual output
safe-rollback/ safety git checkout rollback when fix cycles exhausted — never leave codebase in broken state
+ 43 more skills library brainstorming, code-refactoring, frontend/backend guidelines, k8s-sre, playwright, pr workflow, and more
.tmux.conf config Ctrl+a prefix · | and - splits · arrow + hjkl pane nav · mouse on · base-index 1 · 10k scrollback. Required for agent team split panes.

Claude Code CLI — agent team mode

parallel · local · user-driven · tmux panes
flowchart TD DEV([👤 Developer
Terminal + tmux]) -->|"/plan_to_build
'add feature X'"| PTB DEV -->|"/build specs/plan.md"| BUILD subgraph PLAN_PHASE ["📋 Plan Creation (plan_to_build.md)"] PTB["Analyze codebase directly
no subagents — understand patterns"] --> DESIGN DESIGN["Design solution
task type · complexity
architecture decisions"] --> TEAM_COMP TEAM_COMP["Compose team
from agents/team/*.md
builder count · workstream split"] --> WRITE_SPEC WRITE_SPEC["Write exhaustive spec
to specs/*.md
task IDs · deps · full descriptions"] --> SELF_VERIFY SELF_VERIFY["Self-verify before save
count sections = 7
task descriptions ≥50 words"] --> HOOK_STOP HOOK_STOP["Stop hook fires
validate_new_file.py
validate_file_contains.py
— 7 required sections?
— file created this session?"] end HOOK_STOP -->|"PASS → allow stop
FAIL → block + fix"| REPORT1 REPORT1["Plan report
+ EXECUTION DIRECTIVE
FORBIDDEN: direct implementation"] REPORT1 -->|"'/build specs/plan.md'"| BUILD subgraph BUILD_PHASE ["⚙️ Build Orchestration (build.md)"] BUILD["Team Lead
reads spec
disallowed: Write, Edit, NotebookEdit"] --> TEAM_CREATE TEAM_CREATE["TeamCreate
team named after plan"] --> TASK_GRAPH TASK_GRAPH["TaskCreate × N
one per plan task
+ addBlockedBy deps
+ auto spec-updater task (blocked by all)"] --> DEPLOY subgraph DEPLOY ["🚀 Parallel Deploy (run_in_background: true)"] B1["builder-1
standing orders:
TaskList → claim → execute
→ complete → SendMessage → loop"] B2["builder-2
(if plan has parallel work)
same standing orders"] VAL_A["validator
standing orders:
claim validator tasks
run commands → PASS/FAIL
create fix tasks on FAIL"] SPEC_U["spec-updater
standing orders:
runs last (blocked by all)
re-runs commands
writes Build Evidence to spec"] end DEPLOY --> MONITOR MONITOR["Team Lead monitors
receives SendMessage reports
does NOT poll — event-driven"] MONITOR -->|"Validation FAILED
fix_cycle < 2"| FIX_TASK FIX_TASK["validator creates fix task
role: builder
+ re-validation task blocked by fix"] FIX_TASK -->|"builders auto-discover"| DEPLOY MONITOR -->|"FAILED max cycles"| ESCALATE ESCALATE["Escalate to user
collect failure details
do NOT create more fix tasks"] end BUILD_PHASE --> SHUTDOWN SHUTDOWN["SendMessage shutdown_request
to all agents
wait shutdown_response
TeamDelete"] --> BUILD_REPORT BUILD_REPORT["Build Report
agents · tasks · validation results
fix cycles · spec evidence
files changed"] subgraph HOOKS ["🪝 Hooks — Python via uv run (settings.json)"] H1["PreToolUse
pre_tool_use.py — dangerous cmd guard
enforce_team_lead.py — write guard
require_team_create.py — team guard
validate_plan_format.py — 7 sections
validate_task_description.py — exhaustive desc
merge_gate.py — review gate
enforce_branch_discipline.py"] H2["PostToolUse
post_tool_use.py
enforce_test_evidence.py
validate_bug_report.py
validate_pr_test_evidence.py"] H3["Stop
stop.py → validate_new_file.py
+ validate_file_contains.py
blocks if spec incomplete"] H4["SessionStart / SessionEnd
session_start.py — load CONTEXT.md
session_end.py — state persist
subagent_start/stop — audit log"] end style DEV fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a style PLAN_PHASE fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a style PTB fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a style DESIGN fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a style TEAM_COMP fill:#edf2fb,stroke:#2a5fa5,color:#7a7468 style WRITE_SPEC fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a style SELF_VERIFY fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a style HOOK_STOP fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a style REPORT1 fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a style BUILD_PHASE fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a style BUILD fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a style TEAM_CREATE fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a style TASK_GRAPH fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a style DEPLOY fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a style B1 fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a style B2 fill:#f0ecfc,stroke:#6450b4,color:#7a7468 style VAL_A fill:#f0ecfc,stroke:#2d7a4f,color:#1a1a1a style SPEC_U fill:#f0ecfc,stroke:#2d7a4f,color:#7a7468 style MONITOR fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a style FIX_TASK fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a style ESCALATE fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a style SHUTDOWN fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a style BUILD_REPORT fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a style HOOKS fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a style H1 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468 style H2 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468 style H3 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468 style H4 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468

📋 plan_to_build.md

1
Analyze Requirements
parse USER_PROMPT · determine task type + complexity
2
Understand Codebase Directly
no subagents — Read, Grep, Glob existing patterns and architecture
3
Design Solution
architecture decisions · technical approach · edge cases
4
Define Team Members
builder count · names · agent types from agents/team/*.md · one validator
5
Exhaustive Task Descriptions
fully self-contained · file paths · code patterns · acceptance criteria · validation command
6
Save + Stop Hook Validates
validate_new_file.py + validate_file_contains.py block if any of 7 sections missing
7
EXECUTION DIRECTIVE in spec
FORBIDDEN: direct implementation by main agent · REQUIRED: /build command only

⚙️ build.md

1
Team Lead — never writes code
disallowed-tools: Write, Edit, NotebookEdit — enforced by frontmatter
2
Full task graph with dependencies
TaskCreate per task · addBlockedBy for correct ordering · auto spec-updater last
3
Deploy once with standing orders
run_in_background:true · builders + validator + spec-updater in parallel tmux panes
4
Event-driven monitoring
wait for SendMessage reports · do NOT poll · intervene only on escalations
5
Validator fix cycles (max 2)
validator creates fix task + re-validation task · builders auto-discover · escalate if exceeded
6
Clean shutdown
SendMessage shutdown_request to every agent · wait response · TeamDelete · build report

🪝 hooks — Python lifecycle events

Pre
PreToolUse — 7 guards
dangerous cmd · team lead writes · team before tasks · plan format · task quality · merge gate · branch discipline
Post
PostToolUse — 4 validators
post_tool_use · test evidence · bug report 8 sections · PR test evidence
Stop
Stop — spec gate
new file in specs/ required · all 7 sections present · blocks session end if missing
Ses
Session lifecycle
SessionStart: load CONTEXT.md · SessionEnd: persist state · SubagentStart/Stop: audit log
Cfg
All wired in settings.json
uv run $HOME/.claude/hooks/*.py — portable $HOME paths, no hardcoded usernames

🤖 agent standing orders

B
Builder loop
TaskList → claim lowest-ID unblocked (role:builder) → TaskGet → execute → complete → SendMessage → repeat
V
Validator loop
claim (role:validator) → run all commands → PASS: complete · FAIL: create fix+revalidation tasks
S
Spec-updater (runs last)
blocked by all other tasks · re-runs commands · writes ## Build Evidence into spec · read-only for src
Role filtering is strict
builders skip role:validator tasks · validators skip role:builder · prevents cross-contamination
Idle → retry → shutdown
no tasks: wait 10s, retry max 5 · then send "all tasks complete" · await shutdown_request

Skills → Command embedding traceability matrix

deterministic enforcement
Skill Embedded In Enforcement Key Rule
writing-plansplan_to_build → Step 5 task descriptionsprompt + hook≥50-word exhaustive descriptions, design assertions per task, 7 required spec sections
brainstormingplan_to_build → Steps 1–3 analysispromptultrathink approach, consider edge cases and scalability before writing tasks
plan-reviewerplan_to_build → self-verify before savepromptcount builders, validators, check every acceptance criterion before writing spec
test-driven-developmentbuilder standing orders (implicit)promptagents follow TDD as part of their base agent definition — test first is mandatory
systematic-debuggingvalidator fix cycle dispatchpromptfix tasks include reproduce → isolate → root cause → fix protocol
verification-before-completionbuild → validator standing orderspromptnever report PASS without running actual commands and capturing actual output
safe-rollbackbuild → max fix cycles exhaustedpromptafter 2 failed fix cycles, validator escalates — team lead reports, no further fix tasks
executing-plansbuild → task graph executionpromptdependency ordering via addBlockedBy — agents never start tasks before prerequisites complete
spec section checkvalidate_plan_format.py + validate_file_contains.pySYSTEM7 sections required — blocks Write and blocks Stop if missing
task quality checkvalidate_task_description.pySYSTEMTaskCreate blocked if description is under-specified — enforces exhaustive agent context
team lead enforcementenforce_team_lead.pySYSTEMWrite/Edit to .claude/ and specs/ blocked during active build — only team lead may write spec
merge gatemerge_gate.pySYSTEMmerge commands blocked unless bug pipeline state shows both reviewer verdicts are APPROVE
review isolationenforce_review_isolation.pySYSTEMreviewer-alpha cannot read reviewer-beta verdict (and vice versa) until both complete
test evidence captureenforce_test_evidence.pySYSTEMPR creation blocked unless test results committed to bugs/NNN/test-results.md
spec build evidencespec-updater standing ordersstructuralspec-updater task always auto-created by /build, blocked by all others — spec becomes system of record
dangerous command guardpre_tool_use.pySYSTEMrm -rf, force push, --no-verify blocked before every tool call — safety net for all agents

What Claude Code can do that Copilot local cannot

native platform capabilities
Feature GitHub Copilot (local) Claude Code (this setup)
Parallel agent execution✗ sequential only — one subagent at a time✓ run_in_background:true — builders work simultaneously in tmux panes
Shared task board⚠ todo list in orchestrator context only✓ TaskCreate/Update/List/Get on disk — agents independently discover work
Agent resume✗ each dispatch is fresh, stateless✓ resume: agentId preserves full context — agent continues mid-task
Peer-to-peer messaging✗ not available✓ SendMessage — agents report completion, request help, trigger shutdown
Agent teams + tmux panes✗ not available✓ TeamCreate/Delete — named team with tmux split panes per agent
Tool restriction per agent⚠ tools: field exists but names undocumented✓ disallowed-tools frontmatter — validator and build leader cannot Write/Edit
Dependency-ordered tasks⚠ sequential list only — no DAG✓ addBlockedBy — correct DAG ordering, agents never start prematurely
Spec as system of record⚠ spec written once, not updated✓ spec-updater always runs last — ## Build Evidence written back with actual command output
Python hook ecosystem⚠ bash/JSON hooks, limited logic✓ full Python hooks via uv run — complex validation, state machines, audit logs
Native OTel traces✗ session logs only⚠ subagent_stop.py audit log — not distributed traces but structured JSON
Copilot compensates withairtight exhaustive task descriptions + sequential TDD buildruntime platform does the heavy lifting