From aide
Merges git worktrees after swarm completion: lists status from .aide/state, tests/lints/builds feat branches, reviews changes, merges clean ones, intelligently resolves conflicts.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aide:worktree-resolveThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Recommended model tier:** balanced (sonnet) - this skill performs straightforward operations
Recommended model tier: balanced (sonnet) - this skill performs straightforward operations
Merge all swarm worktrees back into the main branch after testing.
git worktree list
Check the AIDE worktree state file for metadata and status:
cat .aide/state/worktrees.json
Worktree Status Values:
active - Agent is still working on this worktreeagent-complete - Agent finished, ready for merge reviewmerged - Successfully merged to mainOnly merge worktrees with status agent-complete.
Example state file:
{
"active": [
{
"name": "story-auth",
"path": ".aide/worktrees/story-auth",
"branch": "feat/story-auth",
"taskId": "story-auth",
"agentId": "agent-auth",
"status": "agent-complete",
"createdAt": "2026-02-07T...",
"completedAt": "2026-02-07T..."
}
],
"baseBranch": "main"
}
Run these steps for every feat/* branch from swarm:
# Checkout the worktree
cd .aide/worktrees/<name>
# Run tests
npm test # or appropriate test command
# Run linting
npm run lint # or appropriate lint command
# Check build
npm run build # if applicable
# Back in main repo
git log main..feat/<name> --oneline
git diff main...feat/<name> --stat
# Dry-run merge check
git merge-tree $(git merge-base main feat/<name>) main feat/<name>
If conflicts shown, note them for manual resolution.
For branches that pass tests and have no conflicts:
git checkout main
git merge feat/<branch-name> --no-edit
When merge conflicts occur, do not use -X theirs or -X ours - these blindly discard changes.
Instead, resolve conflicts intelligently:
git merge feat/<name> --no-edit
# If conflicts occur, git will list the conflicted files
# Read the file with conflict markers
cat <conflicted-file>
The conflict markers show:
<<<<<<< HEAD
[changes from main branch]
=======
[changes from feature branch]
>>>>>>> feat/<name>
Act as an expert code reviewer. For each conflict:
The resolution must:
<<<<<<<, =======, >>>>>>>)# Stage the resolved files
git add <resolved-file>
# Run tests to verify the resolution works
npm test # or appropriate test command
# If tests pass, complete the merge
git commit --no-edit
If you cannot resolve the conflict (logic is contradictory, tests fail after resolution, or changes are too complex):
Abort the merge to restore clean state:
git merge --abort
Record the failure using aide messaging:
./.aide/bin/aide message send --from=resolver --to=orchestrator "CONFLICT: Cannot merge feat/<name> - <brief reason>"
Binary location: The aide binary is at .aide/bin/aide. If it's on your $PATH, you can use aide directly.
Skip this branch and continue with remaining branches
Report at completion - list unmerged branches in the final summary for manual review
Do NOT:
-X theirs or -X ours to blindly pick one sideConflict:
<<<<<<< HEAD
function getUser(id: string): User {
return db.users.find(u => u.id === id);
}
=======
function getUser(id: string): User | null {
const user = db.users.find(u => u.id === id);
return user ?? null;
}
>>>>>>> feat/null-safety
Analysis:
Resolution:
function getUser(id: string): User | null {
const user = db.users.find((u) => u.id === id);
return user ?? null;
}
Feature branch improved null safety - this is additive, keep it.
After all branches merged:
# Remove each worktree
git worktree remove .aide/worktrees/<name>
# Delete merged branches
git branch -d feat/<name>
# Prune any orphaned worktrees
git worktree prune
# Clear state file
rm .aide/state/worktrees.json
# Ensure all tests pass on main
git checkout main
npm test
npm run lint
npm run build
# Check no worktrees remain
git worktree list # Should only show main
After resolution, report:
## Worktree Resolution Complete
### Merged Branches
- feat/task1-agent1: ✓ (3 files, +150/-20)
- feat/task2-agent2: ✓ (5 files, +280/-45)
### Skipped (conflicts/failures)
- feat/task3-agent3: Test failures in auth.test.ts
### Final Status
- All tests passing: ✓
- Lint clean: ✓
- Build successful: ✓
# List all feat branches from swarm
git branch --list 'feat/*'
# Merge all clean branches at once (risky - prefer one at a time)
for branch in $(git branch --list 'feat/*' | tr -d ' '); do
git merge $branch --no-edit || echo "Conflict in $branch"
done
# Bulk cleanup worktrees
git worktree list | grep '.aide/worktrees' | awk '{print $1}' | xargs -I {} git worktree remove {}
# Bulk delete feat branches (only if merged)
git branch --list 'feat/*' | xargs git branch -d
git merge --abort./.aide/bin/aide message send --from=resolver --to=orchestrator "Merge failed: feat/<name> - <reason>"
git revert -m 1 HEAD# Force remove if necessary
git worktree remove --force .aide/worktrees/<name>
# Prune any orphaned entries
git worktree prune
# Verify merge commit exists
git log -1 --oneline
# Verify no uncommitted changes
git status --porcelain # Should be empty
# Verify tests pass
npm test # or appropriate test command
# Verify all worktrees removed
git worktree list # Should only show main worktree
# Verify all feature branches deleted (or list unmerged)
git branch --list 'feat/*' # Should be empty for merged branches
# Verify main is clean
git status
# Verify final tests pass
npm test && npm run lint && npm run build
git tag pre-swarm-merge-d not -D to prevent deleting unmerged worknpx claudepluginhub jmylchreest/aide --plugin aideReviews pending fleet worktree merges by reading the merge-check queue, detecting file-level conflicts, and proposing a safe merge order with reconciliation plans.
Creates isolated git worktrees for branch work, auto-installs dependencies, verifies baselines, and handles branch finishing with clean isolation.
Finishes development branches: verifies tests pass, presents options for local merge, push and GitHub PR, keep as-is, or discard; executes git commands and cleans up worktrees.