
Let Claude Close the Loop: Background Agents Now Auto-Commit, Push, and Open a Draft PR
Chris Harper
2 min read
Jul 9, 2026 · 12:09 UTC
TL;DR: Claude Code v2.1.198 (July 1) changed the default for worktree background agents — on finish, they auto-commit, auto-push, and open a GitHub draft PR, then fire an agent_completed hook you can wire to any notification channel.
Before v2.1.198, a background agent launched with claude agents would pause at the end of code work and wait for you to confirm before committing. That pause was the main friction in fleet-style workflows — you couldn't walk away until you acknowledged each session.
Now the agent closes the loop on its own:
- Finishes its edits in the isolated worktree
- Commits with a descriptive message
- Pushes the branch to the remote
- Opens a draft PR on GitHub — automatically
The draft flag is the guardrail: the agent stages the result, but the merge decision stays with you. No code ships until a human promotes the PR from draft to ready.
Wire up notifications with the new hooks
v2.1.198 also added two Notification hook events for background agents:
agent_completed— fires when the agent finishes and the draft PR is openagent_needs_input— fires when the agent is paused and blocked on your input
Add this to .claude/settings.json to trigger a macOS notification when a session completes (swap the command for a Slack webhook, ntfy.sh, or anything else):
{
"hooks": {
"Notification": [
{
"matcher": "agent_completed",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Draft PR ready\" with title \"Claude Agent Done\"'"
}
]
}
]
}
}
The fleet workflow this enables
Dispatch five background agents at once — each works in its own worktree on a different task. All five commit, push, and open draft PRs when done. You get five agent_completed notifications and five PRs waiting in your GitHub repo. Previously you had to babysit and manually commit each session.
To opt back in to the old "ask before committing" behavior, set "autoCommit": false in the agent session config — a setting added in response to community feedback.
Sources: Claude Code changelog · v2.1.198 release notes · Background agents deep dive