@zcy2nn/agent-forge 1.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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/agent-forge.schema.json +675 -0
  4. package/dist/agents/council.d.ts +27 -0
  5. package/dist/agents/councillor.d.ts +2 -0
  6. package/dist/agents/implementer.d.ts +2 -0
  7. package/dist/agents/index.d.ts +30 -0
  8. package/dist/agents/orchestrator.d.ts +30 -0
  9. package/dist/agents/researcher.d.ts +2 -0
  10. package/dist/agents/reviewer.d.ts +2 -0
  11. package/dist/cli/config-io.d.ts +24 -0
  12. package/dist/cli/config-manager.d.ts +4 -0
  13. package/dist/cli/custom-skills.d.ts +29 -0
  14. package/dist/cli/doctor.d.ts +38 -0
  15. package/dist/cli/index.d.ts +2 -0
  16. package/dist/cli/index.js +1932 -0
  17. package/dist/cli/install.d.ts +2 -0
  18. package/dist/cli/migration.d.ts +46 -0
  19. package/dist/cli/model-key-normalization.d.ts +1 -0
  20. package/dist/cli/paths.d.ts +35 -0
  21. package/dist/cli/providers.d.ts +99 -0
  22. package/dist/cli/skills.d.ts +52 -0
  23. package/dist/cli/system.d.ts +6 -0
  24. package/dist/cli/types.d.ts +40 -0
  25. package/dist/config/agent-mcps.d.ts +15 -0
  26. package/dist/config/constants.d.ts +28 -0
  27. package/dist/config/council-schema.d.ts +127 -0
  28. package/dist/config/index.d.ts +5 -0
  29. package/dist/config/loader.d.ts +57 -0
  30. package/dist/config/runtime-preset.d.ts +12 -0
  31. package/dist/config/schema.d.ts +371 -0
  32. package/dist/config/utils.d.ts +15 -0
  33. package/dist/council/council-manager.d.ts +49 -0
  34. package/dist/council/index.d.ts +1 -0
  35. package/dist/divoom/council.gif +0 -0
  36. package/dist/divoom/designer.gif +0 -0
  37. package/dist/divoom/explorer.gif +0 -0
  38. package/dist/divoom/fixer.gif +0 -0
  39. package/dist/divoom/input.gif +0 -0
  40. package/dist/divoom/intro.gif +0 -0
  41. package/dist/divoom/librarian.gif +0 -0
  42. package/dist/divoom/manager.d.ts +57 -0
  43. package/dist/divoom/oracle.gif +0 -0
  44. package/dist/divoom/orchestrator.gif +0 -0
  45. package/dist/hooks/apply-patch/codec.d.ts +7 -0
  46. package/dist/hooks/apply-patch/errors.d.ts +25 -0
  47. package/dist/hooks/apply-patch/execution-context.d.ts +27 -0
  48. package/dist/hooks/apply-patch/index.d.ts +15 -0
  49. package/dist/hooks/apply-patch/matching.d.ts +26 -0
  50. package/dist/hooks/apply-patch/operations.d.ts +3 -0
  51. package/dist/hooks/apply-patch/patch.d.ts +2 -0
  52. package/dist/hooks/apply-patch/prepared-changes.d.ts +17 -0
  53. package/dist/hooks/apply-patch/resolution.d.ts +19 -0
  54. package/dist/hooks/apply-patch/rewrite.d.ts +7 -0
  55. package/dist/hooks/apply-patch/test-helpers.d.ts +6 -0
  56. package/dist/hooks/apply-patch/types.d.ts +80 -0
  57. package/dist/hooks/auto-update-checker/cache.d.ts +11 -0
  58. package/dist/hooks/auto-update-checker/checker.d.ts +32 -0
  59. package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
  60. package/dist/hooks/auto-update-checker/index.d.ts +18 -0
  61. package/dist/hooks/auto-update-checker/types.d.ts +22 -0
  62. package/dist/hooks/chat-headers.d.ts +16 -0
  63. package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
  64. package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
  65. package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
  66. package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
  67. package/dist/hooks/filter-available-skills/index.d.ts +32 -0
  68. package/dist/hooks/foreground-fallback/index.d.ts +72 -0
  69. package/dist/hooks/image-hook.d.ts +19 -0
  70. package/dist/hooks/index.d.ts +13 -0
  71. package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
  72. package/dist/hooks/json-error-recovery/index.d.ts +1 -0
  73. package/dist/hooks/phase-reminder/index.d.ts +26 -0
  74. package/dist/hooks/post-file-tool-nudge/index.d.ts +19 -0
  75. package/dist/hooks/task-session-manager/index.d.ts +52 -0
  76. package/dist/hooks/todo-continuation/index.d.ts +53 -0
  77. package/dist/hooks/todo-continuation/todo-hygiene.d.ts +35 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.js +32981 -0
  80. package/dist/interview/dashboard.d.ts +62 -0
  81. package/dist/interview/document.d.ts +25 -0
  82. package/dist/interview/helpers.d.ts +10 -0
  83. package/dist/interview/index.d.ts +1 -0
  84. package/dist/interview/manager.d.ts +35 -0
  85. package/dist/interview/parser.d.ts +11 -0
  86. package/dist/interview/prompts.d.ts +7 -0
  87. package/dist/interview/server.d.ts +13 -0
  88. package/dist/interview/service.d.ts +34 -0
  89. package/dist/interview/types.d.ts +96 -0
  90. package/dist/interview/ui.d.ts +12 -0
  91. package/dist/mcp/context7.d.ts +6 -0
  92. package/dist/mcp/grep-app.d.ts +6 -0
  93. package/dist/mcp/index.d.ts +8 -0
  94. package/dist/mcp/types.d.ts +12 -0
  95. package/dist/mcp/websearch.d.ts +9 -0
  96. package/dist/multiplexer/factory.d.ts +26 -0
  97. package/dist/multiplexer/index.d.ts +9 -0
  98. package/dist/multiplexer/session-manager.d.ts +53 -0
  99. package/dist/multiplexer/tmux/index.d.ts +22 -0
  100. package/dist/multiplexer/types.d.ts +54 -0
  101. package/dist/multiplexer/zellij/index.d.ts +34 -0
  102. package/dist/tools/ast-grep/cli.d.ts +15 -0
  103. package/dist/tools/ast-grep/constants.d.ts +25 -0
  104. package/dist/tools/ast-grep/downloader.d.ts +5 -0
  105. package/dist/tools/ast-grep/index.d.ts +10 -0
  106. package/dist/tools/ast-grep/tools.d.ts +3 -0
  107. package/dist/tools/ast-grep/types.d.ts +30 -0
  108. package/dist/tools/ast-grep/utils.d.ts +4 -0
  109. package/dist/tools/council.d.ts +10 -0
  110. package/dist/tools/index.d.ts +6 -0
  111. package/dist/tools/preset-manager.d.ts +27 -0
  112. package/dist/tools/skill.d.ts +9 -0
  113. package/dist/tools/smartfetch/binary.d.ts +3 -0
  114. package/dist/tools/smartfetch/cache.d.ts +6 -0
  115. package/dist/tools/smartfetch/constants.d.ts +12 -0
  116. package/dist/tools/smartfetch/index.d.ts +3 -0
  117. package/dist/tools/smartfetch/network.d.ts +38 -0
  118. package/dist/tools/smartfetch/secondary-model.d.ts +28 -0
  119. package/dist/tools/smartfetch/tool.d.ts +3 -0
  120. package/dist/tools/smartfetch/types.d.ts +122 -0
  121. package/dist/tools/smartfetch/utils.d.ts +18 -0
  122. package/dist/tui-state.d.ts +15 -0
  123. package/dist/tui.d.ts +8 -0
  124. package/dist/tui.js +248 -0
  125. package/dist/utils/agent-variant.d.ts +63 -0
  126. package/dist/utils/compat.d.ts +30 -0
  127. package/dist/utils/env.d.ts +1 -0
  128. package/dist/utils/index.d.ts +9 -0
  129. package/dist/utils/internal-initiator.d.ts +6 -0
  130. package/dist/utils/logger.d.ts +8 -0
  131. package/dist/utils/polling.d.ts +21 -0
  132. package/dist/utils/session-manager.d.ts +55 -0
  133. package/dist/utils/session.d.ts +74 -0
  134. package/dist/utils/subagent-depth.d.ts +35 -0
  135. package/dist/utils/system-collapse.d.ts +6 -0
  136. package/dist/utils/task.d.ts +4 -0
  137. package/dist/utils/zip-extractor.d.ts +1 -0
  138. package/package.json +104 -0
  139. package/src/skills/brainstorming/SKILL.md +177 -0
  140. package/src/skills/brainstorming/scripts/frame-template.html +214 -0
  141. package/src/skills/brainstorming/scripts/helper.js +88 -0
  142. package/src/skills/brainstorming/scripts/server.cjs +354 -0
  143. package/src/skills/brainstorming/scripts/start-server.sh +148 -0
  144. package/src/skills/brainstorming/scripts/stop-server.sh +56 -0
  145. package/src/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  146. package/src/skills/brainstorming/visual-companion.md +279 -0
  147. package/src/skills/codemap/README.md +59 -0
  148. package/src/skills/codemap/SKILL.md +163 -0
  149. package/src/skills/codemap/codemap.md +36 -0
  150. package/src/skills/codemap/scripts/codemap.mjs +483 -0
  151. package/src/skills/codemap/scripts/codemap.test.ts +129 -0
  152. package/src/skills/codemap.md +40 -0
  153. package/src/skills/dispatching-parallel-agents/SKILL.md +193 -0
  154. package/src/skills/executing-plans/SKILL.md +78 -0
  155. package/src/skills/finishing-a-development-branch/SKILL.md +211 -0
  156. package/src/skills/receiving-code-review/SKILL.md +224 -0
  157. package/src/skills/requesting-code-review/SKILL.md +113 -0
  158. package/src/skills/requesting-code-review/code-reviewer.md +146 -0
  159. package/src/skills/simplify/README.md +19 -0
  160. package/src/skills/simplify/SKILL.md +138 -0
  161. package/src/skills/simplify/codemap.md +36 -0
  162. package/src/skills/subagent-driven-development/SKILL.md +288 -0
  163. package/src/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  164. package/src/skills/subagent-driven-development/implementer-prompt.md +113 -0
  165. package/src/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  166. package/src/skills/systematic-debugging/CREATION-LOG.md +119 -0
  167. package/src/skills/systematic-debugging/SKILL.md +308 -0
  168. package/src/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  169. package/src/skills/systematic-debugging/condition-based-waiting.md +115 -0
  170. package/src/skills/systematic-debugging/defense-in-depth.md +122 -0
  171. package/src/skills/systematic-debugging/find-polluter.sh +63 -0
  172. package/src/skills/systematic-debugging/root-cause-tracing.md +169 -0
  173. package/src/skills/systematic-debugging/test-academic.md +14 -0
  174. package/src/skills/systematic-debugging/test-pressure-1.md +58 -0
  175. package/src/skills/systematic-debugging/test-pressure-2.md +68 -0
  176. package/src/skills/systematic-debugging/test-pressure-3.md +69 -0
  177. package/src/skills/test-driven-development/SKILL.md +383 -0
  178. package/src/skills/test-driven-development/testing-anti-patterns.md +299 -0
  179. package/src/skills/using-git-worktrees/SKILL.md +226 -0
  180. package/src/skills/verification-before-completion/SKILL.md +147 -0
  181. package/src/skills/writing-plans/SKILL.md +165 -0
  182. package/src/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  183. package/src/skills/writing-skills/SKILL.md +666 -0
  184. package/src/skills/writing-skills/anthropic-best-practices.md +1150 -0
  185. package/src/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  186. package/src/skills/writing-skills/graphviz-conventions.dot +172 -0
  187. package/src/skills/writing-skills/persuasion-principles.md +187 -0
  188. package/src/skills/writing-skills/render-graphs.js +168 -0
  189. package/src/skills/writing-skills/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,129 @@
