create-claudecraft 1.0.0

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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -0
  3. package/bin/cli.js +2 -0
  4. package/dist/constants.d.ts +71 -0
  5. package/dist/constants.js +128 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +229 -0
  8. package/dist/ink-prompts.d.ts +12 -0
  9. package/dist/ink-prompts.js +363 -0
  10. package/dist/prompts.d.ts +16 -0
  11. package/dist/prompts.js +434 -0
  12. package/dist/scaffold.d.ts +19 -0
  13. package/dist/scaffold.js +303 -0
  14. package/dist/ui.d.ts +27 -0
  15. package/dist/ui.js +254 -0
  16. package/package.json +74 -0
  17. package/templates/app/App.tsx +21 -0
  18. package/templates/base/CLAUDE.md +332 -0
  19. package/templates/base/eslint.config.js +28 -0
  20. package/templates/base/index.html +17 -0
  21. package/templates/base/package.json +43 -0
  22. package/templates/base/postcss.config.js +6 -0
  23. package/templates/base/tailwind.config.js +81 -0
  24. package/templates/base/tsconfig.json +25 -0
  25. package/templates/base/vite.config.ts +16 -0
  26. package/templates/commands/brainstorm.md +6 -0
  27. package/templates/commands/build.md +41 -0
  28. package/templates/commands/execute-plan.md +6 -0
  29. package/templates/commands/lint.md +41 -0
  30. package/templates/commands/ralph.md +113 -0
  31. package/templates/commands/typecheck.md +44 -0
  32. package/templates/commands/write-plan.md +6 -0
  33. package/templates/components/ErrorBoundary.tsx +49 -0
  34. package/templates/components/ui/Button.tsx +60 -0
  35. package/templates/components/ui/CodeBlock.tsx +46 -0
  36. package/templates/components/ui/CopyCommand.tsx +38 -0
  37. package/templates/components/ui/FilePreview.tsx +46 -0
  38. package/templates/components/ui/SkipLink.tsx +7 -0
  39. package/templates/components/ui/ThemeSelector.tsx +41 -0
  40. package/templates/components/ui/UICarousel.tsx +309 -0
  41. package/templates/context/ThemeContext.tsx +61 -0
  42. package/templates/homepage/HomePage.tsx +534 -0
  43. package/templates/homepage/NotFoundPage.tsx +17 -0
  44. package/templates/hooks/README.md +82 -0
  45. package/templates/hooks/check-branch.js +27 -0
  46. package/templates/hooks/typecheck-after-edit.js +51 -0
  47. package/templates/index.css +67 -0
  48. package/templates/lib/utils.ts +9 -0
  49. package/templates/main.tsx +16 -0
  50. package/templates/settings/MCP_SETUP.md +76 -0
  51. package/templates/settings/settings.json +16 -0
  52. package/templates/settings/settings.local.json +37 -0
  53. package/templates/skills/design/a11y-audit/SKILL.md +173 -0
  54. package/templates/skills/design/design-polish/SKILL.md +75 -0
  55. package/templates/skills/design/figma-to-code/SKILL.md +157 -0
  56. package/templates/skills/design/json-ld/SKILL.md +125 -0
  57. package/templates/skills/design/microcopy/SKILL.md +197 -0
  58. package/templates/skills/design/og-image/SKILL.md +157 -0
  59. package/templates/skills/design/ralph-wiggum-loops/SKILL.md +299 -0
  60. package/templates/skills/design/react-best-practices/SKILL.md +106 -0
  61. package/templates/skills/design/react-best-practices/references/react-performance-guidelines.md +143 -0
  62. package/templates/skills/design/seo-review/SKILL.md +96 -0
  63. package/templates/skills/design/sitemap-generator/SKILL.md +66 -0
  64. package/templates/skills/design/testing-patterns/SKILL.md +276 -0
  65. package/templates/skills/design/ui-skills/SKILL.md +85 -0
  66. package/templates/skills/design/visual-iteration/SKILL.md +88 -0
  67. package/templates/skills/workflow/brainstorming/SKILL.md +54 -0
  68. package/templates/skills/workflow/dispatching-parallel-agents/SKILL.md +180 -0
  69. package/templates/skills/workflow/executing-plans/SKILL.md +76 -0
  70. package/templates/skills/workflow/finishing-a-development-branch/SKILL.md +200 -0
  71. package/templates/skills/workflow/receiving-code-review/SKILL.md +213 -0
  72. package/templates/skills/workflow/requesting-code-review/SKILL.md +105 -0
  73. package/templates/skills/workflow/requesting-code-review/code-reviewer.md +146 -0
  74. package/templates/skills/workflow/subagent-driven-development/SKILL.md +240 -0
  75. package/templates/skills/workflow/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  76. package/templates/skills/workflow/subagent-driven-development/implementer-prompt.md +78 -0
  77. package/templates/skills/workflow/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  78. package/templates/skills/workflow/systematic-debugging/CREATION-LOG.md +119 -0
  79. package/templates/skills/workflow/systematic-debugging/SKILL.md +296 -0
  80. package/templates/skills/workflow/systematic-debugging/condition-based-waiting-example.ts +158 -0
  81. package/templates/skills/workflow/systematic-debugging/condition-based-waiting.md +115 -0
  82. package/templates/skills/workflow/systematic-debugging/defense-in-depth.md +122 -0
  83. package/templates/skills/workflow/systematic-debugging/find-polluter.sh +63 -0
  84. package/templates/skills/workflow/systematic-debugging/root-cause-tracing.md +169 -0
  85. package/templates/skills/workflow/systematic-debugging/test-academic.md +14 -0
  86. package/templates/skills/workflow/systematic-debugging/test-pressure-1.md +58 -0
  87. package/templates/skills/workflow/systematic-debugging/test-pressure-2.md +68 -0
  88. package/templates/skills/workflow/systematic-debugging/test-pressure-3.md +69 -0
  89. package/templates/skills/workflow/test-driven-development/SKILL.md +371 -0
  90. package/templates/skills/workflow/test-driven-development/testing-anti-patterns.md +299 -0
  91. package/templates/skills/workflow/using-git-worktrees/SKILL.md +217 -0
  92. package/templates/skills/workflow/using-superpowers/SKILL.md +87 -0
  93. package/templates/skills/workflow/verification-before-completion/SKILL.md +139 -0
  94. package/templates/skills/workflow/writing-plans/SKILL.md +116 -0
  95. package/templates/skills/workflow/writing-skills/SKILL.md +655 -0
  96. package/templates/skills/workflow/writing-skills/anthropic-best-practices.md +1150 -0
  97. package/templates/skills/workflow/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  98. package/templates/skills/workflow/writing-skills/graphviz-conventions.dot +172 -0
  99. package/templates/skills/workflow/writing-skills/persuasion-principles.md +187 -0
  100. package/templates/skills/workflow/writing-skills/render-graphs.js +168 -0
  101. package/templates/skills/workflow/writing-skills/testing-skills-with-subagents.md +384 -0
  102. package/templates/types/index.ts +17 -0
  103. package/templates/vite-env.d.ts +1 -0
