swellai 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 (130) hide show
  1. package/README.md +711 -0
  2. package/dist/agents/linear-agent.d.ts +32 -0
  3. package/dist/agents/linear-agent.d.ts.map +1 -0
  4. package/dist/agents/linear-agent.js +263 -0
  5. package/dist/agents/linear-agent.js.map +1 -0
  6. package/dist/agents/planning-agent.d.ts +36 -0
  7. package/dist/agents/planning-agent.d.ts.map +1 -0
  8. package/dist/agents/planning-agent.js +248 -0
  9. package/dist/agents/planning-agent.js.map +1 -0
  10. package/dist/cli/index.d.ts +3 -0
  11. package/dist/cli/index.d.ts.map +1 -0
  12. package/dist/cli/index.js +102 -0
  13. package/dist/cli/index.js.map +1 -0
  14. package/dist/cli/install.d.ts +11 -0
  15. package/dist/cli/install.d.ts.map +1 -0
  16. package/dist/cli/install.js +257 -0
  17. package/dist/cli/install.js.map +1 -0
  18. package/dist/cli/manifest.d.ts +27 -0
  19. package/dist/cli/manifest.d.ts.map +1 -0
  20. package/dist/cli/manifest.js +65 -0
  21. package/dist/cli/manifest.js.map +1 -0
  22. package/dist/index.d.ts +17 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +17 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/lib/claude-agent-sdk.d.ts +73 -0
  27. package/dist/lib/claude-agent-sdk.d.ts.map +1 -0
  28. package/dist/lib/claude-agent-sdk.js +114 -0
  29. package/dist/lib/claude-agent-sdk.js.map +1 -0
  30. package/dist/lib/conversation-logger.d.ts +66 -0
  31. package/dist/lib/conversation-logger.d.ts.map +1 -0
  32. package/dist/lib/conversation-logger.js +159 -0
  33. package/dist/lib/conversation-logger.js.map +1 -0
  34. package/dist/lib/opencode.d.ts +68 -0
  35. package/dist/lib/opencode.d.ts.map +1 -0
  36. package/dist/lib/opencode.js +151 -0
  37. package/dist/lib/opencode.js.map +1 -0
  38. package/dist/lib/turso-schema.d.ts +13 -0
  39. package/dist/lib/turso-schema.d.ts.map +1 -0
  40. package/dist/lib/turso-schema.js +69 -0
  41. package/dist/lib/turso-schema.js.map +1 -0
  42. package/dist/lib/turso.d.ts +56 -0
  43. package/dist/lib/turso.d.ts.map +1 -0
  44. package/dist/lib/turso.js +144 -0
  45. package/dist/lib/turso.js.map +1 -0
  46. package/dist/lib/types.d.ts +31 -0
  47. package/dist/lib/types.d.ts.map +1 -0
  48. package/dist/lib/types.js +20 -0
  49. package/dist/lib/types.js.map +1 -0
  50. package/dist/lib/utils.d.ts +34 -0
  51. package/dist/lib/utils.d.ts.map +1 -0
  52. package/dist/lib/utils.js +72 -0
  53. package/dist/lib/utils.js.map +1 -0
  54. package/dist/scripts/build-templates.d.ts +17 -0
  55. package/dist/scripts/build-templates.d.ts.map +1 -0
  56. package/dist/scripts/build-templates.js +132 -0
  57. package/dist/scripts/build-templates.js.map +1 -0
  58. package/dist/scripts/claude-agent-runner.d.ts +28 -0
  59. package/dist/scripts/claude-agent-runner.d.ts.map +1 -0
  60. package/dist/scripts/claude-agent-runner.js +278 -0
  61. package/dist/scripts/claude-agent-runner.js.map +1 -0
  62. package/dist/src/agents/linear-agent.d.ts +32 -0
  63. package/dist/src/agents/linear-agent.d.ts.map +1 -0
  64. package/dist/src/agents/linear-agent.js +285 -0
  65. package/dist/src/agents/linear-agent.js.map +1 -0
  66. package/dist/src/agents/planning-agent.d.ts +36 -0
  67. package/dist/src/agents/planning-agent.d.ts.map +1 -0
  68. package/dist/src/agents/planning-agent.js +248 -0
  69. package/dist/src/agents/planning-agent.js.map +1 -0
  70. package/dist/src/cli/index.d.ts +3 -0
  71. package/dist/src/cli/index.d.ts.map +1 -0
  72. package/dist/src/cli/index.js +102 -0
  73. package/dist/src/cli/index.js.map +1 -0
  74. package/dist/src/cli/install.d.ts +11 -0
  75. package/dist/src/cli/install.d.ts.map +1 -0
  76. package/dist/src/cli/install.js +257 -0
  77. package/dist/src/cli/install.js.map +1 -0
  78. package/dist/src/cli/manifest.d.ts +27 -0
  79. package/dist/src/cli/manifest.d.ts.map +1 -0
  80. package/dist/src/cli/manifest.js +65 -0
  81. package/dist/src/cli/manifest.js.map +1 -0
  82. package/dist/src/index.d.ts +17 -0
  83. package/dist/src/index.d.ts.map +1 -0
  84. package/dist/src/index.js +17 -0
  85. package/dist/src/index.js.map +1 -0
  86. package/dist/src/lib/claude-agent-sdk.d.ts +73 -0
  87. package/dist/src/lib/claude-agent-sdk.d.ts.map +1 -0
  88. package/dist/src/lib/claude-agent-sdk.js +114 -0
  89. package/dist/src/lib/claude-agent-sdk.js.map +1 -0
  90. package/dist/src/lib/conversation-logger.d.ts +66 -0
  91. package/dist/src/lib/conversation-logger.d.ts.map +1 -0
  92. package/dist/src/lib/conversation-logger.js +159 -0
  93. package/dist/src/lib/conversation-logger.js.map +1 -0
  94. package/dist/src/lib/opencode.d.ts +153 -0
  95. package/dist/src/lib/opencode.d.ts.map +1 -0
  96. package/dist/src/lib/opencode.js +153 -0
  97. package/dist/src/lib/opencode.js.map +1 -0
  98. package/dist/src/lib/turso-schema.d.ts +13 -0
  99. package/dist/src/lib/turso-schema.d.ts.map +1 -0
  100. package/dist/src/lib/turso-schema.js +69 -0
  101. package/dist/src/lib/turso-schema.js.map +1 -0
  102. package/dist/src/lib/turso.d.ts +56 -0
  103. package/dist/src/lib/turso.d.ts.map +1 -0
  104. package/dist/src/lib/turso.js +144 -0
  105. package/dist/src/lib/turso.js.map +1 -0
  106. package/dist/src/lib/types.d.ts +31 -0
  107. package/dist/src/lib/types.d.ts.map +1 -0
  108. package/dist/src/lib/types.js +20 -0
  109. package/dist/src/lib/types.js.map +1 -0
  110. package/dist/src/lib/utils.d.ts +34 -0
  111. package/dist/src/lib/utils.d.ts.map +1 -0
  112. package/dist/src/lib/utils.js +72 -0
  113. package/dist/src/lib/utils.js.map +1 -0
  114. package/package.json +63 -0
  115. package/templates/.env.example +51 -0
  116. package/templates/agents/codebase-analyzer.md +121 -0
  117. package/templates/agents/codebase-locator.md +105 -0
  118. package/templates/agents/coding-agent.md +187 -0
  119. package/templates/agents/debug-agent.md +300 -0
  120. package/templates/prompts/consolidate-and-create-linear.md +282 -0
  121. package/templates/prompts/implementation.md +94 -0
  122. package/templates/prompts/plan-generation.md +171 -0
  123. package/templates/prompts/review.md +39 -0
  124. package/templates/prompts/verify.md +80 -0
  125. package/templates/scripts/claude-agent-runner.js +12887 -0
  126. package/templates/scripts/detect-runtime.sh +95 -0
  127. package/templates/scripts/linear-agent.js +1753 -0
  128. package/templates/scripts/planning-agent.js +1738 -0
  129. package/templates/workflows/claude-implement.yml +931 -0
  130. package/templates/workflows/claude-plan.yml +301 -0
