@lvlup-sw/exarchos 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/.claude-plugin/marketplace.json +22 -0
  2. package/.claude-plugin/plugin.json +17 -0
  3. package/.mcp.json +17 -0
  4. package/AGENTS.md +59 -0
  5. package/CLAUDE.md.template +62 -0
  6. package/LICENSE +202 -0
  7. package/README.md +258 -0
  8. package/commands/autocompact.md +37 -0
  9. package/commands/checkpoint.md +85 -0
  10. package/commands/cleanup.md +99 -0
  11. package/commands/debug.md +145 -0
  12. package/commands/delegate.md +56 -0
  13. package/commands/ideate.md +82 -0
  14. package/commands/plan.md +150 -0
  15. package/commands/refactor.md +139 -0
  16. package/commands/reload.md +37 -0
  17. package/commands/resume.md +130 -0
  18. package/commands/review.md +51 -0
  19. package/commands/sync-schemas.md +74 -0
  20. package/commands/synthesize.md +122 -0
  21. package/commands/tdd.md +58 -0
  22. package/dist/exarchos-cli.js +8828 -0
  23. package/dist/exarchos-mcp.js +50 -0
  24. package/hooks/hooks.json +53 -0
  25. package/package.json +59 -0
  26. package/rules/coding-standards.md +46 -0
  27. package/rules/mcp-tool-guidance.md +26 -0
  28. package/rules/pr-descriptions.md +12 -0
  29. package/rules/rm-safety.md +9 -0
  30. package/rules/skill-path-resolution.md +10 -0
  31. package/rules/tdd.md +41 -0
  32. package/rules/telemetry-awareness.md +9 -0
  33. package/scripts/assess-refactor-scope.sh +239 -0
  34. package/scripts/check-benchmark-regression.sh +229 -0
  35. package/scripts/check-coderabbit.sh +288 -0
  36. package/scripts/check-coverage-thresholds.sh +194 -0
  37. package/scripts/check-polish-scope.sh +245 -0
  38. package/scripts/check-property-tests.sh +167 -0
  39. package/scripts/check-tdd-compliance.sh +265 -0
  40. package/scripts/coderabbit-review-gate.sh +518 -0
  41. package/scripts/debug-review-gate.sh +201 -0
  42. package/scripts/extract-fix-tasks.sh +179 -0
  43. package/scripts/extract-task.sh +67 -0
  44. package/scripts/generate-traceability.sh +209 -0
  45. package/scripts/investigation-timer.sh +171 -0
  46. package/scripts/needs-schema-sync.sh +174 -0
  47. package/scripts/new-project.sh +103 -0
  48. package/scripts/post-delegation-check.sh +317 -0
  49. package/scripts/pre-synthesis-check.sh +440 -0
  50. package/scripts/reconcile-state.sh +346 -0
  51. package/scripts/reconstruct-stack.sh +432 -0
  52. package/scripts/review-diff.sh +63 -0
  53. package/scripts/review-verdict.sh +169 -0
  54. package/scripts/security-scan.sh +248 -0
  55. package/scripts/select-debug-track.sh +186 -0
  56. package/scripts/setup-worktree.sh +323 -0
  57. package/scripts/spec-coverage-check.sh +230 -0
  58. package/scripts/static-analysis-gate.sh +236 -0
  59. package/scripts/sync-labels.sh +122 -0
  60. package/scripts/validate-companion.sh +161 -0
  61. package/scripts/validate-dotnet-standards.sh +267 -0
  62. package/scripts/validate-installation.sh +101 -0
  63. package/scripts/validate-plugin.sh +223 -0
  64. package/scripts/validate-refactor.sh +234 -0
  65. package/scripts/validate-rm.sh +93 -0
  66. package/scripts/verify-delegation-saga.sh +240 -0
  67. package/scripts/verify-doc-links.sh +211 -0
  68. package/scripts/verify-ideate-artifacts.sh +296 -0
  69. package/scripts/verify-plan-coverage.sh +228 -0
  70. package/scripts/verify-review-triage.sh +219 -0
  71. package/scripts/verify-worktree-baseline.sh +159 -0
  72. package/scripts/verify-worktree.sh +84 -0
  73. package/settings.json +47 -0
  74. package/skills/brainstorming/SKILL.md +127 -0
  75. package/skills/brainstorming/references/design-template.md +65 -0
  76. package/skills/cleanup/SKILL.md +147 -0
  77. package/skills/cleanup/references/merge-verification.md +40 -0
  78. package/skills/debug/SKILL.md +204 -0
  79. package/skills/debug/references/hotfix-track.md +134 -0
  80. package/skills/debug/references/investigation-checklist.md +217 -0
  81. package/skills/debug/references/rca-template.md +150 -0
  82. package/skills/debug/references/state-schema.md +294 -0
  83. package/skills/debug/references/thorough-track.md +194 -0
  84. package/skills/debug/references/triage-questions.md +155 -0
  85. package/skills/debug/references/troubleshooting.md +47 -0
  86. package/skills/delegation/SKILL.md +150 -0
  87. package/skills/delegation/references/adaptive-orchestration.md +31 -0
  88. package/skills/delegation/references/agent-teams-saga.md +248 -0
  89. package/skills/delegation/references/fix-mode.md +74 -0
  90. package/skills/delegation/references/fixer-prompt.md +162 -0
  91. package/skills/delegation/references/implementer-prompt.md +322 -0
  92. package/skills/delegation/references/parallel-strategy.md +124 -0
  93. package/skills/delegation/references/pbt-patterns.md +172 -0
  94. package/skills/delegation/references/pr-fixes-mode.md +154 -0
  95. package/skills/delegation/references/state-management.md +51 -0
  96. package/skills/delegation/references/testing-patterns.md +129 -0
  97. package/skills/delegation/references/troubleshooting.md +33 -0
  98. package/skills/delegation/references/workflow-steps.md +127 -0
  99. package/skills/delegation/references/worktree-enforcement.md +64 -0
  100. package/skills/dotnet-standards/SKILL.md +269 -0
  101. package/skills/dotnet-standards/references/csharp-standards.md +120 -0
  102. package/skills/dotnet-standards/templates/.editorconfig +366 -0
  103. package/skills/dotnet-standards/templates/Directory.Build.props +56 -0
  104. package/skills/dotnet-standards/templates/Directory.Packages.props +69 -0
  105. package/skills/dotnet-standards/templates/global.json +6 -0
  106. package/skills/dotnet-standards/templates/nuget.config +9 -0
  107. package/skills/dotnet-standards/templates/stylecop.json +37 -0
  108. package/skills/git-worktrees/SKILL.md +255 -0
  109. package/skills/implementation-planning/SKILL.md +233 -0
  110. package/skills/implementation-planning/references/plan-document-template.md +42 -0
  111. package/skills/implementation-planning/references/spec-tracing-guide.md +51 -0
  112. package/skills/implementation-planning/references/task-template.md +43 -0
  113. package/skills/implementation-planning/references/testing-strategy-guide.md +88 -0
  114. package/skills/quality-review/SKILL.md +278 -0
  115. package/skills/quality-review/references/code-quality-checklist.md +159 -0
  116. package/skills/quality-review/references/review-report-template.md +65 -0
  117. package/skills/quality-review/references/security-checklist.md +79 -0
  118. package/skills/quality-review/references/typescript-standards.md +24 -0
  119. package/skills/refactor/COMMAND.md +67 -0
  120. package/skills/refactor/SKILL.md +198 -0
  121. package/skills/refactor/phases/auto-chain.md +262 -0
  122. package/skills/refactor/phases/brief.md +176 -0
  123. package/skills/refactor/phases/explore.md +132 -0
  124. package/skills/refactor/phases/overhaul-delegate.md +136 -0
  125. package/skills/refactor/phases/overhaul-plan.md +312 -0
  126. package/skills/refactor/phases/overhaul-review.md +304 -0
  127. package/skills/refactor/phases/polish-implement.md +349 -0
  128. package/skills/refactor/phases/polish-validate.md +218 -0
  129. package/skills/refactor/phases/update-docs.md +234 -0
  130. package/skills/refactor/references/brief-template.md +81 -0
  131. package/skills/refactor/references/doc-update-checklist.md +110 -0
  132. package/skills/refactor/references/explore-checklist.md +73 -0
  133. package/skills/refactor/references/overhaul-track.md +215 -0
  134. package/skills/refactor/references/polish-track.md +170 -0
  135. package/skills/shared/prompts/context-reading.md +58 -0
  136. package/skills/shared/prompts/report-format.md +54 -0
  137. package/skills/shared/prompts/tdd-requirements.md +39 -0
  138. package/skills/shepherd/SKILL.md +264 -0
  139. package/skills/shepherd/references/assess-checklist.md +124 -0
  140. package/skills/shepherd/references/fix-strategies.md +191 -0
  141. package/skills/spec-review/SKILL.md +229 -0
  142. package/skills/spec-review/references/review-checklist.md +60 -0
  143. package/skills/sync-schemas/SKILL.md +114 -0
  144. package/skills/sync-schemas/references/configuration.md +73 -0
  145. package/skills/synthesis/SKILL.md +129 -0
  146. package/skills/synthesis/references/pr-descriptions.md +87 -0
  147. package/skills/synthesis/references/synthesis-steps.md +109 -0
  148. package/skills/synthesis/references/troubleshooting.md +115 -0
  149. package/skills/validate-all-skills.sh +57 -0
  150. package/skills/validate-frontmatter.sh +237 -0
  151. package/skills/workflow-state/SKILL.md +210 -0
  152. package/skills/workflow-state/references/mcp-tool-reference.md +111 -0
  153. package/skills/workflow-state/references/phase-transitions.md +141 -0