1
+ import { afterEach, describe, expect, mock, test } from 'bun:test';
2
+ import {
3
+ existsSync,
4
+ mkdirSync,
5
+ mkdtempSync,
6
+ readFileSync,
7
+ rmSync,
8
+ writeFileSync,
9
+ } from 'node:fs';
10
+ import os from 'node:os';
11
+ import path from 'node:path';
12
+
13
+ mock.restore();
14
+
15
+ const {
16
+ computeFileHash,
17
+ computeFolderHash,
18
+ loadState,
19
+ PatternMatcher,
20
+ selectFiles,
21
+ } = await import('./codemap.mjs');
22
+
23
+ const tempDirs: string[] = [];
24
+
25
+ function createTempDir() {
26
+ const dir = mkdtempSync(path.join(os.tmpdir(), 'codemap-'));
27
+ tempDirs.push(dir);
28
+ return dir;
29
+ }
30
+
31
+ afterEach(() => {
32
+ for (const dir of tempDirs.splice(0)) {
33
+ rmSync(dir, { force: true, recursive: true });
34
+ }
35
+ });
36
+
37
+ describe('PatternMatcher', () => {
38
+ test('matches expected paths', () => {
39
+ const matcher = new PatternMatcher([
40
+ 'node_modules/',
41
+ 'dist/',
42
+ '*.log',
43
+ 'src/**/*.ts',
44
+ ]);
45
+
46
+ expect(matcher.matches('node_modules/foo.js')).toBe(true);
47
+ expect(matcher.matches('vendor/node_modules/bar.js')).toBe(true);
48
+ expect(matcher.matches('dist/main.js')).toBe(true);
49
+ expect(matcher.matches('src/dist/output.js')).toBe(true);
50
+ expect(matcher.matches('error.log')).toBe(true);
51
+ expect(matcher.matches('logs/access.log')).toBe(true);
52
+ expect(matcher.matches('src/index.ts')).toBe(true);
53
+ expect(matcher.matches('src/utils/helper.ts')).toBe(true);
54
+ expect(matcher.matches('README.md')).toBe(false);
55
+ expect(matcher.matches('tests/test.py')).toBe(false);
56
+ });
57
+ });
58
+
59
+ describe('hash helpers', () => {
60
+ test('computes file hash', () => {
61
+ const dir = createTempDir();
62
+ const filePath = path.join(dir, 'file.txt');
63
+ writeFileSync(filePath, 'test content');
64
+
65
+ expect(computeFileHash(filePath)).toBe('9473fdd0d880a43c21b7778d34872157');
66
+ });
67
+
68
+ test('computes stable folder hash', () => {
69
+ const fileHashes = {
70
+ 'src/a.ts': 'hash-a',
71
+ 'src/b.ts': 'hash-b',
72
+ 'tests/test.ts': 'hash-test',
73
+ };
74
+
75
+ const hash1 = computeFolderHash('src', fileHashes);
76
+ const hash2 = computeFolderHash('src', fileHashes);
77
+ const hash3 = computeFolderHash('src', {
78
+ 'src/a.ts': 'hash-a-modified',
79
+ 'src/b.ts': 'hash-b',
80
+ });
81
+
82
+ expect(hash1).toBe(hash2);
83
+ expect(hash1).not.toBe(hash3);
84
+ });
85
+ });
86
+
87
+ describe('selectFiles', () => {
88
+ test('respects include and exclude patterns', () => {
89
+ const root = createTempDir();
90
+ mkdirSync(path.join(root, 'src'));
91
+ mkdirSync(path.join(root, 'node_modules'));
92
+ writeFileSync(path.join(root, 'src', 'index.ts'), 'code');
93
+ writeFileSync(path.join(root, 'src', 'index.test.ts'), 'test');
94
+ writeFileSync(path.join(root, 'node_modules', 'foo.js'), 'dep');
95
+ writeFileSync(path.join(root, 'package.json'), '{}');
96
+
97
+ const selected = selectFiles(
98
+ root,
99
+ ['src/**/*.ts', 'package.json'],
100
+ ['**/*.test.ts', 'node_modules/'],
101
+ [],
102
+ [],
103
+ ).map((filePath) =>
104
+ path.relative(root, filePath).split(path.sep).join('/'),
105
+ );
106
+
107
+ expect(selected).toEqual(['package.json', 'src/index.ts']);
108
+ });
109
+ });
110
+
111
+ describe('loadState', () => {
112
+ test('migrates legacy cartography state', () => {
113
+ const root = createTempDir();
114
+ const slimDir = path.join(root, '.slim');
115
+ mkdirSync(slimDir);
116
+
117
+ const legacyState = { metadata: { version: '1.0.0' } };
118
+ writeFileSync(
119
+ path.join(slimDir, 'cartography.json'),
120
+ JSON.stringify(legacyState),
121
+ );
122
+
123
+ expect(loadState(root)).toEqual(legacyState);
124
+ expect(existsSync(path.join(slimDir, 'cartography.json'))).toBe(false);
125
+ expect(
126
+ JSON.parse(readFileSync(path.join(slimDir, 'codemap.json'), 'utf8')),
127
+ ).toEqual(legacyState);
128
+ });
129
+ });
@@ -0,0 +1,40 @@
1
+ # src/skills/
2
+
3
+ ## Responsibility
4
+
5
+ - Own metadata-driven OpenCode custom skills shipped with this package.
6
+ - Maintain the skill contract artifacts (`SKILL.md`, `README.md`, per-skill helper files) that are copied into
7
+ `${configDir}/skills` at install time.
8
+ - Preserve a canonical registry boundary: runtime code consumes skill definitions as data, not as executable
9
+ plugin dependencies.
10
+
11
+ ## Design
12
+
13
+ - `CUSTOM_SKILLS` in `src/cli/custom-skills.ts` is the authoritative skill manifest for bundled
14
+ skills; each entry maps folder name + `sourcePath` to an install-time consumer.
15
+ - `install.ts` runs `installCustomSkill()` which recursively copies `src/skills/codemap` and
16
+ `src/skills/simplify` into the OpenCode skills directory.
17
+ - This directory is partitioned by skill:
18
+ - `src/skills/codemap/` (command-style repository mapping skill)
19
+ - `src/skills/simplify/` (readability/refactor guidance skill)
20
+ - Files are considered static runtime payload. No plugin TS module in `src/` imports these files directly; they
21
+ are loaded by OpenCode via filesystem installation.
22
+
23
+ ## Flow
24
+
25
+ - `bun run install` delegates to `src/cli/install.ts`, where `installCustomSkills` gates copying of
26
+ each `CUSTOM_SKILLS` entry.
27
+ - `installCustomSkill()` computes `packageRoot`, validates `sourcePath`, then performs a recursive
28
+ directory copy via `copyDirRecursive()`.
29
+ - During plugin release, the `files` whitelist in `package.json` must include `src/skills` so
30
+ `src/skills/**` survive `npm pack`.
31
+ - OpenCode plugin startup discovers these installed folders and reads each `SKILL.md` as a prompt-level contract.
32
+
33
+ ## Integration
34
+
35
+ - `src/cli/custom-skills.ts`: source-of-truth registry consumed by installer and permission helpers.
36
+ - `src/cli/skills.ts:getSkillPermissionsForAgent()` auto-populates permission rules for
37
+ `codemap` and `simplify` when agent policy is derived from built-in recommendations.
38
+ - `verify-release-artifact.ts` enforces artifact completeness by asserting `src/skills/simplify/SKILL.md`
39
+ and `src/skills/codemap/SKILL.md` are present in the tarball.
40
+ - `package.json` scripts (`verify:release`, `build`) rely on these assets to ensure install-time skill availability.
@@ -0,0 +1,193 @@
1
+ ---
2
+ name: dispatching-parallel-agents
3
+ description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
4
+ ---
5
+
6
+ # Dispatching Parallel Agents
7
+
8
+ ## Overview
9
+
10
+ You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history — you construct exactly what they need. This also preserves your own context for coordination work.
11
+
12
+ When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel.
13
+
14
+ **Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.
15
+
16
+ ## When to Use
17
+
18
+ ```dot
19
+ digraph when_to_use {
20
+ "Multiple failures?" [shape=diamond];
21
+ "Are they independent?" [shape=diamond];
22
+ "Single agent investigates all" [shape=box];
23
+ "One agent per problem domain" [shape=box];
24
+ "Can they work in parallel?" [shape=diamond];
25
+ "Sequential agents" [shape=box];
26
+ "Parallel dispatch" [shape=box];
27
+
28
+ "Multiple failures?" -> "Are they independent?" [label="yes"];
29
+ "Are they independent?" -> "Single agent investigates all" [label="no - related"];
30
+ "Are they independent?" -> "Can they work in parallel?" [label="yes"];
31
+ "Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
32
+ "Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
33
+ }
34
+ ```
35
+
36
+ **Use when:**
37
+ - 3+ test files failing with different root causes
38
+ - Multiple subsystems broken independently
39
+ - Each problem can be understood without context from others
40
+ - No shared state between investigations
41
+
42
+ **Don't use when:**
43
+ - Failures are related (fix one might fix others)
44
+ - Need to understand full system state
45
+ - Agents would interfere with each other
46
+
47
+ ## The Pattern
48
+
49
+ ### 1. Identify Independent Domains
50
+
51
+ Group failures by what's broken:
52
+ - File A tests: Tool approval flow
53
+ - File B tests: Batch completion behavior
54
+ - File C tests: Abort functionality
55
+
56
+ Each domain is independent - fixing tool approval doesn't affect abort tests.
57
+
58
+ ### 2. Create Focused Agent Tasks
59
+
60
+ Each agent gets:
61
+ - **Specific scope:** One test file or subsystem
62
+ - **Clear goal:** Make these tests pass
63
+ - **Constraints:** Don't change other code
64
+ - **Expected output:** Summary of what you found and fixed
65
+
66
+ ### 3. Dispatch in Parallel
67
+
68
+ ```typescript
69
+ // In Claude Code / AI environment
70
+ Task("Fix agent-tool-abort.test.ts failures")
71
+ Task("Fix batch-completion-behavior.test.ts failures")
72
+ Task("Fix tool-approval-race-conditions.test.ts failures")
73
+ // All three run concurrently
74
+ ```
75
+
76
+ ### 4. Review and Integrate
77
+
78
+ When agents return:
79
+ - Read each summary
80
+ - Verify fixes don't conflict
81
+ - Run full test suite
82
+ - Integrate all changes
83
+
84
+ ## Agent Prompt Structure
85
+
86
+ Good agent prompts are:
87
+ 1. **Focused** - One clear problem domain
88
+ 2. **Self-contained** - All context needed to understand the problem
89
+ 3. **Specific about output** - What should the agent return?
90
+
91
+ ```markdown
92
+ Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
93
+
94
+ 1. "should abort tool with partial output capture" - expects 'interrupted at' in message
95
+ 2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
96
+ 3. "should properly track pendingToolCount" - expects 3 results but gets 0
97
+
98
+ These are timing/race condition issues. Your task:
99
+
100
+ 1. Read the test file and understand what each test verifies
101
+ 2. Identify root cause - timing issues or actual bugs?
102
+ 3. Fix by:
103
+ - Replacing arbitrary timeouts with event-based waiting
104
+ - Fixing bugs in abort implementation if found
105
+ - Adjusting test expectations if testing changed behavior
106
+
107
+ Do NOT just increase timeouts - find the real issue.
108
+
109
+ Return: Summary of what you found and what you fixed.
110
+ ```
111
+
112
+ ## Common Mistakes
113
+
114
+ **❌ Too broad:** "Fix all the tests" - agent gets lost
115
+ **✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope
116
+
117
+ **❌ No context:** "Fix the race condition" - agent doesn't know where
118
+ **✅ Context:** Paste the error messages and test names
119
+
120
+ **❌ No constraints:** Agent might refactor everything
121
+ **✅ Constraints:** "Do NOT change production code" or "Fix tests only"
122
+
123
+ **❌ Vague output:** "Fix it" - you don't know what changed
124
+ **✅ Specific:** "Return summary of root cause and changes"
125
+
126
+ ## When NOT to Use
127
+
128
+ **Related failures:** Fixing one might fix others - investigate together first
129
+ **Need full context:** Understanding requires seeing entire system
130
+ **Exploratory debugging:** You don't know what's broken yet
131
+ **Shared state:** Agents would interfere (editing same files, using same resources)
132
+
133
+ ## Real Example from Session
134
+
135
+ **Scenario:** 6 test failures across 3 files after major refactoring
136
+
137
+ **Failures:**
138
+ - agent-tool-abort.test.ts: 3 failures (timing issues)
139
+ - batch-completion-behavior.test.ts: 2 failures (tools not executing)
140
+ - tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
141
+
142
+ **Decision:** Independent domains - abort logic separate from batch completion separate from race conditions
143
+
144
+ **Dispatch:**
145
+ ```
146
+ Agent 1 → Fix agent-tool-abort.test.ts
147
+ Agent 2 → Fix batch-completion-behavior.test.ts
148
+ Agent 3 → Fix tool-approval-race-conditions.test.ts
149
+ ```
150
+
151
+ **Results:**
152
+ - Agent 1: Replaced timeouts with event-based waiting
153
+ - Agent 2: Fixed event structure bug (threadId in wrong place)
154
+ - Agent 3: Added wait for async tool execution to complete
155
+
156
+ **Integration:** All fixes independent, no conflicts, full suite green
157
+
158
+ **Time saved:** 3 problems solved in parallel vs sequentially
159
+
160
+ ## Key Benefits
161
+
162
+ 1. **Parallelization** - Multiple investigations happen simultaneously
163
+ 2. **Focus** - Each agent has narrow scope, less context to track
164
+ 3. **Independence** - Agents don't interfere with each other
165
+ 4. **Speed** - 3 problems solved in time of 1
166
+
167
+ ## Verification
168
+
169
+ After agents return:
170
+ 1. **Review each summary** - Understand what changed
171
+ 2. **Check for conflicts** - Did agents edit same code?
172
+ 3. **Run full suite** - Verify all fixes work together
173
+ 4. **Spot check** - Agents can make systematic errors
174
+
175
+ ## Complexity Assessment
176
+
177
+ **Lightweight usage:**
178
+ - 2-3 simple tasks dispatched in parallel directly
179
+
180
+ **Standard usage:**
181
+ - Analyze dependencies → split domains → dispatch in parallel → review integration
182
+
183
+ **Deep usage:**
184
+ - Standard + detailed dependency graph + conflict detection
185
+
186
+ ## Real-World Impact
187
+
188
+ From debugging session (2025-10-03):
189
+ - 6 failures across 3 files
190
+ - 3 agents dispatched in parallel
191
+ - All investigations completed concurrently
192
+ - All fixes integrated successfully
193
+ - Zero conflicts between agent changes
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: executing-plans
3
+ description: Use when you have a written implementation plan to execute in a separate session with review checkpoints
4
+ ---
5
+
6
+ # Executing Plans
7
+
8
+ ## Overview
9
+
10
+ Load plan, review critically, execute all tasks, report when complete.
11
+
12
+ **Announce at start:** "I'm using the executing-plans skill to implement this plan."
13
+
14
+ **Note:** Tell your human partner that Superpowers works much better with access to subagents. The quality of its work will be significantly higher if run on a platform with subagent support (such as Claude Code or OpenCode). If subagents are available, use superpowers:subagent-driven-development instead of this skill.
15
+
16
+ ## The Process
17
+
18
+ ### Step 1: Load and Review Plan
19
+ 1. Read plan file
20
+ 2. Review critically - identify any questions or concerns about the plan
21
+ 3. If concerns: Raise them with your human partner before starting
22
+ 4. If no concerns: Create TodoWrite and proceed
23
+
24
+ ### Step 2: Execute Tasks
25
+
26
+ For each task:
27
+ 1. Mark as in_progress
28
+ 2. Follow each step exactly (plan has bite-sized steps)
29
+ 3. Run verifications as specified
30
+ 4. Mark as completed
31
+
32
+ ### Step 3: Complete Development
33
+
34
+ After all tasks complete and verified:
35
+ - Announce: "I'm using the finishing-a-development-branch skill to complete this work."
36
+ - **REQUIRED SUB-SKILL:** Use superpowers:finishing-a-development-branch
37
+ - Follow that skill to verify tests, present options, execute choice
38
+
39
+ ## When to Stop and Ask for Help
40
+
41
+ **STOP executing immediately when:**
42
+ - Hit a blocker (missing dependency, test fails, instruction unclear)
43
+ - Plan has critical gaps preventing starting
44
+ - You don't understand an instruction
45
+ - Verification fails repeatedly
46
+
47
+ **Ask for clarification rather than guessing.**
48
+
49
+ ## When to Revisit Earlier Steps
50
+
51
+ **Return to Review (Step 1) when:**
52
+ - Partner updates the plan based on your feedback
53
+ - Fundamental approach needs rethinking
54
+
55
+ **Don't force through blockers** - stop and ask.
56
+
57
+ ## Remember
58
+ - Review plan critically first
59
+ - Follow plan steps exactly
60
+ - Don't skip verifications
61
+ - Reference skills when plan says to
62
+ - Stop when blocked, don't guess
63
+ - Never start implementation on main/master branch without explicit user consent
64
+
65
+ ## Complexity Assessment
66
+
67
+ **Lightweight usage:**
68
+ - Execute plan sequentially, skip intermediate checkpoints
69
+
70
+ **Standard usage:**
71
+ - Load plan → execute per task → checkpoint after each task
72
+
73
+ ## Integration
74
+
75
+ **Required workflow skills:**
76
+ - **superpowers:using-git-worktrees** - REQUIRED: Set up isolated workspace before starting
77
+ - **superpowers:writing-plans** - Creates the plan this skill executes
78
+ - **superpowers:finishing-a-development-branch** - Complete development after all tasks
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: finishing-a-development-branch
3
+ description: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
4
+ ---
5
+
6
+ # Finishing a Development Branch
7
+
8
+ ## Overview
9
+
10
+ Guide completion of development work by presenting clear options and handling chosen workflow.
11
+
12
+ **Core principle:** Verify tests → Present options → Execute choice → Clean up.
13
+
14
+ **Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work."
15
+
16
+ ## The Process
17
+
18
+ ### Step 1: Verify Tests
19
+
20
+ **Before presenting options, verify tests pass:**
21
+
22
+ ```bash
23
+ # Run project's test suite
24
+ npm test / cargo test / pytest / go test ./...
25
+ ```
26
+
27
+ **If tests fail:**
28
+ ```
29
+ Tests failing (<N> failures). Must fix before completing:
30
+
31
+ [Show failures]
32
+
33
+ Cannot proceed with merge/PR until tests pass.
34
+ ```
35
+
36
+ Stop. Don't proceed to Step 2.
37
+
38
+ **If tests pass:** Continue to Step 2.
39
+
40
+ ### Step 2: Determine Base Branch
41
+
42
+ ```bash
43
+ # Try common base branches
44
+ git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
45
+ ```
46
+
47
+ Or ask: "This branch split from main - is that correct?"
48
+
49
+ ### Step 3: Present Options
50
+
51
+ Present exactly these 4 options:
52
+
53
+ ```
54
+ Implementation complete. What would you like to do?
55
+
56
+ 1. Merge back to <base-branch> locally
57
+ 2. Push and create a Pull Request
58
+ 3. Keep the branch as-is (I'll handle it later)
59
+ 4. Discard this work
60
+
61
+ Which option?
62
+ ```
63
+
64
+ **Don't add explanation** - keep options concise.
65
+
66
+ ### Step 4: Execute Choice
67
+
68
+ #### Option 1: Merge Locally
69
+
70
+ ```bash
71
+ # Switch to base branch
72
+ git checkout <base-branch>
73
+
74
+ # Pull latest
75
+ git pull
76
+
77
+ # Merge feature branch
78
+ git merge <feature-branch>
79
+
80
+ # Verify tests on merged result
81
+ <test command>
82
+
83
+ # If tests pass
84
+ git branch -d <feature-branch>
85
+ ```
86
+
87
+ Then: Cleanup worktree (Step 5)
88
+
89
+ #### Option 2: Push and Create PR
90
+
91
+ ```bash
92
+ # Push branch
93
+ git push -u origin <feature-branch>
94
+
95
+ # Create PR
96
+ gh pr create --title "<title>" --body "$(cat <<'EOF'
97
+ ## Summary
98
+ <2-3 bullets of what changed>
99
+
100
+ ## Test Plan
101
+ - [ ] <verification steps>
102
+ EOF
103
+ )"
104
+ ```
105
+
106
+ Then: Cleanup worktree (Step 5)
107
+
108
+ #### Option 3: Keep As-Is
109
+
110
+ Report: "Keeping branch <name>. Worktree preserved at <path>."
111
+
112
+ **Don't cleanup worktree.**
113
+
114
+ #### Option 4: Discard
115
+
116
+ **Confirm first:**
117
+ ```
118
+ This will permanently delete:
119
+ - Branch <name>
120
+ - All commits: <commit-list>
121
+ - Worktree at <path>
122
+
123
+ Type 'discard' to confirm.
124
+ ```
125
+
126
+ Wait for exact confirmation.
127
+
128
+ If confirmed:
129
+ ```bash
130
+ git checkout <base-branch>
131
+ git branch -D <feature-branch>
132
+ ```
133
+
134
+ Then: Cleanup worktree (Step 5)
135
+
136
+ ### Step 5: Cleanup Worktree
137
+
138
+ **For Options 1, 2, 4:**
139
+
140
+ Check if in worktree:
141
+ ```bash
142
+ git worktree list | grep $(git branch --show-current)
143
+ ```
144
+
145
+ If yes:
146
+ ```bash
147
+ git worktree remove <worktree-path>
148
+ ```
149
+
150
+ **For Option 3:** Keep worktree.
151
+
152
+ ## Quick Reference
153
+
154
+ | Option | Merge | Push | Keep Worktree | Cleanup Branch |
155
+ |--------|-------|------|---------------|----------------|
156
+ | 1. Merge locally | ✓ | - | - | ✓ |
157
+ | 2. Create PR | - | ✓ | ✓ | - |
158
+ | 3. Keep as-is | - | - | ✓ | - |
159
+ | 4. Discard | - | - | - | ✓ (force) |
160
+
161
+ ## Common Mistakes
162
+
163
+ **Skipping test verification**
164
+ - **Problem:** Merge broken code, create failing PR
165
+ - **Fix:** Always verify tests before offering options
166
+
167
+ **Open-ended questions**
168
+ - **Problem:** "What should I do next?" → ambiguous
169
+ - **Fix:** Present exactly 4 structured options
170
+
171
+ **Automatic worktree cleanup**
172
+ - **Problem:** Remove worktree when might need it (Option 2, 3)
173
+ - **Fix:** Only cleanup for Options 1 and 4
174
+
175
+ **No confirmation for discard**
176
+ - **Problem:** Accidentally delete work
177
+ - **Fix:** Require typed "discard" confirmation
178
+
179
+ ## Red Flags
180
+
181
+ **Never:**
182
+ - Proceed with failing tests
183
+ - Merge without verifying tests on result
184
+ - Delete work without confirmation
185
+ - Force-push without explicit request
186
+
187
+ **Always:**
188
+ - Verify tests before offering options
189
+ - Present exactly 4 options
190
+ - Get typed confirmation for Option 4
191
+ - Clean up worktree for Options 1 & 4 only
192
+
193
+ ## Complexity Assessment
194
+
195
+ **Lightweight usage:**
196
+ - Run tests → merge directly to current branch
197
+
198
+ **Standard usage:**
199
+ - Run tests → determine base branch → present options → execute choice
200
+
201
+ **Deep usage:**
202
+ - Standard + detailed test plan + cleanup worktree
203
+
204
+ ## Integration
205
+
206
+ **Called by:**
207
+ - **subagent-driven-development** (Step 7) - After all tasks complete
208
+ - **executing-plans** (Step 5) - After all batches complete
209
+
210
+ **Pairs with:**
211
+ - **using-git-worktrees** - Cleans up worktree created by that skill