pi-orchestrator-config 4.1.5

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 (175) hide show
  1. package/README.md +808 -0
  2. package/agents/api-documenter.md +32 -0
  3. package/agents/bash-expert.md +53 -0
  4. package/agents/code-reviewer-docs.md +145 -0
  5. package/agents/code-reviewer-guidelines.md +97 -0
  6. package/agents/code-reviewer-quality.md +142 -0
  7. package/agents/code-reviewer-security.md +107 -0
  8. package/agents/code-reviewer-spec.md +164 -0
  9. package/agents/debugger.md +63 -0
  10. package/agents/docker-expert.md +40 -0
  11. package/agents/docs-fetcher.md +48 -0
  12. package/agents/git-expert.md +63 -0
  13. package/agents/github-expert.md +83 -0
  14. package/agents/go-expert.md +62 -0
  15. package/agents/issue-reviewer-feasibility.md +60 -0
  16. package/agents/issue-reviewer-scope.md +63 -0
  17. package/agents/issue-reviewer-spec.md +77 -0
  18. package/agents/java-expert.md +31 -0
  19. package/agents/jenkins-expert.md +38 -0
  20. package/agents/kubernetes-expert.md +40 -0
  21. package/agents/planner.md +42 -0
  22. package/agents/python-expert.md +61 -0
  23. package/agents/reviewer.md +26 -0
  24. package/agents/scout.md +40 -0
  25. package/agents/security-auditor.md +254 -0
  26. package/agents/technical-documentation-writer.md +37 -0
  27. package/agents/test-automator.md +55 -0
  28. package/agents/test-runner.md +47 -0
  29. package/agents/ts-expert.md +23 -0
  30. package/agents/worker.md +30 -0
  31. package/extensions/acpx-provider/index.ts +104 -0
  32. package/extensions/acpx-provider/load-runtime.ts +99 -0
  33. package/extensions/acpx-provider/runtime-models.ts +40 -0
  34. package/extensions/cli-provider/agents/claude.ts +128 -0
  35. package/extensions/cli-provider/agents/cursor.ts +84 -0
  36. package/extensions/cli-provider/agents/gemini.ts +100 -0
  37. package/extensions/cli-provider/discover.ts +77 -0
  38. package/extensions/cli-provider/index.ts +57 -0
  39. package/extensions/cli-provider/parsers.ts +304 -0
  40. package/extensions/cli-provider/providers.ts +58 -0
  41. package/extensions/cli-provider/runner.ts +225 -0
  42. package/extensions/cli-provider/runtime-models.ts +32 -0
  43. package/extensions/cli-provider/session-reaper.ts +122 -0
  44. package/extensions/cli-provider/sessions.ts +533 -0
  45. package/extensions/cli-provider/shared/discover-cache.ts +235 -0
  46. package/extensions/cli-provider/types.ts +48 -0
  47. package/extensions/coms/coms-net-server.ts +1642 -0
  48. package/extensions/coms/coms-net-wrapper.ts +521 -0
  49. package/extensions/coms/coms-net.ts +1589 -0
  50. package/extensions/coms/coms-p2p.ts +1879 -0
  51. package/extensions/coms/coms-shared.ts +510 -0
  52. package/extensions/coms/coms-wrapper.ts +138 -0
  53. package/extensions/coms/index.ts +20 -0
  54. package/extensions/coms/themeMap.ts +147 -0
  55. package/extensions/image-gen/image-gen.ts +332 -0
  56. package/extensions/image-gen/index.ts +14 -0
  57. package/extensions/orchestrator/agents.ts +134 -0
  58. package/extensions/orchestrator/ask-user.ts +293 -0
  59. package/extensions/orchestrator/async-agents.ts +1037 -0
  60. package/extensions/orchestrator/async-capability.ts +129 -0
  61. package/extensions/orchestrator/async-runner.ts +324 -0
  62. package/extensions/orchestrator/async-status-parse.ts +31 -0
  63. package/extensions/orchestrator/async-status-ui.ts +201 -0
  64. package/extensions/orchestrator/async-wait.ts +36 -0
  65. package/extensions/orchestrator/btw.ts +210 -0
  66. package/extensions/orchestrator/cron-status-format.ts +126 -0
  67. package/extensions/orchestrator/cron-status-ui.ts +132 -0
  68. package/extensions/orchestrator/cron.ts +730 -0
  69. package/extensions/orchestrator/dreaming.ts +355 -0
  70. package/extensions/orchestrator/enforcement-helpers.ts +530 -0
  71. package/extensions/orchestrator/enforcement-rules.ts +329 -0
  72. package/extensions/orchestrator/enforcement.ts +828 -0
  73. package/extensions/orchestrator/extended-autocomplete.ts +593 -0
  74. package/extensions/orchestrator/git-helpers.ts +420 -0
  75. package/extensions/orchestrator/github-autocomplete.ts +250 -0
  76. package/extensions/orchestrator/icons.ts +17 -0
  77. package/extensions/orchestrator/index.ts +100 -0
  78. package/extensions/orchestrator/memory-embeddings.ts +281 -0
  79. package/extensions/orchestrator/memory-promotion.ts +449 -0
  80. package/extensions/orchestrator/memory-provenance.ts +80 -0
  81. package/extensions/orchestrator/memory-query-class.ts +90 -0
  82. package/extensions/orchestrator/memory-scoring.ts +434 -0
  83. package/extensions/orchestrator/memory-tools.ts +883 -0
  84. package/extensions/orchestrator/memory-tree.ts +212 -0
  85. package/extensions/orchestrator/nvim.ts +169 -0
  86. package/extensions/orchestrator/overlay-dashboard-utils.ts +25 -0
  87. package/extensions/orchestrator/overlay-dashboard.ts +512 -0
  88. package/extensions/orchestrator/pi-config-review-state.ts +303 -0
  89. package/extensions/orchestrator/preference-extractor.ts +106 -0
  90. package/extensions/orchestrator/project-settings.ts +468 -0
  91. package/extensions/orchestrator/promotion-queue.ts +311 -0
  92. package/extensions/orchestrator/resolve-agent-model.ts +32 -0
  93. package/extensions/orchestrator/review-ui.ts +204 -0
  94. package/extensions/orchestrator/rule-placeholders.ts +12 -0
  95. package/extensions/orchestrator/rules.ts +481 -0
  96. package/extensions/orchestrator/session-search.ts +243 -0
  97. package/extensions/orchestrator/session-validation.ts +374 -0
  98. package/extensions/orchestrator/situation-report.ts +370 -0
  99. package/extensions/orchestrator/status-bar.ts +31 -0
  100. package/extensions/orchestrator/status-line.ts +192 -0
  101. package/extensions/orchestrator/status.ts +110 -0
  102. package/extensions/orchestrator/subagent-tool.ts +1748 -0
  103. package/extensions/orchestrator/task-lifecycle.ts +88 -0
  104. package/extensions/orchestrator/utils.ts +227 -0
  105. package/extensions/pidash/index.ts +15 -0
  106. package/extensions/pidash/pidash.ts +941 -0
  107. package/extensions/pidiff/index.ts +13 -0
  108. package/extensions/pidiff/pidiff.ts +369 -0
  109. package/extensions/providers/acpx-driver.ts +479 -0
  110. package/extensions/providers/built-in-drivers.ts +52 -0
  111. package/extensions/providers/claude-driver.ts +319 -0
  112. package/extensions/providers/cursor-acpx-driver.ts +398 -0
  113. package/extensions/providers/cursor-cli-driver.ts +484 -0
  114. package/extensions/providers/gemini-driver.ts +302 -0
  115. package/extensions/providers/index.ts +513 -0
  116. package/extensions/shared/build-system-prompt.ts +57 -0
  117. package/extensions/shared/create-runtime-provider.ts +190 -0
  118. package/extensions/shared/daemon-manager.ts +248 -0
  119. package/extensions/shared/file-logger.ts +115 -0
  120. package/extensions/shared/managed-refresh.ts +211 -0
  121. package/extensions/shared/provider-driver.ts +295 -0
  122. package/extensions/shared/provider-errors.ts +305 -0
  123. package/extensions/shared/provider-registry.ts +388 -0
  124. package/extensions/shared/stream-builder.ts +275 -0
  125. package/extensions/shared/types.ts +20 -0
  126. package/extensions/shared/ui/README.md +10 -0
  127. package/extensions/shared/ui/badge.tsx +52 -0
  128. package/extensions/shared/ui/button.tsx +58 -0
  129. package/extensions/shared/ui/collapsible.tsx +21 -0
  130. package/extensions/shared/ui/dropdown-menu.tsx +266 -0
  131. package/extensions/shared/ui/input.tsx +20 -0
  132. package/extensions/shared/ui/popover.tsx +114 -0
  133. package/extensions/shared/ui/resizable.tsx +48 -0
  134. package/extensions/shared/ui/scroll-area.tsx +53 -0
  135. package/extensions/shared/ui/select.tsx +201 -0
  136. package/extensions/shared/ui/separator.tsx +25 -0
  137. package/extensions/shared/ui/tooltip.tsx +64 -0
  138. package/extensions/shared/ws-client.ts +74 -0
  139. package/package.json +59 -0
  140. package/prompts/coderabbit-rate-limit.md +95 -0
  141. package/prompts/create-coms-feature-manager.md +186 -0
  142. package/prompts/create-skill.md +128 -0
  143. package/prompts/domain-model.md +109 -0
  144. package/prompts/external-ai.md +665 -0
  145. package/prompts/implement-and-review.md +25 -0
  146. package/prompts/implement.md +26 -0
  147. package/prompts/issue-review.md +256 -0
  148. package/prompts/pr-review.md +753 -0
  149. package/prompts/query-db.md +154 -0
  150. package/prompts/refine-review.md +208 -0
  151. package/prompts/release.md +235 -0
  152. package/prompts/remember.md +33 -0
  153. package/prompts/review-handler-status.md +27 -0
  154. package/prompts/review-handler.md +677 -0
  155. package/prompts/review-local.md +159 -0
  156. package/prompts/scout-and-plan.md +21 -0
  157. package/rules/00-orchestrator-core.md +42 -0
  158. package/rules/05-issue-first-workflow.md +119 -0
  159. package/rules/10-agent-routing.md +58 -0
  160. package/rules/15-mcp-launchpad.md +46 -0
  161. package/rules/20-code-review-loop.md +234 -0
  162. package/rules/25-documentation-updates.md +15 -0
  163. package/rules/30-prompt-templates.md +19 -0
  164. package/rules/35-memory.md +240 -0
  165. package/rules/40-critical-rules.md +124 -0
  166. package/rules/45-file-preview.md +29 -0
  167. package/rules/50-agent-bug-reporting.md +90 -0
  168. package/rules/55-coms-protocol.md +63 -0
  169. package/rules/60-task-tracking.md +66 -0
  170. package/skills/conflict-resolver/SKILL.md +213 -0
  171. package/skills/skill-creator/SKILL.md +85 -0
  172. package/skills/systematic-debugging/SKILL.md +353 -0
  173. package/skills/test-driven-development/SKILL.md +335 -0
  174. package/skills/update-agents-md/SKILL.md +282 -0
  175. package/templates/coms-feature-manager-prompt.md +313 -0
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: conflict-resolver
3
+ description: "Resolve git merge/rebase conflicts by analyzing git history, commit intent, and code context. Use when merge or rebase produces conflicts."
4
+ ---
5
+
6
+ # Git Conflict Resolver
7
+
8
+ Resolve merge and rebase conflicts by understanding WHY both sides made their changes,
9
+ then choosing the right resolution based on intent — not just line-by-line diffing.
10
+
11
+ ## When to Use
12
+
13
+ - `git merge` / `git rebase` / `git cherry-pick` produced conflicts
14
+ - PR can't merge due to conflicts
15
+ - Worktree rebase has conflicts after `git rebase origin/main`
16
+
17
+ ## Phase 1: Understand the Conflict
18
+
19
+ Before touching any file, gather context:
20
+
21
+ ```bash
22
+ # List all conflicted files
23
+ git diff --name-only --diff-filter=U
24
+
25
+ # Show ALL conflict types (UU=both modified, AA=both added, etc.)
26
+ git status --porcelain | grep "^[UAD][UAD]"
27
+ ```
28
+
29
+ ### Detect the operation type
30
+
31
+ ```bash
32
+ # What caused the conflict? (worktree-safe — no .git/ path assumptions)
33
+ if git rev-parse --verify -q MERGE_HEAD >/dev/null 2>&1; then
34
+ echo "MERGE — ours=HEAD, theirs=MERGE_HEAD"
35
+ THEIRS="MERGE_HEAD"
36
+ elif git rev-parse --verify -q REBASE_HEAD >/dev/null 2>&1; then
37
+ echo "REBASE — ours=upstream (HEAD), theirs=your commits (REBASE_HEAD) — swapped!"
38
+ THEIRS="REBASE_HEAD"
39
+ elif git rev-parse --verify -q CHERRY_PICK_HEAD >/dev/null 2>&1; then
40
+ echo "CHERRY-PICK — ours=HEAD, theirs=CHERRY_PICK_HEAD"
41
+ THEIRS="CHERRY_PICK_HEAD"
42
+ fi
43
+
44
+ # For EACH conflicted file — see what each side changed
45
+ git log --oneline $THEIRS..HEAD -- <file> # our commits
46
+ git log --oneline HEAD..$THEIRS -- <file> # their commits
47
+
48
+ # Get blame for context
49
+ git blame HEAD -- <file> | head -30
50
+ git blame $THEIRS -- <file> | head -30
51
+
52
+ # View the actual conflict markers
53
+ grep -n "<<<<<<\|======\|>>>>>>" <file>
54
+ ```
55
+
56
+ **⚠️ During rebase, `--ours` and `--theirs` are SWAPPED:**
57
+
58
+ - `git merge`: `--ours` = your branch, `--theirs` = incoming
59
+ - `git rebase`: `--ours` = upstream (the branch you're rebasing onto), `--theirs` = your commits
60
+
61
+ **Iron Law: understand BOTH sides before resolving. Never blindly accept one side.**
62
+
63
+ ## Phase 2: Classify the Conflict
64
+
65
+ Classify each side's changes by intent:
66
+
67
+ | Type | Indicators | Resolution Priority |
68
+ |------|-----------|---------------------|
69
+ | Security fix | "security", "vuln", "CVE" in commit message | Highest — always keep |
70
+ | Bug fix | "fix", "bug", "patch" in commit message; small targeted change | Highest — always keep |
71
+ | Refactor | "refactor", "cleanup", "rename"; no behavior change | Medium — preserve both if compatible |
72
+ | Feature | "feat", "add", "implement"; new functionality | Medium — merge carefully |
73
+ | Style | "style", "format", "lint"; whitespace/formatting only | Lowest — accept either side |
74
+
75
+ ## Phase 3: Resolve
76
+
77
+ ### Decision Framework
78
+
79
+ 1. **Same intent, compatible changes** → merge both (most common)
80
+ 2. **Bug fix vs feature** → bug fix wins, integrate feature around it
81
+ 3. **Conflicting logic** → prefer the more recent or more tested change
82
+ 4. **Style/format conflicts** → accept either, prefer consistency with surrounding code
83
+ 5. **Deletions vs modifications** → investigate why deleted; deletion is usually intentional
84
+ 6. **Lock files** (`package-lock.json`, `uv.lock`, `yarn.lock`, `pnpm-lock.yaml`) → NEVER merge manually.
85
+ Resolve the **manifest first** (`package.json`, `pyproject.toml`, etc.), then regenerate:
86
+
87
+ ```bash
88
+ # Step 1: Resolve the manifest file (package.json, pyproject.toml) normally
89
+ # Step 2: Delete the conflicted lock file and regenerate
90
+
91
+ # For uv.lock
92
+ rm -f uv.lock
93
+ uv lock
94
+
95
+ # For package-lock.json
96
+ rm -f package-lock.json
97
+ npm install
98
+
99
+ # For yarn.lock
100
+ rm -f yarn.lock
101
+ yarn install
102
+ ```
103
+
104
+ The manifest defines WHAT you want. The lock file is generated FROM the manifest. Never pick a side for the lock file — just regenerate it.
105
+
106
+ ### Resolution Commands
107
+
108
+ ```bash
109
+ # Accept theirs entirely (incoming changes)
110
+ git checkout --theirs <file>
111
+ git add <file>
112
+
113
+ # Accept ours entirely (current branch changes)
114
+ git checkout --ours <file>
115
+ git add <file>
116
+ ```
117
+
118
+ **⚠️ During rebase, `--ours`/`--theirs` are swapped.** If unsure, use `git diff :2:<file> :3:<file>` to compare stage 2 (ours) vs stage 3 (theirs) directly.
119
+
120
+ ```bash
121
+ # Manual resolution
122
+ # 1. Open file, read conflict markers
123
+ # 2. Remove <<<<<<< ======= >>>>>>> markers
124
+ # 3. Combine changes based on intent analysis
125
+ # 4. Verify syntax
126
+ git add <file>
127
+ ```
128
+
129
+ ### For Manual Resolution
130
+
131
+ 1. Read the ENTIRE conflict block — not just the markers
132
+ 2. Check what comes BEFORE and AFTER the conflict — context matters
133
+ 3. If both sides add imports → keep both (deduplicate)
134
+ 4. If both sides modify the same function → merge logic carefully, test
135
+ 5. If one side deletes code the other modifies → check git log to understand why
136
+
137
+ ## Phase 4: Verify
138
+
139
+ ```bash
140
+ # No remaining conflict markers
141
+ grep -rn "<<<<<<\|======\|>>>>>>" <resolved-files>
142
+
143
+ # No unresolved files
144
+ git diff --name-only --diff-filter=U
145
+
146
+ # Syntax check (language-dependent)
147
+ # Python
148
+ uv run python -c "import ast; ast.parse(open('<file>').read())"
149
+ # TypeScript/JavaScript
150
+ npx tsc --noEmit
151
+ # Go
152
+ go build ./...
153
+
154
+ # Run tests
155
+ uv run pytest -q # or npm test, go test, etc.
156
+ ```
157
+
158
+ ## Phase 5: Complete
159
+
160
+ ```bash
161
+ # For merge
162
+ git add <all-resolved-files>
163
+ git commit # uses merge commit message
164
+
165
+ # For rebase
166
+ git add <all-resolved-files>
167
+ git rebase --continue
168
+ ```
169
+
170
+ ## Common Patterns
171
+
172
+ ### Import Conflicts
173
+
174
+ Both sides added different imports → keep all, deduplicate:
175
+
176
+ ```python
177
+ # OURS
178
+ from module import foo, bar
179
+
180
+ # THEIRS
181
+ from module import foo, baz
182
+
183
+ # RESOLVED
184
+ from module import bar, baz, foo
185
+ ```
186
+
187
+ ### Function Modification Conflicts
188
+
189
+ Both sides changed the same function → merge logic:
190
+
191
+ 1. Read both versions completely
192
+ 2. Identify what each change does
193
+ 3. If independent changes → combine both
194
+ 4. If conflicting behavior → pick the one that matches current requirements
195
+
196
+ ### Config/YAML Conflicts
197
+
198
+ Both sides added different config entries → merge sections:
199
+
200
+ ```yaml
201
+ # Usually safe to keep both additions
202
+ # Watch for duplicate keys — last one wins in YAML
203
+ ```
204
+
205
+ ## Anti-Patterns
206
+
207
+ | Don't | Why | Instead |
208
+ |-------|-----|---------|
209
+ | `git checkout --ours .` | Discards ALL incoming changes | Resolve file by file |
210
+ | Manually edit lock files | Corrupts dependency resolution | Regenerate from scratch |
211
+ | Skip git blame | Wrong intent, wrong resolution | Always check commit history |
212
+ | Resolve without understanding | Creates subtle bugs | Read both sides first |
213
+ | Accept AI's first suggestion blindly | AI often picks one side | Verify the merge makes sense |
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: skill-creator
3
+ description: "Save successful workflows as reusable pi skills. Use when a workflow worked well and should be preserved for future use."
4
+ ---
5
+
6
+ # Create Skills from Experience
7
+
8
+ ## When to Use
9
+
10
+ After completing a task that involved a non-obvious workflow:
11
+
12
+ - Multi-step debugging process that worked
13
+ - Build/deploy procedure that required specific steps
14
+ - Integration pattern that took multiple attempts to get right
15
+ - Any workflow where you think "I should remember how to do this"
16
+
17
+ ## How to Create a Skill
18
+
19
+ 1. **Identify the workflow** — what steps did you follow? What worked?
20
+ 2. **Write the SKILL.md** — save to `~/.agents/skills/<name>/SKILL.md`
21
+ 3. **Keep it specific and actionable** — steps, commands, verification
22
+
23
+ ## SKILL.md Format
24
+
25
+ ```markdown
26
+ ---
27
+ name: skill-name
28
+ description: "One-line description of what this skill does and when to use it."
29
+ ---
30
+
31
+ # Skill Title
32
+
33
+ ## When to Use
34
+
35
+ - Trigger condition 1
36
+ - Trigger condition 2
37
+
38
+ ## Steps
39
+
40
+ 1. Step one with exact commands
41
+ 2. Step two
42
+ 3. Verification step
43
+
44
+ ## Pitfalls
45
+
46
+ - Common mistake and how to avoid it
47
+ ```
48
+
49
+ ## Rules
50
+
51
+ - **name**: lowercase, hyphenated, max 64 chars
52
+ - **description**: one line, max 1024 chars, explains WHEN to use it
53
+ - **Body**: concrete steps, exact commands, verification
54
+ - **No fluff**: skip background, motivation, history — just the procedure
55
+ - **Include pitfalls**: what goes wrong and how to avoid it
56
+ - **Include verification**: how to confirm it worked
57
+
58
+ ## Where to Save
59
+
60
+ ```bash
61
+ mkdir -p ~/.agents/skills/<skill-name>
62
+ # Write SKILL.md there
63
+ ```
64
+
65
+ Skills in `~/.agents/skills/` are user-local and automatically discovered by pi.
66
+
67
+ ## Good vs Bad Skills
68
+
69
+ **Good skill:** Specific procedure with exact commands
70
+
71
+ ```text
72
+ ## Steps
73
+ 1. Run `uv run pytest tests/ -q` to get baseline
74
+ 2. Check for `FAILED` in output
75
+ 3. If failures, run `uv run pytest tests/test_specific.py -v` for details
76
+ ```
77
+
78
+ **Bad skill:** Vague advice
79
+
80
+ ```text
81
+ ## Steps
82
+ 1. Run tests
83
+ 2. Check results
84
+ 3. Fix issues
85
+ ```
@@ -0,0 +1,353 @@
1
+ ---
2
+ name: systematic-debugging
3
+ description: "4-phase root cause debugging: understand bugs before fixing."
4
+ ---
5
+
6
+ # Systematic Debugging
7
+
8
+ ## Overview
9
+
10
+ Random fixes waste time and create new bugs. Quick patches mask underlying issues.
11
+
12
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
13
+
14
+ **Violating the letter of this process is violating the spirit of debugging.**
15
+
16
+ ## The Iron Law
17
+
18
+ ```text
19
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
20
+ ```
21
+
22
+ If you haven't completed Phase 1, you cannot propose fixes.
23
+
24
+ ## When to Use
25
+
26
+ Use for ANY technical issue:
27
+
28
+ - Test failures
29
+ - Bugs in production
30
+ - Unexpected behavior
31
+ - Performance problems
32
+ - Build failures
33
+ - Integration issues
34
+
35
+ **Use this ESPECIALLY when:**
36
+
37
+ - Under time pressure (emergencies make guessing tempting)
38
+ - "Just one quick fix" seems obvious
39
+ - You've already tried multiple fixes
40
+ - Previous fix didn't work
41
+ - You don't fully understand the issue
42
+
43
+ **Don't skip when:**
44
+
45
+ - Issue seems simple (simple bugs have root causes too)
46
+ - You're in a hurry (rushing guarantees rework)
47
+ - Someone wants it fixed NOW (systematic is faster than thrashing)
48
+
49
+ ## The Four Phases
50
+
51
+ You MUST complete each phase before proceeding to the next.
52
+
53
+ ---
54
+
55
+ ## Phase 1: Root Cause Investigation
56
+
57
+ **BEFORE attempting ANY fix:**
58
+
59
+ ### 1. Read Error Messages Carefully
60
+
61
+ - Don't skip past errors or warnings
62
+ - They often contain the exact solution
63
+ - Read stack traces completely
64
+ - Note line numbers, file paths, error codes
65
+
66
+ **Action:** Use `read` on the relevant source files. Use `bash` with `grep -rn` to find the error string in the codebase.
67
+
68
+ ### 2. Reproduce Consistently
69
+
70
+ - Can you trigger it reliably?
71
+ - What are the exact steps?
72
+ - Does it happen every time?
73
+ - If not reproducible → gather more data, don't guess
74
+
75
+ **Action:** Use `bash` to run the failing test or trigger the bug:
76
+
77
+ ```bash
78
+ # Run specific failing test
79
+ uv run pytest tests/test_module.py::test_name -v
80
+
81
+ # Run with verbose output
82
+ uv run pytest tests/test_module.py -v --tb=long
83
+ ```
84
+
85
+ ### 3. Check Recent Changes
86
+
87
+ - What changed that could cause this?
88
+ - Git diff, recent commits
89
+ - New dependencies, config changes
90
+
91
+ **Action:**
92
+
93
+ ```bash
94
+ # Recent commits
95
+ git log --oneline -10
96
+
97
+ # Uncommitted changes
98
+ git diff
99
+
100
+ # Changes in specific file
101
+ git log -p --follow src/problematic_file.py | head -100
102
+ ```
103
+
104
+ ### 4. Gather Evidence in Multi-Component Systems
105
+
106
+ **WHEN system has multiple components (API → service → database, CI → build → deploy):**
107
+
108
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
109
+
110
+ For EACH component boundary:
111
+
112
+ - Log what data enters the component
113
+ - Log what data exits the component
114
+ - Verify environment/config propagation
115
+ - Check state at each layer
116
+
117
+ Run once to gather evidence showing WHERE it breaks.
118
+ THEN analyze evidence to identify the failing component.
119
+ THEN investigate that specific component.
120
+
121
+ ### 5. Trace Data Flow
122
+
123
+ **WHEN error is deep in the call stack:**
124
+
125
+ - Where does the bad value originate?
126
+ - What called this function with the bad value?
127
+ - Keep tracing upstream until you find the source
128
+ - Fix at the source, not at the symptom
129
+
130
+ **Action:** Use `bash` with `grep` to trace references:
131
+
132
+ ```bash
133
+ # Find where the function is called
134
+ grep -rn "function_name(" src/ --include="*.py"
135
+
136
+ # Find where the variable is set
137
+ grep -rn "variable_name\s*=" src/ --include="*.py"
138
+ ```
139
+
140
+ ### Phase 1 Completion Checklist
141
+
142
+ - [ ] Error messages fully read and understood
143
+ - [ ] Issue reproduced consistently
144
+ - [ ] Recent changes identified and reviewed
145
+ - [ ] Evidence gathered (logs, state, data flow)
146
+ - [ ] Problem isolated to specific component/code
147
+ - [ ] Root cause hypothesis formed
148
+
149
+ **STOP:** Do not proceed to Phase 2 until you understand WHY it's happening.
150
+
151
+ ---
152
+
153
+ ## Phase 2: Pattern Analysis
154
+
155
+ **Find the pattern before fixing:**
156
+
157
+ ### 1. Find Working Examples
158
+
159
+ - Locate similar working code in the same codebase
160
+ - What works that's similar to what's broken?
161
+
162
+ **Action:** Use `bash` with `grep` to find comparable patterns:
163
+
164
+ ```bash
165
+ grep -rn "similar_pattern" src/ --include="*.py"
166
+ ```
167
+
168
+ ### 2. Compare Against References
169
+
170
+ - If implementing a pattern, read the reference implementation COMPLETELY
171
+ - Don't skim — read every line
172
+ - Understand the pattern fully before applying
173
+
174
+ ### 3. Identify Differences
175
+
176
+ - What's different between working and broken?
177
+ - List every difference, however small
178
+ - Don't assume "that can't matter"
179
+
180
+ ### 4. Understand Dependencies
181
+
182
+ - What other components does this need?
183
+ - What settings, config, environment?
184
+ - What assumptions does it make?
185
+
186
+ ---
187
+
188
+ ## Phase 3: Hypothesis and Testing
189
+
190
+ **Scientific method:**
191
+
192
+ ### 1. Form a Single Hypothesis
193
+
194
+ - State clearly: "I think X is the root cause because Y"
195
+ - Write it down
196
+ - Be specific, not vague
197
+
198
+ ### 2. Test Minimally
199
+
200
+ - Make the SMALLEST possible change to test the hypothesis
201
+ - One variable at a time
202
+ - Don't fix multiple things at once
203
+
204
+ ### 3. Verify Before Continuing
205
+
206
+ - Did it work? → Phase 4
207
+ - Didn't work? → Form NEW hypothesis
208
+ - DON'T add more fixes on top
209
+
210
+ ### 4. When You Don't Know
211
+
212
+ - Say "I don't understand X"
213
+ - Don't pretend to know
214
+ - Ask the user for help
215
+ - Research more
216
+
217
+ ---
218
+
219
+ ## Phase 4: Implementation
220
+
221
+ **Fix the root cause, not the symptom:**
222
+
223
+ ### 1. Create Failing Test Case
224
+
225
+ - Simplest possible reproduction
226
+ - Automated test if possible
227
+ - MUST have before fixing
228
+ - Use the `test-driven-development` skill
229
+
230
+ ### 2. Implement Single Fix
231
+
232
+ - Address the root cause identified
233
+ - ONE change at a time
234
+ - No "while I'm here" improvements
235
+ - No bundled refactoring
236
+
237
+ ### 3. Verify Fix
238
+
239
+ ```bash
240
+ # Run the specific regression test
241
+ uv run pytest tests/test_module.py::test_regression -v
242
+
243
+ # Run full suite — no regressions
244
+ uv run pytest tests/ -q
245
+ ```
246
+
247
+ ### 4. If Fix Doesn't Work — The Rule of Three
248
+
249
+ - **STOP.**
250
+ - Count: How many fixes have you tried?
251
+ - If < 3: Return to Phase 1, re-analyze with new information
252
+ - **If ≥ 3: STOP and question the architecture (step 5 below)**
253
+ - DON'T attempt Fix #4 without architectural discussion
254
+
255
+ ### 5. If 3+ Fixes Failed: Question Architecture
256
+
257
+ **Pattern indicating an architectural problem:**
258
+
259
+ - Each fix reveals new shared state/coupling in a different place
260
+ - Fixes require "massive refactoring" to implement
261
+ - Each fix creates new symptoms elsewhere
262
+
263
+ **STOP and question fundamentals:**
264
+
265
+ - Is this pattern fundamentally sound?
266
+ - Are we "sticking with it through sheer inertia"?
267
+ - Should we refactor the architecture vs. continue fixing symptoms?
268
+
269
+ **Discuss with the user before attempting more fixes.**
270
+
271
+ This is NOT a failed hypothesis — this is a wrong architecture.
272
+
273
+ ---
274
+
275
+ ## Red Flags — STOP and Follow Process
276
+
277
+ If you catch yourself thinking:
278
+
279
+ - "Quick fix for now, investigate later"
280
+ - "Just try changing X and see if it works"
281
+ - "Add multiple changes, run tests"
282
+ - "Skip the test, I'll manually verify"
283
+ - "It's probably X, let me fix that"
284
+ - "I don't fully understand but this might work"
285
+ - "Pattern says X but I'll adapt it differently"
286
+ - "Here are the main problems: [lists fixes without investigation]"
287
+ - Proposing solutions before tracing data flow
288
+ - **"One more fix attempt" (when already tried 2+)**
289
+ - **Each fix reveals a new problem in a different place**
290
+
291
+ **ALL of these mean: STOP. Return to Phase 1.**
292
+
293
+ **If 3+ fixes failed:** Question the architecture (Phase 4 step 5).
294
+
295
+ ## Common Rationalizations
296
+
297
+ | Excuse | Reality |
298
+ | ------ | ------- |
299
+ | "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
300
+ | "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
301
+ | "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
302
+ | "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
303
+ | "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
304
+ | "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
305
+ | "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
306
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question the pattern, don't fix again. |
307
+
308
+ ## Quick Reference
309
+
310
+ | Phase | Key Activities | Success Criteria |
311
+ | ----- | -------------- | ---------------- |
312
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence, trace data flow | Understand WHAT and WHY |
313
+ | **2. Pattern** | Find working examples, compare, identify differences | Know what's different |
314
+ | **3. Hypothesis** | Form theory, test minimally, one variable at a time | Confirmed or new hypothesis |
315
+ | **4. Implementation** | Create regression test, fix root cause, verify | Bug resolved, all tests pass |
316
+
317
+ ## Pi Agent Integration
318
+
319
+ ### Investigation Tools
320
+
321
+ Use these pi tools during Phase 1:
322
+
323
+ - **`bash`** (grep, find, rg) — Find error strings, trace function calls, locate patterns
324
+ - **`read`** — Read source code for precise analysis
325
+ - **`bash`** — Run tests, check git history, reproduce bugs
326
+ - **`web_search`** — Research error messages, library docs
327
+
328
+ ### With subagent
329
+
330
+ For complex multi-component debugging, the orchestrator dispatches the debugger agent:
331
+
332
+ The debugger diagnoses only — it does not modify files.
333
+ The orchestrator delegates the actual fix to the appropriate language specialist.
334
+
335
+ ### With test-driven-development
336
+
337
+ When fixing bugs:
338
+
339
+ 1. Write a test that reproduces the bug (RED)
340
+ 2. Debug systematically to find root cause
341
+ 3. Fix the root cause (GREEN)
342
+ 4. The test proves the fix and prevents regression
343
+
344
+ ## Real-World Impact
345
+
346
+ From debugging sessions:
347
+
348
+ - Systematic approach: 15-30 minutes to fix
349
+ - Random fixes approach: 2-3 hours of thrashing
350
+ - First-time fix rate: 95% vs 40%
351
+ - New bugs introduced: Near zero vs common
352
+
353
+ **No shortcuts. No guessing. Systematic always wins.**