| name | the-controller-finishing-a-development-branch |
| description | Use when implementation is complete and you need to merge the branch — verifies tests, rebases, creates PR, squash merges, deletes remote branch, syncs local master, and closes the issue |
Finishing a Development Branch
Step 1: Verify Tests
Run the project's test suite. If tests fail, fix them before proceeding.
Step 2: Execute Merge Workflow
- Ensure all changes are committed before proceeding
- Rebase onto
master
- Create a PR to
master
- Squash merge the PR (without
--delete-branch to avoid worktree checkout errors):
gh pr merge --squash
- Delete the remote branch:
git push origin --delete "$(git branch --show-current)"
- Sync local master:
master_worktree=$(git worktree list | grep '\[master\]' | awk '{print $1}')
if [ -n "$master_worktree" ]; then
git -C "$master_worktree" pull origin master
else
git fetch origin master:master
fi
- Close the associated issue with a summary of what was done
- If running inside The Controller (i.e.
$THE_CONTROLLER_SESSION_ID is set), signal it to clean up this session's worktree. Syncing master (step 6) may trigger a dev server restart which temporarily kills the socket, so retry for up to 60 seconds:
if [ -z "$THE_CONTROLLER_SESSION_ID" ]; then
echo "ERROR: THE_CONTROLLER_SESSION_ID is not set, cannot signal cleanup"
else
for i in $(seq 1 30); do
echo "cleanup:$THE_CONTROLLER_SESSION_ID" | nc -U -w 2 /tmp/the-controller.sock && break
echo "Waiting for controller socket (attempt $i/30)..."
sleep 2
done
fi
Integration
Called by:
- the-controller-subagent-driven-development (Step 7) - After all tasks complete
- the-controller-executing-plans (Step 5) - After all batches complete
Pairs with:
- the-controller-using-git-worktrees - Cleans up worktree created by that skill