Duo
Two-agent workflow: deep-thinker plans, coder implements
Claude CodeGeneric
---
description: Two-agent workflow: deep-thinker plans, coder implements
allowed-tools: Bash(gh:*), Bash(git:*), Task
argument-hint: <issue> (e.g., 385, #385, or full URL)
---
# Duo: Deep-Thinker + Coder Workflow
This command orchestrates a two-agent workflow for implementing GitHub issues.
## Input Parsing
Parse the `$ARGUMENTS` to extract the issue number:
- `385` → issue number 385
- `#385` → issue number 385
- `https://github.com/asynkron/Asynkron.JsEngine/issues/385` → issue number 385
Extract the number and store as `ISSUE_NUMBER`.
## Phase 1: Deep-Thinker Analysis
First, fetch the issue details:
```bash
gh issue view $ISSUE_NUMBER --json title,body,labels,comments
Then launch a deep-thinker agent with this prompt:
You are analyzing GitHub issue #$ISSUE_NUMBER for the Asynkron.JsEngine project.
## Issue Details
$ISSUE_CONTENT
## Your Task
1. **Research the codebase** to understand:
- What files and components are involved
- How similar features are implemented
- What tests exist for related functionality
- Any relevant patterns or conventions
2. **Analyze the issue** thoroughly:
- What is the root cause (for bugs) or requirements (for features)?
- What are the edge cases to consider?
- What could go wrong?
3. **Create an implementation plan** with:
- Step-by-step implementation approach
- Files to modify/create
- Tests to add
- Potential risks or blockers
4. **Post your plan as a GitHub comment** on issue #$ISSUE_NUMBER:
```bash
gh issue comment $ISSUE_NUMBER --body "$(cat <<'EOF'
# Implementation Plan
## Summary
[Brief description of the approach]
## Analysis Findings
[Key discoveries from codebase research]
## Implementation Steps
1. [Step 1]
2. [Step 2]
...
## Files to Modify
- `path/to/file.cs`: [what changes]
...
## Tests to Add
- [Test descriptions]
## Risks & Considerations
- [Any potential issues]
---
*Generated by /duo deep-thinker agent*
EOF
)"
Return the comment URL when done.
Wait for the deep-thinker agent to complete and capture the comment URL.
## Phase 2: Create Worktree
After deep-thinker completes, create a worktree for the coder:
```bash
git worktree add ../Asynkron.JsEngine-issue-$ISSUE_NUMBER -b feature/issue-$ISSUE_NUMBER
Phase 3: Coder Implementation
Launch a coder agent with this prompt:
You are implementing GitHub issue #$ISSUE_NUMBER in the Asynkron.JsEngine project.
## Working Directory
Work in the worktree at: ../Asynkron.JsEngine-issue-$ISSUE_NUMBER
## Implementation Plan
Read the implementation plan comment on the issue:
$COMMENT_URL
Follow the plan carefully.
## Your Task
1. **Read the implementation plan** from the GitHub comment
2. **Implement the solution** following the plan
3. **Write tests** as specified in the plan
4. **Run tests** to verify: `dotnet test tests/Asynkron.JsEngine.Tests`
5. **Run pre-PR checks**:
- `roslynator fix src/Asynkron.JsEngine`
- `dotnet build src/Asynkron.JsEngine`
- `dotnet test tests/Asynkron.JsEngine.Tests`
- `quickdup --path src/Asynkron.JsEngine --ext .cs --select 0..20 --min 2 --exclude ".g."`
- `dotnet format src/Asynkron.JsEngine`
6. **Commit your changes** with a descriptive message
7. **Create a PR** using gh CLI:
```bash
git push -u origin feature/issue-$ISSUE_NUMBER
gh pr create --title "Fix #$ISSUE_NUMBER: [brief description]" --body "$(cat <<'EOF'
## Summary
[What this PR does]
## Changes
- [List of changes]
## Testing
- [How it was tested]
Fixes #$ISSUE_NUMBER
---
*Implemented by /duo coder agent*
EOF
)"
- Monitor CI Pipeline - After creating the PR, wait for CI to complete:
# Wait for CI checks to complete (poll every 30 seconds, max 20 minutes)
gh pr checks --watch --interval 30
If gh pr checks shows failures:
a. Get the failed check details:
gh pr checks --json name,state,conclusion,detailsUrl
b. Fetch the CI logs for failed checks:
# Get the run ID from the PR checks
gh run view <run-id> --log-failed
c. Analyze the failure:
- Build errors: Read the error messages, fix the code
- Test failures: Identify which tests failed and why, fix the issues
d. Fix the issues in your worktree
e. Run local verification again:
dotnet build src/Asynkron.JsEnginedotnet test tests/Asynkron.JsEngine.Tests
f. Commit and push the fix:
git add -A
git commit -m "Fix CI failures: [brief description of fix]"
git push
g. Repeat from step 8 - Monitor CI again until all checks pass
IMPORTANT: Continue this loop until ALL CI checks pass. Do not return until CI is green.
- Return the PR URL only after CI passes successfully.
## Output
After both agents complete, report:
- Issue: #$ISSUE_NUMBER
- Implementation plan comment: [URL]
- Pull request: [URL]
- CI status: ✅ All checks passed
- Worktree location: ../Asynkron.JsEngine-issue-$ISSUE_NUMBER
Remind user to review the PR and clean up the worktree after merge:
```bash
git pull origin main
git worktree remove ../Asynkron.JsEngine-issue-$ISSUE_NUMBER --force
git branch -D feature/issue-$ISSUE_NUMBER
Maintain Duo?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Duo on getagentictools](https://getagentictools.com/loops/asynkron-duo-deep-thinker-coder-workflow?ref=badge)