@@ -0,0 +1,276 @@
1
+ ---
2
+ name: testing-patterns
3
+ description: Vitest and React Testing Library patterns for React applications. Use when writing unit tests, creating test factories, or following TDD workflow. Triggers on tasks involving tests, testing, Vitest, describe/it blocks, or test-driven development.
4
+ ---
5
+
6
+ # Testing Patterns
7
+
8
+ ## Setup Requirements
9
+
10
+ This template uses Vitest with React Testing Library. Dependencies are pre-installed:
11
+
12
+ ```json
13
+ {
14
+ "devDependencies": {
15
+ "@testing-library/react": "^16.0.1",
16
+ "@testing-library/jest-dom": "^6.6.2",
17
+ "vitest": "^2.1.4"
18
+ },
19
+ "scripts": {
20
+ "test": "vitest",
21
+ "test:coverage": "vitest run --coverage"
22
+ }
23
+ }
24
+ ```
25
+
26
+ ---
27
+
28
+ ## TDD Workflow
29
+
30
+ ### Red-Green-Refactor Cycle
31
+
32
+ 1. **RED:** Write failing test first
33
+ ```tsx
34
+ it('renders button with correct text', () => {
35
+ render(<Button>Click me</Button>);
36
+ expect(screen.getByRole('button')).toHaveTextContent('Click me');
37
+ });
38
+ // ❌ Test fails - component doesn't exist yet
39
+ ```
40
+
41
+ 2. **GREEN:** Write minimal code to pass
42
+ ```tsx
43
+ export function Button({ children }) {
44
+ return <button>{children}</button>;
45
+ }
46
+ // ✅ Test passes
47
+ ```
48
+
49
+ 3. **REFACTOR:** Improve without changing behavior
50
+ ```tsx
51
+ // Add styling while keeping tests passing
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Test Utilities
57
+
58
+ ### Custom Render with Providers
59
+
60
+ ```tsx
61
+ // src/test-utils.tsx
62
+ import { render, RenderOptions } from '@testing-library/react';
63
+ import { ReactElement } from 'react';
64
+ import { ThemeProvider } from '@/context/ThemeContext';
65
+
66
+ function AllProviders({ children }: { children: React.ReactNode }) {
67
+ return <ThemeProvider>{children}</ThemeProvider>;
68
+ }
69
+
70
+ export function renderWithProviders(
71
+ ui: ReactElement,
72
+ options?: Omit<RenderOptions, 'wrapper'>
73
+ ) {
74
+ return render(ui, { wrapper: AllProviders, ...options });
75
+ }
76
+
77
+ export * from '@testing-library/react';
78
+ export { renderWithProviders as render };
79
+ ```
80
+
81
+ ### Factory Functions
82
+
83
+ ```tsx
84
+ // src/test-factories.ts
85
+
86
+ // Props Factory for Components
87
+ export function createButtonProps(
88
+ overrides: Partial<React.ComponentProps<typeof Button>> = {}
89
+ ) {
90
+ return {
91
+ children: 'Click me',
92
+ onClick: vi.fn(),
93
+ variant: 'primary' as const,
94
+ disabled: false,
95
+ ...overrides,
96
+ };
97
+ }
98
+
99
+ // Data Factory
100
+ export function createUser(overrides: Partial<User> = {}): User {
101
+ return {
102
+ id: 'user-1',
103
+ name: 'Test User',
104
+ email: 'test@example.com',
105
+ ...overrides,
106
+ };
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Component Testing Patterns
113
+
114
+ ### Testing User Interactions
115
+
116
+ ```tsx
117
+ import { render, screen } from '@testing-library/react';
118
+ import userEvent from '@testing-library/user-event';
119
+
120
+ describe('Button', () => {
121
+ it('calls onClick when clicked', async () => {
122
+ const user = userEvent.setup();
123
+ const onClick = vi.fn();
124
+
125
+ render(<Button onClick={onClick}>Click</Button>);
126
+ await user.click(screen.getByRole('button'));
127
+
128
+ expect(onClick).toHaveBeenCalledTimes(1);
129
+ });
130
+
131
+ it('does not call onClick when disabled', async () => {
132
+ const user = userEvent.setup();
133
+ const onClick = vi.fn();
134
+
135
+ render(<Button disabled onClick={onClick}>Click</Button>);
136
+ await user.click(screen.getByRole('button'));
137
+
138
+ expect(onClick).not.toHaveBeenCalled();
139
+ });
140
+ });
141
+ ```
142
+
143
+ ### Testing Accessibility
144
+
145
+ ```tsx
146
+ describe('Button accessibility', () => {
147
+ it('decorative elements are hidden from screen readers', () => {
148
+ const { container } = render(<Button>Accessible</Button>);
149
+ const decorativeElements = container.querySelectorAll('[aria-hidden="true"]');
150
+
151
+ decorativeElements.forEach(el => {
152
+ expect(el).toHaveAttribute('aria-hidden', 'true');
153
+ });
154
+ });
155
+
156
+ it('button is keyboard accessible', () => {
157
+ render(<Button>Click</Button>);
158
+ const button = screen.getByRole('button');
159
+ button.focus();
160
+ expect(document.activeElement).toBe(button);
161
+ });
162
+
163
+ it('disabled button is not interactive', () => {
164
+ render(<Button disabled>Disabled</Button>);
165
+ const button = screen.getByRole('button');
166
+ expect(button).toBeDisabled();
167
+ });
168
+ });
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Mocking Patterns
174
+
175
+ ### Mocking Components
176
+
177
+ ```tsx
178
+ vi.mock('@/components/ui/Button', () => ({
179
+ Button: ({ children, onClick }: any) => (
180
+ <button onClick={onClick} data-testid="mock-button">
181
+ {children}
182
+ </button>
183
+ ),
184
+ }));
185
+ ```
186
+
187
+ ### Mocking Animations
188
+
189
+ ```tsx
190
+ // Disable animations in tests
191
+ beforeAll(() => {
192
+ vi.useFakeTimers();
193
+ });
194
+
195
+ afterAll(() => {
196
+ vi.useRealTimers();
197
+ });
198
+
199
+ it('completes animation', () => {
200
+ render(<AnimatedComponent />);
201
+ vi.advanceTimersByTime(500); // Skip 500ms animation
202
+ expect(screen.getByText('Done')).toBeInTheDocument();
203
+ });
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Query Priority
209
+
210
+ Use queries in this order (most to least preferred):
211
+
212
+ 1. **`getByRole`** - Accessible elements
213
+ ```tsx
214
+ screen.getByRole('button', { name: 'Submit' })
215
+ ```
216
+
217
+ 2. **`getByLabelText`** - Form elements
218
+ ```tsx
219
+ screen.getByLabelText('Email')
220
+ ```
221
+
222
+ 3. **`getByText`** - Text content
223
+ ```tsx
224
+ screen.getByText('Welcome')
225
+ ```
226
+
227
+ 4. **`getByTestId`** - Last resort
228
+ ```tsx
229
+ screen.getByTestId('custom-element')
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Anti-Patterns
235
+
236
+ ### ❌ Testing Implementation Details
237
+ ```tsx
238
+ // BAD: Tests internal state
239
+ expect(component.state.isHovered).toBe(true);
240
+
241
+ // GOOD: Tests visible behavior
242
+ await user.hover(button);
243
+ expect(button).toHaveClass('hover-state');
244
+ ```
245
+
246
+ ### ❌ Snapshot Overuse
247
+ ```tsx
248
+ // BAD: Entire component snapshot
249
+ expect(container).toMatchSnapshot();
250
+
251
+ // GOOD: Targeted assertion
252
+ expect(button).toHaveClass('btn-primary');
253
+ ```
254
+
255
+ ### ❌ Manual Data Creation
256
+ ```tsx
257
+ // BAD: Hardcoded in every test
258
+ const user = { id: '1', name: 'Test', ... };
259
+
260
+ // GOOD: Use factory
261
+ const user = createUser({ name: 'Custom' });
262
+ ```
263
+
264
+ ---
265
+
266
+ ## File Organization
267
+
268
+ ```
269
+ src/
270
+ ├── components/
271
+ │ └── ui/
272
+ │ ├── Button.tsx
273
+ │ └── Button.test.tsx # Tests live next to components
274
+ ├── test-utils.tsx # Custom render with providers
275
+ └── test-factories.ts # Data factories
276
+ ```
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: ui-skills
3
+ description: Opinionated constraints for building better interfaces with agents.
4
+ ---
5
+
6
+ # UI Skills
7
+
8
+ When invoked, apply these opinionated constraints for building better interfaces.
9
+
10
+ ## How to use
11
+
12
+ - `/ui-skills`
13
+ Apply these constraints to any UI work in this conversation.
14
+
15
+ - `/ui-skills <file>`
16
+ Review the file against all constraints below and output:
17
+ - violations (quote the exact line/snippet)
18
+ - why it matters (1 short sentence)
19
+ - a concrete fix (code-level suggestion)
20
+
21
+ ## Stack
22
+
23
+ - MUST use Tailwind CSS defaults unless custom values already exist or are explicitly requested
24
+ - MUST use `motion/react` (formerly `framer-motion`) when JavaScript animation is required
25
+ - SHOULD use `tw-animate-css` for entrance and micro-animations in Tailwind CSS
26
+ - MUST use `cn` utility (`clsx` + `tailwind-merge`) for class logic
27
+
28
+ ## Components
29
+
30
+ - MUST use accessible component primitives for anything with keyboard or focus behavior (`Base UI`, `React Aria`, `Radix`)
31
+ - MUST use the project's existing component primitives first
32
+ - NEVER mix primitive systems within the same interaction surface
33
+ - SHOULD prefer [`Base UI`](https://base-ui.com/react/components) for new primitives if compatible with the stack
34
+ - MUST add an `aria-label` to icon-only buttons
35
+ - NEVER rebuild keyboard or focus behavior by hand unless explicitly requested
36
+
37
+ ## Interaction
38
+
39
+ - MUST use an `AlertDialog` for destructive or irreversible actions
40
+ - SHOULD use structural skeletons for loading states
41
+ - NEVER use `h-screen`, use `h-dvh`
42
+ - MUST respect `safe-area-inset` for fixed elements
43
+ - MUST show errors next to where the action happens
44
+ - NEVER block paste in `input` or `textarea` elements
45
+
46
+ ## Animation
47
+
48
+ - NEVER add animation unless it is explicitly requested
49
+ - MUST animate only compositor props (`transform`, `opacity`)
50
+ - NEVER animate layout properties (`width`, `height`, `top`, `left`, `margin`, `padding`)
51
+ - SHOULD avoid animating paint properties (`background`, `color`) except for small, local UI (text, icons)
52
+ - SHOULD use `ease-out` on entrance
53
+ - NEVER exceed `200ms` for interaction feedback
54
+ - MUST pause looping animations when off-screen
55
+ - SHOULD respect `prefers-reduced-motion`
56
+ - NEVER introduce custom easing curves unless explicitly requested
57
+ - SHOULD avoid animating large images or full-screen surfaces
58
+
59
+ ## Typography
60
+
61
+ - MUST use `text-balance` for headings and `text-pretty` for body/paragraphs
62
+ - MUST use `tabular-nums` for data
63
+ - SHOULD use `truncate` or `line-clamp` for dense UI
64
+ - NEVER modify `letter-spacing` (`tracking-*`) unless explicitly requested
65
+
66
+ ## Layout
67
+
68
+ - MUST use a fixed `z-index` scale (no arbitrary `z-*`)
69
+ - SHOULD use `size-*` for square elements instead of `w-*` + `h-*`
70
+
71
+ ## Performance
72
+
73
+ - NEVER animate large `blur()` or `backdrop-filter` surfaces
74
+ - NEVER apply `will-change` outside an active animation
75
+ - NEVER use `useEffect` for anything that can be expressed as render logic
76
+
77
+ ## Design
78
+
79
+ - NEVER use gradients unless explicitly requested
80
+ - NEVER use purple or multicolor gradients
81
+ - NEVER use glow effects as primary affordances
82
+ - SHOULD use Tailwind CSS default shadow scale unless explicitly requested
83
+ - MUST give empty states one clear next action
84
+ - SHOULD limit accent color usage to one per view
85
+ - SHOULD use existing theme or Tailwind CSS color tokens before introducing new ones
@@ -0,0 +1,88 @@
1
+ # Visual Iteration Skill
2
+
3
+ Use this skill when implementing designs from mockups or iterating on visual output.
4
+
5
+ ## Trigger
6
+
7
+ Use when user:
8
+ - Shares a screenshot or design mockup
9
+ - Asks to "implement this design"
10
+ - Wants to iterate on visual appearance
11
+ - Says "this doesn't look right"
12
+
13
+ ## Process
14
+
15
+ ### Phase 1: Analyze Reference
16
+
17
+ When given a visual reference:
18
+
19
+ 1. **Describe what you see** (verify understanding)
20
+ - Layout structure
21
+ - Spacing patterns
22
+ - Typography choices
23
+ - Color usage
24
+ - Visual hierarchy
25
+
26
+ 2. **Ask clarifying questions** if needed
27
+ - "Should this match exactly or capture the style?"
28
+ - "Any elements to skip or modify for our context?"
29
+
30
+ ### Phase 2: Implement
31
+
32
+ 1. Generate code using project's design system
33
+ 2. Prefer DaisyUI classes over custom CSS
34
+ 3. Use Tailwind utilities for fine-tuning
35
+ 4. Keep code minimal—don't over-engineer
36
+
37
+ ### Phase 3: Review Cycle
38
+
39
+ After implementation:
40
+
41
+ ```
42
+ I've implemented the design. To continue iterating:
43
+
44
+ 1. Take a screenshot of the result
45
+ 2. Paste it here
46
+ 3. Tell me what to adjust
47
+
48
+ Common adjustments:
49
+ - "More spacing between X and Y"
50
+ - "Make the heading larger"
51
+ - "The colors feel off—try darker background"
52
+ - "Align this to the left"
53
+ ```
54
+
55
+ ## Best Practices
56
+
57
+ ### DO
58
+ - Reference specific measurements ("add 16px gap")
59
+ - Compare to the original ("match the border radius from the mockup")
60
+ - Work in small increments
61
+ - Use semantic color names from the design system
62
+
63
+ ### DON'T
64
+ - Guess at values—ask if unsure
65
+ - Add features not in the design
66
+ - Over-complicate with unnecessary abstractions
67
+ - Ignore the existing component patterns
68
+
69
+ ## Iteration Prompts
70
+
71
+ Helpful prompts for the user:
72
+
73
+ ```
74
+ "The spacing feels cramped—add more breathing room"
75
+ "Make the text hierarchy clearer"
76
+ "This button should stand out more"
77
+ "Match the rounded corners from my mockup"
78
+ "The alignment is off on mobile"
79
+ ```
80
+
81
+ ## Output
82
+
83
+ After each iteration:
84
+ - Show the specific changes made
85
+ - Note any assumptions
86
+ - Ask if ready to commit or continue iterating
87
+
88
+ Typical cycle: 2-3 iterations to match a design.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: brainstorming
3
+ description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
4
+ ---
5
+
6
+ # Brainstorming Ideas Into Designs
7
+
8
+ ## Overview
9
+
10
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
11
+
12
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
13
+
14
+ ## The Process
15
+
16
+ **Understanding the idea:**
17
+ - Check out the current project state first (files, docs, recent commits)
18
+ - Ask questions one at a time to refine the idea
19
+ - Prefer multiple choice questions when possible, but open-ended is fine too
20
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
21
+ - Focus on understanding: purpose, constraints, success criteria
22
+
23
+ **Exploring approaches:**
24
+ - Propose 2-3 different approaches with trade-offs
25
+ - Present options conversationally with your recommendation and reasoning
26
+ - Lead with your recommended option and explain why
27
+
28
+ **Presenting the design:**
29
+ - Once you believe you understand what you're building, present the design
30
+ - Break it into sections of 200-300 words
31
+ - Ask after each section whether it looks right so far
32
+ - Cover: architecture, components, data flow, error handling, testing
33
+ - Be ready to go back and clarify if something doesn't make sense
34
+
35
+ ## After the Design
36
+
37
+ **Documentation:**
38
+ - Write the validated design to `docs/plans/YYYY-MM-DD-<topic>-design.md`
39
+ - Use elements-of-style:writing-clearly-and-concisely skill if available
40
+ - Commit the design document to git
41
+
42
+ **Implementation (if continuing):**
43
+ - Ask: "Ready to set up for implementation?"
44
+ - Use superpowers:using-git-worktrees to create isolated workspace
45
+ - Use superpowers:writing-plans to create detailed implementation plan
46
+
47
+ ## Key Principles
48
+
49
+ - **One question at a time** - Don't overwhelm with multiple questions
50
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
51
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
52
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
53
+ - **Incremental validation** - Present design in sections, validate each
54
+ - **Be flexible** - Go back and clarify when something doesn't make sense
@@ -0,0 +1,180 @@
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
+ 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.
11
+
12
+ **Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.
13
+
14
+ ## When to Use
15
+
16
+ ```dot
17
+ digraph when_to_use {
18
+ "Multiple failures?" [shape=diamond];
19
+ "Are they independent?" [shape=diamond];
20
+ "Single agent investigates all" [shape=box];
21
+ "One agent per problem domain" [shape=box];
22
+ "Can they work in parallel?" [shape=diamond];
23
+ "Sequential agents" [shape=box];
24
+ "Parallel dispatch" [shape=box];
25
+
26
+ "Multiple failures?" -> "Are they independent?" [label="yes"];
27
+ "Are they independent?" -> "Single agent investigates all" [label="no - related"];
28
+ "Are they independent?" -> "Can they work in parallel?" [label="yes"];
29
+ "Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
30
+ "Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
31
+ }
32
+ ```
33
+
34
+ **Use when:**
35
+ - 3+ test files failing with different root causes
36
+ - Multiple subsystems broken independently
37
+ - Each problem can be understood without context from others
38
+ - No shared state between investigations
39
+
40
+ **Don't use when:**
41
+ - Failures are related (fix one might fix others)
42
+ - Need to understand full system state
43
+ - Agents would interfere with each other
44
+
45
+ ## The Pattern
46
+
47
+ ### 1. Identify Independent Domains
48
+
49
+ Group failures by what's broken:
50
+ - File A tests: Tool approval flow
51
+ - File B tests: Batch completion behavior
52
+ - File C tests: Abort functionality
53
+
54
+ Each domain is independent - fixing tool approval doesn't affect abort tests.
55
+
56
+ ### 2. Create Focused Agent Tasks
57
+
58
+ Each agent gets:
59
+ - **Specific scope:** One test file or subsystem
60
+ - **Clear goal:** Make these tests pass
61
+ - **Constraints:** Don't change other code
62
+ - **Expected output:** Summary of what you found and fixed
63
+
64
+ ### 3. Dispatch in Parallel
65
+
66
+ ```typescript
67
+ // In Claude Code / AI environment
68
+ Task("Fix agent-tool-abort.test.ts failures")
69
+ Task("Fix batch-completion-behavior.test.ts failures")
70
+ Task("Fix tool-approval-race-conditions.test.ts failures")
71
+ // All three run concurrently
72
+ ```
73
+
74
+ ### 4. Review and Integrate
75
+
76
+ When agents return:
77
+ - Read each summary
78
+ - Verify fixes don't conflict
79
+ - Run full test suite
80
+ - Integrate all changes
81
+
82
+ ## Agent Prompt Structure
83
+
84
+ Good agent prompts are:
85
+ 1. **Focused** - One clear problem domain
86
+ 2. **Self-contained** - All context needed to understand the problem
87
+ 3. **Specific about output** - What should the agent return?
88
+
89
+ ```markdown
90
+ Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
91
+
92
+ 1. "should abort tool with partial output capture" - expects 'interrupted at' in message
93
+ 2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
94
+ 3. "should properly track pendingToolCount" - expects 3 results but gets 0
95
+
96
+ These are timing/race condition issues. Your task:
97
+
98
+ 1. Read the test file and understand what each test verifies
99
+ 2. Identify root cause - timing issues or actual bugs?
100
+ 3. Fix by:
101
+ - Replacing arbitrary timeouts with event-based waiting
102
+ - Fixing bugs in abort implementation if found
103
+ - Adjusting test expectations if testing changed behavior
104
+
105
+ Do NOT just increase timeouts - find the real issue.
106
+
107
+ Return: Summary of what you found and what you fixed.
108
+ ```
109
+
110
+ ## Common Mistakes
111
+
112
+ **❌ Too broad:** "Fix all the tests" - agent gets lost
113
+ **✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope
114
+
115
+ **❌ No context:** "Fix the race condition" - agent doesn't know where
116
+ **✅ Context:** Paste the error messages and test names
117
+
118
+ **❌ No constraints:** Agent might refactor everything
119
+ **✅ Constraints:** "Do NOT change production code" or "Fix tests only"
120
+
121
+ **❌ Vague output:** "Fix it" - you don't know what changed
122
+ **✅ Specific:** "Return summary of root cause and changes"
123
+
124
+ ## When NOT to Use
125
+
126
+ **Related failures:** Fixing one might fix others - investigate together first
127
+ **Need full context:** Understanding requires seeing entire system
128
+ **Exploratory debugging:** You don't know what's broken yet
129
+ **Shared state:** Agents would interfere (editing same files, using same resources)
130
+
131
+ ## Real Example from Session
132
+
133
+ **Scenario:** 6 test failures across 3 files after major refactoring
134
+
135
+ **Failures:**
136
+ - agent-tool-abort.test.ts: 3 failures (timing issues)
137
+ - batch-completion-behavior.test.ts: 2 failures (tools not executing)
138
+ - tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
139
+
140
+ **Decision:** Independent domains - abort logic separate from batch completion separate from race conditions
141
+
142
+ **Dispatch:**
143
+ ```
144
+ Agent 1 → Fix agent-tool-abort.test.ts
145
+ Agent 2 → Fix batch-completion-behavior.test.ts
146
+ Agent 3 → Fix tool-approval-race-conditions.test.ts
147
+ ```
148
+
149
+ **Results:**
150
+ - Agent 1: Replaced timeouts with event-based waiting
151
+ - Agent 2: Fixed event structure bug (threadId in wrong place)
152
+ - Agent 3: Added wait for async tool execution to complete
153
+
154
+ **Integration:** All fixes independent, no conflicts, full suite green
155
+
156
+ **Time saved:** 3 problems solved in parallel vs sequentially
157
+
158
+ ## Key Benefits
159
+
160
+ 1. **Parallelization** - Multiple investigations happen simultaneously
161
+ 2. **Focus** - Each agent has narrow scope, less context to track
162
+ 3. **Independence** - Agents don't interfere with each other
163
+ 4. **Speed** - 3 problems solved in time of 1
164
+
165
+ ## Verification
166
+
167
+ After agents return:
168
+ 1. **Review each summary** - Understand what changed
169
+ 2. **Check for conflicts** - Did agents edit same code?
170
+ 3. **Run full suite** - Verify all fixes work together
171
+ 4. **Spot check** - Agents can make systematic errors
172
+
173
+ ## Real-World Impact
174
+
175
+ From debugging session (2025-10-03):
176
+ - 6 failures across 3 files
177
+ - 3 agents dispatched in parallel
178
+ - All investigations completed concurrently
179
+ - All fixes integrated successfully
180
+ - Zero conflicts between agent changes