@@ -0,0 +1,154 @@
1
+ # PR Feedback Mode (--pr-fixes)
2
+
3
+ When invoked with `--pr-fixes [PR_URL]`, delegation addresses human review feedback from a pull request instead of implementing from a plan.
4
+
5
+ ## Priority Levels
6
+
7
+ | Priority | Source | Description |
8
+ |----------|--------|-------------|
9
+ | 1 | `coderabbit:critical` | Critical issues + SPEC COMPLIANCE failures |
10
+ | 2 | `human` | Human reviewer comments (authority over automation) |
11
+ | 3 | `coderabbit:major` | Major issues + CODE QUALITY HIGH items |
12
+ | 4 | `coderabbit:minor` | Minor issues |
13
+
14
+ ## Process
15
+
16
+ ### Step 1: Fetch All PR Feedback
17
+
18
+ ```bash
19
+ # Get full PR details including reviews and comments
20
+ gh pr view <number> --json title,body,state,files,reviewDecision,reviews,comments
21
+
22
+ # Get issue-level comments (pre-merge check summaries)
23
+ gh issue view <number> --json comments
24
+ ```
25
+
26
+ > Or use GitHub MCP `pull_request_read` and `issue_read` if available.
27
+
28
+ ### Step 2: Parse CodeRabbit Feedback
29
+
30
+ **2a: Identify CodeRabbit comments** by author = `coderabbitai[bot]`
31
+
32
+ **2b: Parse line comments by severity label:**
33
+
34
+ | Label | Priority |
35
+ |-------|----------|
36
+ | `Critical` | 1 |
37
+ | `Major` | 2 |
38
+ | `Minor` | 3 |
39
+
40
+ Extract from each comment:
41
+ - Severity label (emoji + text)
42
+ - File path and line number
43
+ - Issue description
44
+ - Suggested fix (from Proposed fix section if present)
45
+
46
+ **2c: Parse pre-merge check summaries:**
47
+ - `Status: FAIL` in Spec Review -> Priority 1
48
+ - `Status: NEEDS_FIXES | BLOCKED` in Quality Review -> Priority 2
49
+ - Extract items from `Missing:`, `Untested:`, `Scope Creep:` lists
50
+
51
+ **2d: Parse reviews with `CHANGES_REQUESTED`:**
52
+ - Note "Actionable comments posted: N" count
53
+ - Cross-reference with line comments already parsed
54
+
55
+ ### Step 3: Parse Human Comments (Priority 2)
56
+
57
+ For non-CodeRabbit comments, assign `priority: 2` (human authority over automation).
58
+
59
+ Skip comments that are:
60
+ - Purely praise/acknowledgment ("LGTM", "Nice work")
61
+ - Questions without action items
62
+ - Already marked resolved
63
+ - From other bots (CI notifications, etc.)
64
+
65
+ ### Step 4: Create Fix Tasks
66
+
67
+ For each actionable item, create a structured fix task:
68
+
69
+ | Field | Description |
70
+ |-------|-------------|
71
+ | `id` | `fix-001`, `fix-002`, etc. |
72
+ | `priority` | `1` (critical), `2` (human), `3` (major), `4` (minor) |
73
+ | `source` | `"coderabbit:critical"`, `"human"`, `"coderabbit:major"`, `"coderabbit:minor"` |
74
+ | `severity` | `"Critical"`, `"Major"`, `"Minor"`, or null |
75
+ | `file` | File path |
76
+ | `line` | Line number (if line comment) |
77
+ | `issue` | Problem description |
78
+ | `action` | Required change / suggested fix |
79
+
80
+ ### Step 5: Sort and Display Fix Tasks
81
+
82
+ Sort by priority (1->4), then by file path for grouping.
83
+
84
+ ### Step 6: Track Fix Tasks
85
+
86
+ Use TodoWrite to track all fix tasks with priority labels.
87
+
88
+ ### Step 7: Dispatch Fixes (MANDATORY - Priority Order)
89
+
90
+ **Dispatch sequence:**
91
+ 1. Dispatch all P1 (critical) fixes in parallel
92
+ 2. Wait for completion
93
+ 3. Dispatch all P2 (human) fixes in parallel
94
+ 4. Wait for completion
95
+ 5. Dispatch all P3 (major) fixes in parallel
96
+ 6. Wait for completion
97
+ 7. Dispatch all P4 (minor) fixes in parallel
98
+ 8. Wait for completion
99
+
100
+ **Task prompt template:**
101
+ ```typescript
102
+ Task({
103
+ subagent_type: "general-purpose",
104
+ model: "opus",
105
+ description: "Fix [P{priority} {severity}]: {issue summary}",
106
+ prompt: `
107
+ # Task: Fix PR Feedback - {issue summary}
108
+
109
+ ## Priority
110
+ {priority} - {source}
111
+
112
+ ## Context
113
+ PR: {PR_URL}
114
+ Source: {source}
115
+ Original feedback: "{original comment text}"
116
+
117
+ ## Working Directory
118
+ {absolute path to repo}
119
+
120
+ ## Fix Required
121
+ File: {file path}
122
+ Line: {line number if applicable}
123
+ Issue: {issue description}
124
+ Action: {required change}
125
+
126
+ ## TDD Requirements
127
+ 1. Write a test that would catch this issue (if applicable)
128
+ 2. Verify test fails
129
+ 3. Implement the fix
130
+ 4. Verify test passes
131
+
132
+ ## Success Criteria
133
+ - [ ] Issue addressed per feedback
134
+ - [ ] Tests pass
135
+ - [ ] No regressions introduced
136
+ `
137
+ })
138
+ ```
139
+
140
+ **CHECKPOINT:** Do NOT proceed to next priority level until all fixes in the current level have completed.
141
+
142
+ ### Step 8: Push and Report
143
+
144
+ After all fixes complete, use Graphite to commit and push:
145
+ ```bash
146
+ gt modify -m "fix: address PR review feedback"
147
+ gt submit --no-interactive
148
+ ```
149
+
150
+ Report to user: total fixes by priority, files modified. Then auto-chain to `/exarchos:synthesize` for merge confirmation.
151
+
152
+ ### Handling Missing CodeRabbit Comments
153
+
154
+ If no CodeRabbit comments found, proceed with human comments only.
@@ -0,0 +1,51 @@
1
+ # Delegation State Management
2
+
3
+ State update patterns for workflow state during delegation. Use `mcp__exarchos__exarchos_workflow` for all mutations.
4
+
5
+ ## Read Tasks from State
6
+
7
+ Instead of re-parsing plan, read task list with `action: "get"`, `query: "tasks"`. For status checks during monitoring, use `fields: ["tasks"]` to reduce response size.
8
+
9
+ ## Subagent Mode
10
+
11
+ **On Task Dispatch:**
12
+ ```
13
+ action: "set", featureId: "<id>", updates: {
14
+ "tasks[id=<taskId>]": { "status": "in_progress", "startedAt": "<ISO timestamp>" },
15
+ "worktrees.<wt-id>": { "branch": "<branch>", "taskId": "<taskId>", "status": "active" }
16
+ }
17
+ ```
18
+
19
+ **On Task Complete:**
20
+ ```
21
+ action: "set", featureId: "<id>", updates: {
22
+ "tasks[id=<taskId>]": { "status": "complete", "completedAt": "<ISO timestamp>" }
23
+ }
24
+ ```
25
+
26
+ **On All Tasks Complete:**
27
+ ```
28
+ action: "set", featureId: "<id>", phase: "review"
29
+ ```
30
+
31
+ ## Agent Team Mode (Single-Writer)
32
+
33
+ Only the orchestrator mutates `workflow.tasks[]` via `exarchos_workflow set`. Hooks emit events but never mutate state directly.
34
+
35
+ - **Step 2:** Store `nativeTaskId` from each `TaskCreate` return value
36
+ - **Step 4:** Read `team.task.completed` events during monitoring, update task status
37
+ - **Staleness:** 30-60s projection lag is acceptable — native task dependency unblocking is automatic
38
+
39
+ For the three-layer consistency model, drift recovery, and eventual consistency details, see `agent-teams-saga.md`.
40
+
41
+ ## Benchmark Label
42
+
43
+ After extracting tasks from the plan, check if ANY task has `testingStrategy.benchmarks: true`. If so, record in state:
44
+
45
+ ```
46
+ action: "set", featureId: "<id>", updates: {
47
+ "verification.hasBenchmarks": true
48
+ }
49
+ ```
50
+
51
+ The `/synthesize` skill reads `verification.hasBenchmarks` and applies the `has-benchmarks` label via `gh pr edit <number> --add-label has-benchmarks`.
@@ -0,0 +1,129 @@
1
+ # Testing Patterns
2
+
3
+ Code patterns for TDD implementation. Referenced from `rules/tdd.md`.
4
+
5
+ ## TypeScript (Vitest)
6
+
7
+ ```typescript
8
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
9
+ ```
10
+
11
+ ### Test Pattern
12
+
13
+ ```typescript
14
+ describe('ComponentName', () => {
15
+ describe('methodName', () => {
16
+ it('should do expected behavior when condition', async () => {
17
+ // Arrange
18
+ const input = createTestData();
19
+
20
+ // Act
21
+ const result = await component.method(input);
22
+
23
+ // Assert
24
+ expect(result).toBe(expected);
25
+ });
26
+ });
27
+ });
28
+ ```
29
+
30
+ ### Mocking
31
+
32
+ ```typescript
33
+ vi.mock('./dependency', () => ({ someFn: vi.fn() }));
34
+ fetchMock.mockResponseOnce(JSON.stringify({ data: 'value' }));
35
+ expect(mockFn).toHaveBeenCalledWith(expectedArgs);
36
+ ```
37
+
38
+ ## C# (TUnit)
39
+
40
+ All tests MUST use `[Test]` attribute, be `async Task`, and await all assertions.
41
+
42
+ ### Test Pattern
43
+
44
+ ```csharp
45
+ [Test]
46
+ public async Task MethodName_Scenario_ExpectedOutcome()
47
+ {
48
+ // Arrange
49
+ var mockRepo = Substitute.For<IRepository>();
50
+ mockRepo.FindAsync(Arg.Any<Guid>()).Returns(expectedOrder);
51
+ var sut = new OrderService(mockRepo);
52
+
53
+ // Act
54
+ var result = await sut.GetOrderAsync(orderId);
55
+
56
+ // Assert (MUST await)
57
+ await Assert.That(result.IsSuccess).IsTrue();
58
+ await Assert.That(result.Value.Id).IsEqualTo(orderId);
59
+ }
60
+ ```
61
+
62
+ ### Assertions
63
+
64
+ ```csharp
65
+ await Assert.That(actual).IsEqualTo(expected);
66
+ await Assert.That(condition).IsTrue();
67
+ await Assert.That(value).IsNotNull();
68
+ await Assert.That(collection).Contains(item);
69
+ await Assert.That(collection).HasCount(3);
70
+ await Assert.That(() => sut.Method()).Throws<ArgumentException>();
71
+ ```
72
+
73
+ ### Parameterized Tests
74
+
75
+ ```csharp
76
+ [Test]
77
+ [Arguments(2, 3, 5)]
78
+ [Arguments(0, 0, 0)]
79
+ public async Task Add_VariousInputs_ReturnsExpectedSum(int a, int b, int expected)
80
+ {
81
+ var result = _calculator.Add(a, b);
82
+ await Assert.That(result).IsEqualTo(expected);
83
+ }
84
+ ```
85
+
86
+ ### Setup/Cleanup
87
+
88
+ ```csharp
89
+ [Before(Test)]
90
+ public async Task Setup() { _service = new Service(); }
91
+
92
+ [After(Test)]
93
+ public async Task Cleanup() { /* dispose */ }
94
+ ```
95
+
96
+ ### Mocking (NSubstitute)
97
+
98
+ ```csharp
99
+ var mock = Substitute.For<IOrderService>();
100
+ mock.GetOrderAsync(Arg.Any<Guid>()).Returns(Result<Order>.Success(order));
101
+ await mock.Received(1).GetOrderAsync(expectedId);
102
+ await mock.DidNotReceive().DeleteAsync(Arg.Any<Guid>());
103
+ ```
104
+
105
+ ## Property-Based Testing (fast-check)
106
+
107
+ ### When to Use
108
+
109
+ - Data transformations (encode/decode, serialize/deserialize) -> Roundtrip
110
+ - State machines (transitions, guards) -> Invariant
111
+ - Collections/ordering (sort, filter, pagination) -> Idempotence
112
+ - Mathematical operations (scoring, budgets) -> Bounds/constraints
113
+ - Concurrency (optimistic locking) -> Linearizability
114
+
115
+ ### Import
116
+
117
+ ```typescript
118
+ import { it, fc } from '@fast-check/vitest';
119
+ ```
120
+
121
+ ### Basic Usage
122
+
123
+ ```typescript
124
+ it.prop([fc.array(fc.integer())], (arr) => {
125
+ expect(sort(sort(arr))).toEqual(sort(arr));
126
+ });
127
+ ```
128
+
129
+ See `pbt-patterns.md` for roundtrip, invariant, idempotence, and commutativity pattern templates.
@@ -0,0 +1,33 @@
1
+ # Delegation Troubleshooting
2
+
3
+ ## MCP Tool Call Failed
4
+ If an Exarchos MCP tool returns an error:
5
+ 1. Check the error message — it usually contains specific guidance
6
+ 2. Verify the workflow state exists: call `exarchos_workflow` with `action: "get"` and the featureId
7
+ 3. If "version mismatch": another process updated state — retry the operation
8
+ 4. If state is corrupted: call `exarchos_workflow` with `action: "cancel"` and `dryRun: true`
9
+
10
+ ## State Desync
11
+ If workflow state doesn't match git reality:
12
+ 1. The SessionStart hook runs reconciliation automatically on resume
13
+ 2. If manual check needed: compare state file with `git log` and branch state
14
+ 3. Update state via `exarchos_workflow` with `action: "set"` to match git truth
15
+
16
+ ## Worktree Creation Failed
17
+ If `git worktree add` fails:
18
+ 1. Check if the branch already exists: `git branch --list <branch-name>`
19
+ 2. Check if a worktree already exists at the path: `git worktree list`
20
+ 3. If stale worktree: `git worktree prune` then retry
21
+ 4. If branch conflict: use a unique branch name
22
+
23
+ ## Subagent Not Responding
24
+ If a spawned subagent doesn't respond:
25
+ 1. Check task output: use `TaskOutput` with the agent's task ID and `block: false`
26
+ 2. If the subagent is stuck: stop it with `TaskStop` and re-dispatch
27
+ 3. For Agent Teams: use Claude Code's native teammate messaging (Shift+Up/Down to select, then type)
28
+
29
+ ## Task Claim Conflict
30
+ If `exarchos_orchestrate` with `action: "task_claim"` returns ALREADY_CLAIMED:
31
+ 1. Another agent already claimed this task — skip it
32
+ 2. Check task status via `exarchos_view` with `action: "tasks"` and `filter: { "taskId": "<id>" }`
33
+ 3. Do not re-dispatch — the other agent is handling it
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: workflow-steps
3
+ ---
4
+
5
+ # Delegation Workflow Steps
6
+
7
+ ## Step 1: Prepare Environment
8
+
9
+ For parallel tasks, create worktrees:
10
+ ```bash
11
+ git worktree add .worktrees/task-001 feature/task-001
12
+ cd .worktrees/task-001 && npm install
13
+ ```
14
+
15
+ ## Step 2: Extract Task Details
16
+
17
+ From implementation plan, extract for each task:
18
+ - Full task description
19
+ - Files to create/modify
20
+ - Test file paths
21
+ - Expected test names
22
+ - Dependencies
23
+
24
+ ## Step 3: Create TodoWrite Entries
25
+
26
+ Track all delegated tasks:
27
+ ```typescript
28
+ TodoWrite({
29
+ todos: [
30
+ { content: "Task 001: User model", status: "in_progress", activeForm: "Implementing user model" },
31
+ { content: "Task 002: Auth endpoints", status: "pending", activeForm: "Implementing auth endpoints" }
32
+ ]
33
+ })
34
+ ```
35
+
36
+ ## Step 4: Dispatch Implementers
37
+
38
+ **Parallel dispatch:**
39
+ ```typescript
40
+ // Launch multiple in single message for parallel execution
41
+ Task({
42
+ subagent_type: "general-purpose",
43
+ model: "opus",
44
+ run_in_background: true,
45
+ description: "Implement task 001",
46
+ prompt: "[Full implementer prompt]"
47
+ })
48
+
49
+ Task({
50
+ subagent_type: "general-purpose",
51
+ model: "opus",
52
+ run_in_background: true,
53
+ description: "Implement task 002",
54
+ prompt: "[Full implementer prompt]"
55
+ })
56
+ ```
57
+
58
+ ### Agent Teams Dispatch (enhanced)
59
+
60
+ When using `--mode agent-team`:
61
+ 1. **Pre-delegation intelligence:** Query `exarchos_view team_performance` for historical metrics
62
+ 2. **Team creation:** Create team with named teammates, each assigned to a worktree
63
+ 3. **Task list setup:** Create native Claude Code tasks with dependency annotations
64
+ 4. **Natural language delegation:** Describe tasks to teammates with full implementer prompt content
65
+ 5. **Event emission:** Append `team.spawned` event with teamSize, teammateNames, taskCount
66
+
67
+ Teammates self-coordinate via shared task list. No `Task()` calls needed.
68
+
69
+ ## Step 5: Monitor Progress
70
+
71
+ For background tasks:
72
+ ```typescript
73
+ TaskOutput({ task_id: "task-001-id", block: true })
74
+ ```
75
+
76
+ ### Agent Teams Monitoring (enhanced)
77
+
78
+ When using `--mode agent-team`:
79
+ - Teammates visible in tmux split panes
80
+ - `TeammateIdle` hook auto-runs quality gates (typecheck, tests, clean worktree)
81
+ - On quality pass: emits `team.task.completed` event with performance data
82
+ - On quality fail: exit code 2 sends feedback, emits `team.task.failed` event
83
+ - Hook scans task graph for newly unblocked tasks for teammates to claim
84
+ - Orchestrator monitors via `exarchos_view delegation_timeline` for bottleneck detection
85
+
86
+ ## Step 6: Collect Results
87
+
88
+ When tasks complete, run the post-delegation check:
89
+
90
+ ```bash
91
+ bash scripts/post-delegation-check.sh \
92
+ --state-file <path-to-state.json> \
93
+ --repo-root <project-root> \
94
+ [--skip-tests]
95
+ ```
96
+
97
+ **Validates:**
98
+ - State file exists and is valid JSON
99
+ - Tasks array has entries
100
+ - All tasks report "complete" status
101
+ - Per-worktree test runs pass (unless `--skip-tests`)
102
+ - State file consistency (all tasks have id and status fields)
103
+
104
+ **On exit 0:** All delegation results collected and verified. Update TodoWrite status, then check if schema sync is needed (Step 7) and proceed to review phase.
105
+
106
+ **On exit 1:** Failures detected. Review the per-task status report. Address incomplete tasks or failing tests before proceeding.
107
+
108
+ ### Agent Teams Collection (enhanced)
109
+
110
+ When using `--mode agent-team`:
111
+ - `TeammateIdle` hook bridges real-time Agent Teams with persistent Exarchos state
112
+ - On quality gate pass: task marked "complete" + `team.task.completed` event emitted
113
+ - On quality gate fail: exit code 2 sends feedback + `team.task.failed` event emitted
114
+ - Rich event data: taskId, teammateName, durationMs, filesChanged, testsPassed
115
+ - After all teammates finish: append `team.disbanded` event with summary metrics
116
+ - Run `post-delegation-check.sh` as usual for final validation
117
+
118
+ ## Step 7: Schema Sync (Auto-Detection)
119
+
120
+ After all tasks complete, check if API files were modified:
121
+
122
+ ```bash
123
+ bash scripts/needs-schema-sync.sh --repo-root <path> [--base-branch main]
124
+ ```
125
+
126
+ **On exit 0:** No sync needed — proceed to review.
127
+ **On exit 1:** Sync needed — API files modified (`*Endpoints.cs`, `Models/*.cs`, `Requests/*.cs`, `Responses/*.cs`, `Dtos/*.cs`). Run `npm run sync:schemas` and commit via Graphite before proceeding. See `@skills/sync-schemas/SKILL.md`.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: worktree-enforcement
3
+ ---
4
+
5
+ # Worktree Enforcement (MANDATORY)
6
+
7
+ All implementation tasks MUST run in isolated worktrees, not the main project root.
8
+
9
+ ## Why Worktrees Are Required
10
+
11
+ - **Isolation:** Prevents merge conflicts between parallel tasks
12
+ - **Safety:** Protects main project state
13
+ - **Parallelism:** Enables multiple subagents to work simultaneously
14
+ - **Recovery:** Easy rollback via branch deletion
15
+
16
+ ## Pre-Dispatch Checklist
17
+
18
+ Before dispatching ANY implementer, run the worktree setup script:
19
+
20
+ ```bash
21
+ bash scripts/setup-worktree.sh \
22
+ --repo-root <project-root> \
23
+ --task-id <task-id> \
24
+ --task-name <task-name> \
25
+ [--base-branch main] \
26
+ [--skip-tests]
27
+ ```
28
+
29
+ **Validates:**
30
+ - `.worktrees/` is gitignored (adds to `.gitignore` if missing)
31
+ - Feature branch created (`feature/<task-id>-<task-name>` from base branch)
32
+ - Git worktree added at `.worktrees/<task-id>-<task-name>`
33
+ - `npm install` ran in worktree
34
+ - Baseline tests pass in worktree
35
+
36
+ **On exit 0:** Worktree is ready. Proceed with implementer dispatch.
37
+
38
+ **On exit 1:** Setup failed. Review the markdown checklist output for which step failed. Fix the issue before dispatching.
39
+
40
+ **On exit 2:** Usage error. Check required arguments: `--repo-root`, `--task-id`, `--task-name`.
41
+
42
+ ## Worktree State Tracking
43
+
44
+ Track worktrees in the workflow state file using `mcp__exarchos__exarchos_workflow` with `action: "set"`:
45
+ - Set `worktrees.<worktree-id>` to an object containing `branch`, `status`, and either `taskId` (single task) or `tasks` (array of task IDs for multi-task worktrees)
46
+
47
+ ## Implementer Prompt Requirements
48
+
49
+ Include in ALL implementer prompts:
50
+
51
+ 1. **Absolute worktree path** as Working Directory
52
+ 2. **Worktree verification block** (from implementer-prompt.md template)
53
+ 3. **Abort instructions** if not in worktree
54
+
55
+ ## Anti-Patterns
56
+
57
+ | Don't | Do Instead |
58
+ |-------|------------|
59
+ | Make subagents read plan files | Provide full task text in prompt |
60
+ | Use default model for coding | Specify `model: "opus"` |
61
+ | Send sequential Task calls | Batch parallel tasks in one message |
62
+ | Skip worktree for parallel work | Create isolated worktrees |
63
+ | Forget to track in TodoWrite | Update status for every task |
64
+ | Skip TDD requirements | Include TDD instructions in prompt |