package/README.md ADDED
@@ -0,0 +1,711 @@
1
+ **Parallel AI coding. Automatic best-of-N selection.**
2
+
3
+ # Claude Parallel Implementation Workflow
4
+
5
+ A reusable GitHub Actions workflow that runs parallel Claude Code implementations, automatically reviews them, and creates a draft PR with the best implementation.
6
+
7
+ ## Installation
8
+
9
+ Install claude-parallel into your repository:
10
+
11
+ ```bash
12
+ bunx swellai
13
+ ```
14
+
15
+ This will add:
16
+ - GitHub Actions workflows for planning and implementation
17
+ - Scripts for AI agents (planning, linear, claude agent runner)
18
+ - Prompt templates
19
+ - Claude Code agent definitions
20
+
21
+ ### CLI Options
22
+
23
+ | Flag | Description |
24
+ |------|-------------|
25
+ | `--help` | Show usage information |
26
+ | `--yes` | Skip confirmation prompts |
27
+ | `--dry-run` | Preview changes without installing |
28
+ | `--force` | Overwrite all files, including user-modified ones |
29
+
30
+ See [docs/installer.md](docs/installer.md) for detailed documentation.
31
+
32
+ ## How It Works
33
+
34
+ 1. **Triggered by Linear issues** or manual dispatch
35
+ 2. **Runs N parallel implementations** (default: 3) using GitHub Actions matrix
36
+ 3. **Auto-detects runtime** (Node.js, Python, Go, Rust, etc.) and sets up the environment
37
+ 4. **Reviews all implementations** with Claude Code
38
+ 5. **Automatically selects the best** based on code quality and completeness
39
+ 6. **Creates a draft PR** for the winning implementation
40
+
41
+ ## Quick Start (GitHub Actions)
42
+
43
+ Add this workflow to your repository:
44
+
45
+ ```yaml
46
+ # .github/workflows/claude-implement.yml
47
+ name: Claude Implement Issue
48
+
49
+ on:
50
+ issues:
51
+ types: [labeled]
52
+ workflow_dispatch:
53
+ inputs:
54
+ issue_number:
55
+ description: 'Issue number to implement'
56
+ required: true
57
+ type: number
58
+
59
+ jobs:
60
+ implement:
61
+ if: github.event.label.name == 'claude-implement' || github.event_name == 'workflow_dispatch'
62
+ uses: mkrueger12/claude-parallel/.github/workflows/reusable-implement-issue.yml@main
63
+ with:
64
+ issue_number: ${{ github.event.inputs.issue_number }}
65
+ event_name: ${{ github.event_name }}
66
+ event_issue_number: ${{ github.event.issue.number }}
67
+ secrets:
68
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
69
+ GH_PAT: ${{ secrets.GH_PAT }}
70
+ ```
71
+
72
+ ### Required Secrets
73
+
74
+ | Secret | Description |
75
+ |--------|-------------|
76
+ | `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN` | Claude authentication. Use either your Anthropic API key or Claude Code OAuth token (both work, choose one) |
77
+ | `GH_PAT` | GitHub Personal Access Token with repo permissions |
78
+
79
+ **Note:** For the implementation workflow, both `ANTHROPIC_API_KEY` and `CLAUDE_CODE_OAUTH_TOKEN` are supported. The workflow will use whichever is available.
80
+
81
+ ### Workflow Inputs
82
+
83
+ | Input | Default | Description |
84
+ |-------|---------|-------------|
85
+ | `num_implementations` | `3` | Number of parallel implementations |
86
+ | `claude_model` | `claude-opus-4-5-20251101` | Claude model to use |
87
+ | `prompts_repo` | `mkrueger12/claude-parallel` | Repository containing prompts |
88
+ | `prompts_ref` | `main` | Git ref for prompts repository |
89
+ | `bot_name` | `Claude Parallel Bot` | Git author name for commits |
90
+ | `bot_email` | `bot@claude-parallel.dev` | Git author email |
91
+ | `dry_run` | `false` | Skip Claude, use mock responses |
92
+
93
+ ### Usage
94
+
95
+ 1. **Via Label**: Add the `claude-implement` label to any issue
96
+ 2. **Via Manual Trigger**: Go to Actions → Claude Implement Issue → Run workflow
97
+
98
+ ---
99
+
100
+ ## Multi-Provider Plan Generation
101
+
102
+ A GitHub Actions workflow that generates implementation plans using multiple AI providers (Anthropic Claude, Google Gemini, OpenAI GPT-4) and creates Linear issues for tracking.
103
+
104
+ ### How It Works
105
+
106
+ 1. **Triggered by issue label** (`claude-plan`) or manual dispatch
107
+ 2. **Single workflow job** runs a unified script that:
108
+ - Generates 3 plans in parallel using Anthropic Claude, OpenAI GPT-4, and Google Gemini
109
+ - Consolidates plans into a unified implementation strategy
110
+ - Creates Linear issues (parent + sub-issues) in the same session
111
+ 3. **Posts summary comment** on the GitHub issue with links to Linear
112
+
113
+ The entire process runs in one execution - no intermediate file artifacts or job dependencies.
114
+
115
+ ### Quick Start
116
+
117
+ Add this workflow to your repository:
118
+
119
+ ```yaml
120
+ # .github/workflows/multi-provider-plan.yml
121
+ name: Multi-Provider Plan Generation
122
+
123
+ on:
124
+ issues:
125
+ types: [opened, labeled]
126
+ workflow_dispatch:
127
+ inputs:
128
+ issue_number:
129
+ description: 'Issue number to generate plan for'
130
+ required: true
131
+ type: number
132
+ linear_project_id:
133
+ description: 'Linear project ID to add issues to (optional)'
134
+ required: false
135
+ type: string
136
+ anthropic_model:
137
+ description: 'Anthropic model to use'
138
+ required: false
139
+ type: string
140
+ default: 'claude-opus-4-5-20251101'
141
+ openai_model:
142
+ description: 'OpenAI model to use'
143
+ required: false
144
+ type: string
145
+ default: 'gpt-5.2'
146
+ google_model:
147
+ description: 'Google model to use'
148
+ required: false
149
+ type: string
150
+ default: 'gemini-3-pro-preview'
151
+
152
+ jobs:
153
+ plan:
154
+ if: github.event.label.name == 'claude-plan' || github.event_name == 'workflow_dispatch'
155
+ uses: mkrueger12/claude-parallel/.github/workflows/multi-provider-plan.yml@main
156
+ with:
157
+ issue_number: ${{ github.event.inputs.issue_number }}
158
+ event_name: ${{ github.event_name }}
159
+ event_issue_number: ${{ github.event.issue.number }}
160
+ linear_project_id: ${{ github.event.inputs.linear_project_id }}
161
+ anthropic_model: ${{ github.event.inputs.anthropic_model || 'claude-opus-4-5-20251101' }}
162
+ openai_model: ${{ github.event.inputs.openai_model || 'gpt-5.2' }}
163
+ google_model: ${{ github.event.inputs.google_model || 'gemini-3-pro-preview' }}
164
+ secrets:
165
+ CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
166
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
167
+ GOOGLE_GENERATIVE_AI_API_KEY: ${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }}
168
+ LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
169
+ LINEAR_TEAM_ID: ${{ secrets.LINEAR_TEAM_ID }}
170
+ LINEAR_PROJECT_ID: ${{ secrets.LINEAR_PROJECT_ID }}
171
+ GH_PAT: ${{ secrets.GH_PAT }}
172
+ ```
173
+
174
+ ### Required Secrets
175
+
176
+ | Secret | Required | Description |
177
+ |--------|----------|-------------|
178
+ | `CLAUDE_CODE_OAUTH_TOKEN` | Yes | Claude Code OAuth token for Claude authentication |
179
+ | `OPENAI_API_KEY` | Yes | OpenAI API key for GPT-4 |
180
+ | `GOOGLE_GENERATIVE_AI_API_KEY` | Yes | Google AI API key for Gemini |
181
+ | `LINEAR_API_KEY` | Yes | Linear Personal API key ([get yours here](https://linear.app/settings/api)) |
182
+ | `LINEAR_TEAM_ID` | Yes | Linear team ID or name for issue creation |
183
+ | `LINEAR_PROJECT_ID` | No | Linear project to add issues to (optional) |
184
+ | `GH_PAT` | Yes | GitHub Personal Access Token with `issues: write` permission |
185
+
186
+ ### Workflow Inputs
187
+
188
+ For manual workflow dispatch (`workflow_dispatch`), you can customize the following:
189
+
190
+ | Input | Default | Description |
191
+ |-------|---------|-------------|
192
+ | `issue_number` | (required) | GitHub issue number to generate plan for |
193
+ | `linear_project_id` | (none) | Linear project ID to add issues to |
194
+ | `anthropic_model` | `claude-opus-4-5-20251101` | Anthropic model to use for plan generation |
195
+ | `openai_model` | `gpt-5.2` | OpenAI model to use for plan generation |
196
+ | `google_model` | `gemini-3-pro-preview` | Google model to use for plan generation |
197
+
198
+ ### Usage
199
+
200
+ #### Via Label (Automatic)
201
+
202
+ 1. Create or open a GitHub issue describing the feature or task
203
+ 2. Add the `claude-plan` label to the issue
204
+ 3. The workflow automatically triggers and generates plans
205
+ 4. Wait for the workflow to complete (usually 2-5 minutes)
206
+ 5. Check the issue comments for a summary with Linear issue links
207
+
208
+ #### Via Manual Dispatch
209
+
210
+ 1. Go to **Actions** → **Multi-Provider Plan Generation** → **Run workflow**
211
+ 2. Enter the issue number
212
+ 3. (Optional) Override model selections
213
+ 4. (Optional) Specify a Linear project ID
214
+ 5. Click **Run workflow**
215
+ 6. Monitor the workflow in the Actions tab
216
+
217
+ #### Finding Generated Linear Issues
218
+
219
+ After the workflow completes:
220
+ - A comment will be posted on the GitHub issue with links to:
221
+ - **Parent Linear issue**: Contains the consolidated implementation plan
222
+ - **Sub-issues**: One for each implementation step
223
+ - Open Linear and navigate to your team to see the issues
224
+ - Sub-issues are linked to the parent issue (visible in Linear's issue hierarchy)
225
+
226
+ ### How It Works (Technical Details)
227
+
228
+ The workflow uses a streamlined single-script approach:
229
+
230
+ 1. **Plan Generation Phase**: A single OpenCode server instance starts with all 3 provider configurations (Anthropic, OpenAI, Google) plus Linear MCP access
231
+ 2. **Parallel Generation**: Three sessions run in parallel, each generating an implementation plan from a different AI provider
232
+ 3. **Consolidation Phase**: Once all plans are generated (in memory, no files), a new session starts with Claude that:
233
+ - Receives all three plans as context
234
+ - Analyzes and consolidates them into a unified strategy
235
+ - Uses Linear MCP tools to create parent issue + sub-issues
236
+ - All in the same AI session for maximum context retention
237
+
238
+ **Key Benefits:**
239
+ - No intermediate file artifacts needed
240
+ - Single workflow job (faster, simpler)
241
+ - AI has full context when creating Linear issues
242
+ - Fewer moving parts = easier to maintain
243
+
244
+ ### Customization
245
+
246
+ #### Customizing Prompts
247
+
248
+ Prompts are stored in `prompts/` for easy customization:
249
+
250
+ **Plan Generation Prompt** (`prompts/plan-generation.md`):
251
+ ```markdown
252
+ You are a senior software engineer creating an implementation plan.
253
+
254
+ Issue: {{ISSUE_TITLE}}
255
+ Description: {{ISSUE_BODY}}
256
+
257
+ Create a detailed plan with:
258
+ - Overview of the approach
259
+ - Step-by-step implementation tasks
260
+ - Potential risks and mitigations
261
+ - Required dependencies
262
+ ```
263
+
264
+ **Consolidation Prompt** (`prompts/consolidate-and-create-linear.md`):
265
+ ```markdown
266
+ Analyze these 3 implementation plans:
267
+
268
+ Anthropic Claude: {{ANTHROPIC_PLAN}}
269
+ OpenAI GPT-4: {{OPENAI_PLAN}}
270
+ Google Gemini: {{GOOGLE_PLAN}}
271
+
272
+ Consolidate into a unified strategy, then create Linear issues using the
273
+ mcp__linear-server__create_issue tool.
274
+ ```
275
+
276
+ Available placeholders:
277
+ - `{{ISSUE_TITLE}}` - GitHub issue title
278
+ - `{{ISSUE_BODY}}` - GitHub issue description
279
+ - `{{ANTHROPIC_PLAN}}` - Plan from Claude
280
+ - `{{OPENAI_PLAN}}` - Plan from GPT-4
281
+ - `{{GOOGLE_PLAN}}` - Plan from Gemini
282
+ - `{{LINEAR_TEAM_ID}}` - Your Linear team ID
283
+ - `{{LINEAR_PROJECT_ID}}` - Linear project ID (if specified)
284
+ - `{{GITHUB_ISSUE_URL}}` - Link to the original GitHub issue
285
+
286
+ #### Changing Default Models
287
+
288
+ You can change the default models used for plan generation:
289
+
290
+ 1. **Via workflow inputs** (manual dispatch):
291
+ - Use the workflow dispatch UI to select different models each time
292
+
293
+ 2. **Via workflow file** (for your organization):
294
+ - Fork this repository
295
+ - Edit `.github/workflows/multi-provider-plan.yml`
296
+ - Update the `default` values under `workflow_dispatch.inputs`
297
+ - Reference your fork in your workflows
298
+
299
+ Example model options:
300
+ - **Anthropic**: `claude-opus-4-5-20251101` (default), `claude-sonnet-4-20250514`, `claude-3-5-sonnet-20241022`
301
+ - **OpenAI**: `gpt-5.2` (default), `gpt-4-turbo`, `gpt-4`
302
+ - **Google**: `gemini-3-pro` (default), `gemini-1.5-pro`, `gemini-1.5-flash`
303
+
304
+ #### Adding or Removing Providers
305
+
306
+ To customize which AI providers are used:
307
+
308
+ 1. Fork this repository
309
+ 2. Edit `.github/scripts/generate-and-create-linear.ts`:
310
+ - Update the `PROVIDERS` array to add/remove provider configurations
311
+ - Adjust the provider configurations in the `createOpencode()` call
312
+ - Update the consolidation prompt to reference the correct number of plans
313
+ 3. Update `.github/actions/setup-opencode/action.yml`:
314
+ - Add/remove API key inputs and environment variables
315
+ 4. Update `prompts/consolidate-and-create-linear.md`:
316
+ - Adjust placeholders to match your providers
317
+ 5. Update your workflow secrets accordingly
318
+
319
+ ### Troubleshooting
320
+
321
+ #### "Linear API key is invalid"
322
+
323
+ Ensure your `LINEAR_API_KEY` secret is set correctly:
324
+ 1. Go to [Linear Settings → API](https://linear.app/settings/api)
325
+ 2. Create a new Personal API key
326
+ 3. Add it to GitHub Secrets as `LINEAR_API_KEY`
327
+
328
+ #### "Team not found"
329
+
330
+ Your `LINEAR_TEAM_ID` should be either:
331
+ - The team's ID (e.g., `abc123...`)
332
+ - The team's key/name (e.g., `ENG` or `PRODUCT`)
333
+
334
+ Find your team ID in Linear:
335
+ 1. Go to your team in Linear
336
+ 2. Check the URL: `https://linear.app/{workspace}/{team-key}/...`
337
+ 3. Use the `{team-key}` as your `LINEAR_TEAM_ID`
338
+
339
+ #### Workflow doesn't trigger on label
340
+
341
+ Make sure:
342
+ 1. The label name is exactly `claude-plan` (case-sensitive)
343
+ 2. The workflow file is on your default branch (usually `main`)
344
+ 3. You have the required secrets configured
345
+
346
+ #### Plans are similar or identical
347
+
348
+ This can happen if:
349
+ - The issue description is very specific, leaving little room for interpretation
350
+ - Models have been trained on similar data
351
+ - The prompts are too prescriptive
352
+
353
+ To get more diverse plans:
354
+ - Edit `prompts/plan-generation.md` to encourage creative approaches
355
+ - Ask providers to focus on different aspects (e.g., performance vs. simplicity)
356
+
357
+ ---
358
+
359
+ ## Local CLI Usage (Alternative)
360
+
361
+ You can also run implementations locally using the shell script.
362
+
363
+ ### Prerequisites for Local CLI
364
+
365
+ The local `parallel-impl.sh` script now uses the OpenCode SDK (@opencode-ai/sdk) for AI interactions. You need:
366
+
367
+ **Required:**
368
+ - **Git** - Version control
369
+ - **Bun runtime** - The SDK and script execution requires Bun (`curl -fsSL https://bun.sh/install | bash` or `npm install -g bun`)
370
+ - **GitHub CLI (gh)** - For creating PRs (`brew install gh` or `sudo apt install gh`)
371
+ - **jq** - JSON parsing utility (`brew install jq` or `sudo apt install jq`)
372
+
373
+ **Authentication** - Set one of the following environment variables:
374
+ - **`CLAUDE_CODE_OAUTH_TOKEN`** (recommended) - OAuth token for Claude Code. Get yours from [claude.ai/settings](https://claude.ai/settings)
375
+ - **`ANTHROPIC_API_KEY`** (fallback) - Anthropic API key from [console.anthropic.com](https://console.anthropic.com)
376
+
377
+ **Note:** The script uses the OpenCode SDK under the hood to execute AI queries, which provides better integration and features compared to direct CLI calls.
378
+
379
+ ### Installation
380
+
381
+ ```bash
382
+ # Option 1: Add to PATH
383
+ export PATH="$PATH:/path/to/claude-parallel"
384
+
385
+ # Option 2: Create alias
386
+ alias parallel-impl="/path/to/claude-parallel/parallel-impl.sh"
387
+ ```
388
+
389
+ ### Basic Usage
390
+
391
+ ```bash
392
+ ./parallel-impl.sh "Add user authentication with JWT tokens"
393
+ ```
394
+
395
+ ### From Any Git Repository
396
+
397
+ ```bash
398
+ cd ~/my-project
399
+ /path/to/claude-parallel/parallel-impl.sh "Implement dark mode toggle"
400
+ ```
401
+
402
+ ### What Happens
403
+
404
+ The script will:
405
+ 1. Create 3 worktrees in `../parallel-impls/impl-{1,2,3}`
406
+ 2. Run Claude Code in each (this may take several minutes)
407
+ 3. Review all implementations and select the best
408
+ 4. Create a draft PR from the winning branch
409
+ 5. Clean up losing worktrees
410
+
411
+ ## Customizing Prompts
412
+
413
+ Prompts are stored in `prompts/` directory for easy editing:
414
+
415
+ ### Implementation Prompt
416
+ Edit `prompts/implementation.md` to customize how Claude implements features:
417
+
418
+ ```txt
419
+ Implement the following feature request:
420
+
421
+ {{FEATURE_REQUEST}}
422
+
423
+ Requirements:
424
+ - Write clean, maintainable code following project conventions
425
+ - Ensure complete implementation of all requested functionality
426
+ ...
427
+ ```
428
+
429
+ The `{{FEATURE_REQUEST}}` placeholder will be replaced with your actual request.
430
+
431
+ ### Review Prompt
432
+ Edit `prompts/review.md` to customize review criteria:
433
+
434
+ ```txt
435
+ You are reviewing {{NUM_IMPLEMENTATIONS}} parallel implementations...
436
+
437
+ Your task:
438
+ 1. Review each implementation by examining the git diff
439
+ 2. Evaluate based on these criteria:
440
+ - Code quality: ...
441
+ - Completeness: ...
442
+ ```
443
+
444
+ Available placeholders:
445
+ - `{{FEATURE_REQUEST}}` - Your feature request
446
+ - `{{NUM_IMPLEMENTATIONS}}` - Number of parallel implementations (default: 3)
447
+ - `{{WORKTREES_DIR}}` - Path to worktrees directory
448
+
449
+ ## Configuration
450
+
451
+ ### Change Number of Implementations
452
+
453
+ Edit `parallel-impl.sh` and modify:
454
+
455
+ ```bash
456
+ NUM_IMPLEMENTATIONS=3 # Change to 2, 4, 5, etc.
457
+ ```
458
+
459
+ ### Customize Worktree Location
460
+
461
+ Edit `parallel-impl.sh` and modify:
462
+
463
+ ```bash
464
+ WORKTREES_DIR="../parallel-impls" # Change to your preferred location
465
+ ```
466
+
467
+ ### Review Criteria
468
+
469
+ Edit `prompts/review.md` to adjust what Claude looks for when selecting the best implementation. Current criteria:
470
+ - Code quality (clean, maintainable, follows conventions)
471
+ - Completeness (fully implements the feature)
472
+
473
+ You can add more criteria like:
474
+ - Performance
475
+ - Test coverage
476
+ - Security
477
+ - Documentation
478
+
479
+ ## Output
480
+
481
+ ### During Execution
482
+
483
+ ```
484
+ === Claude Code Parallel Implementation ===
485
+ Feature Request: Add user authentication with JWT tokens
486
+ Creating 3 parallel implementations...
487
+
488
+ Step 1: Creating git worktrees
489
+ ✓ Worktrees created
490
+
491
+ Step 2: Running Claude Code in parallel
492
+ This may take several minutes...
493
+ → Implementation 1 starting...
494
+ → Implementation 2 starting...
495
+ → Implementation 3 starting...
496
+ ✓ Implementation 1 complete
497
+ ✓ Implementation 2 complete
498
+ ✓ Implementation 3 complete
499
+
500
+ Step 3: Reviewing implementations
501
+ ✓ Review complete
502
+
503
+ === Review Results ===
504
+ Winner: Implementation 2
505
+ Quality Score: 92
506
+ Completeness Score: 88
507
+
508
+ Reasoning:
509
+ Implementation 2 provides the most robust solution...
510
+
511
+ Step 4: Creating draft PR
512
+ ✓ Draft PR created
513
+ https://github.com/user/repo/pull/123
514
+
515
+ Step 5: Cleanup
516
+ ✓ Cleanup complete
517
+
518
+ === Done! ===
519
+ Winning implementation: impl-1234567890-2
520
+ Worktree location: ../parallel-impls/impl-2
521
+ ```
522
+
523
+ ### Files Created
524
+
525
+ - `../parallel-impls/impl-{1,2,3}/` - Worktree directories
526
+ - `../parallel-impls/impl-X/result.json` - Claude output for each implementation
527
+ - `review-result.json` - Review decision and reasoning
528
+ - Draft PR on GitHub
529
+
530
+ ## Troubleshooting
531
+
532
+ ### "Not in a git repository"
533
+
534
+ Run the script from within a git repository:
535
+
536
+ ```bash
537
+ cd ~/my-project
538
+ /path/to/parallel-impl.sh "feature request"
539
+ ```
540
+
541
+ ### "Required command not found"
542
+
543
+ Install missing dependencies:
544
+
545
+ ```bash
546
+ # Install GitHub CLI
547
+ sudo apt install gh # or: brew install gh
548
+
549
+ # Install jq
550
+ sudo apt install jq # or: brew install jq
551
+ ```
552
+
553
+ ### Claude Code fails
554
+
555
+ Check error logs in each worktree:
556
+
557
+ ```bash
558
+ cat ../parallel-impls/impl-1/error.log
559
+ cat ../parallel-impls/impl-2/error.log
560
+ cat ../parallel-impls/impl-3/error.log
561
+ ```
562
+
563
+ ### Review parsing fails
564
+
565
+ The review output should be pure JSON. If Claude returns markdown or text, edit `prompts/review.md` to emphasize:
566
+
567
+ ```txt
568
+ You MUST respond with ONLY valid JSON (no markdown, no code blocks)
569
+ ```
570
+
571
+ ### PR creation fails
572
+
573
+ You may need to push first or set up GitHub CLI:
574
+
575
+ ```bash
576
+ gh auth login
577
+ ```
578
+
579
+ Or create the PR manually:
580
+
581
+ ```bash
582
+ git checkout impl-TIMESTAMP-X
583
+ git push -u origin HEAD
584
+ gh pr create --draft
585
+ ```
586
+
587
+ ## Advanced Usage
588
+
589
+ ### Customizing for Your Organization
590
+
591
+ Fork this repository and customize:
592
+
593
+ 1. **Prompts**: Edit files in `prompts/` to match your coding standards
594
+ 2. **Review criteria**: Modify `prompts/review.md` for your quality metrics
595
+ 3. **Runtime detection**: Add support for additional languages in `.github/actions/detect-runtime/`
596
+
597
+ Then reference your fork:
598
+
599
+ ```yaml
600
+ uses: your-org/claude-parallel/.github/workflows/reusable-implement-issue.yml@main
601
+ ```
602
+
603
+ ### Custom Review Logic
604
+
605
+ For more sophisticated review (e.g., running tests, performance benchmarks), modify the review section in `parallel-impl.sh` or create a custom review script.
606
+
607
+ ### Keeping All Implementations
608
+
609
+ Comment out the cleanup section in `parallel-impl.sh` to keep all worktrees for manual inspection:
610
+
611
+ ```bash
612
+ # Cleanup non-winning worktrees
613
+ # echo -e "${BLUE}Step 5: Cleanup${NC}"
614
+ # for i in $(seq 1 $NUM_IMPLEMENTATIONS); do
615
+ # ...
616
+ ```
617
+
618
+ ## Cost Considerations
619
+
620
+ Running 3 parallel Claude Code instances will use 3x tokens. For a typical feature:
621
+ - Simple feature: ~30k tokens per implementation = ~90k total
622
+ - Complex feature: ~100k tokens per implementation = ~300k total
623
+ - Review: ~50k tokens
624
+
625
+ Monitor your usage and adjust `NUM_IMPLEMENTATIONS` accordingly.
626
+
627
+ ## Examples
628
+
629
+ ### Add a new feature
630
+
631
+ ```bash
632
+ ./parallel-impl.sh "Add rate limiting middleware to API endpoints"
633
+ ```
634
+
635
+ ### Fix a bug
636
+
637
+ ```bash
638
+ ./parallel-impl.sh "Fix memory leak in WebSocket connection handler"
639
+ ```
640
+
641
+ ### Refactor code
642
+
643
+ ```bash
644
+ ./parallel-impl.sh "Refactor authentication logic to use OAuth 2.0"
645
+ ```
646
+
647
+ ### Add tests
648
+
649
+ ```bash
650
+ ./parallel-impl.sh "Add comprehensive unit tests for user service"
651
+ ```
652
+
653
+ ## Features
654
+
655
+ - **Multi-language support**: Auto-detects Node.js, Python, Go, Rust, Java, Ruby, PHP, and more
656
+ - **Parallel execution**: Runs implementations concurrently using GitHub Actions matrix
657
+ - **Automatic review**: Claude evaluates all implementations and picks the best
658
+ - **Draft PRs**: Creates ready-to-review pull requests
659
+ - **Customizable prompts**: Tailor implementation and review criteria to your needs
660
+ - **Reusable workflow**: Use in any repository with minimal setup
661
+
662
+ ## Conversation Logging (Optional)
663
+
664
+ Claude Parallel can optionally log all agent conversations to a [Turso](https://turso.tech/) database for debugging, analytics, and audit purposes.
665
+
666
+ ### What Gets Logged
667
+
668
+ When enabled, the system captures:
669
+ - **Session metadata**: Agent type, model, provider, timestamps, status
670
+ - **Messages**: User prompts and AI responses with sequence ordering
671
+ - **Tool executions**: Tool names, inputs, outputs, timing, and errors
672
+
673
+ ### Setup
674
+
675
+ 1. **Install Turso CLI**:
676
+ ```bash
677
+ curl -sSfL https://get.tur.so/install.sh | bash
678
+ ```
679
+
680
+ 2. **Create a database**:
681
+ ```bash
682
+ turso db create claude-parallel-logs
683
+ ```
684
+
685
+ 3. **Get your credentials**:
686
+ ```bash
687
+ turso db show --url claude-parallel-logs
688
+ turso db tokens create claude-parallel-logs
689
+ ```
690
+
691
+ 4. **Configure environment variables**:
692
+ ```bash
693
+ export TURSO_DATABASE_URL="libsql://your-db-name.turso.io"
694
+ export TURSO_AUTH_TOKEN="your-auth-token"
695
+ ```
696
+
697
+ The database schema is automatically initialized on first use.
698
+
699
+ ### Disabling Logging
700
+
701
+ Logging is automatically disabled when `TURSO_DATABASE_URL` or `TURSO_AUTH_TOKEN` are not set. There's no performance impact when logging is disabled.
702
+
703
+ ## Credits
704
+
705
+ Inspired by production workflows from:
706
+ - [incident.io's git worktree + Claude Code workflow](https://incident.io/blog)
707
+ - [Crystal desktop app](https://github.com/stravu/crystal)
708
+
709
+ ## License
710
+
711
+ MIT