Recreate the useful part of Cursor-style background coding agents with plain git worktrees: isolated branches, task packets, JSONL traces, and review gates before merge.
tools/agent_workflows/agent_worktree_launcher.sh \ --repo . \ --task "Add billing CSV export" \ --base main \ --out generated/background_agents/billing-export \ --mode dry-run
A background coding agent is useful only when the async work is isolated and reviewable. This launcher turns a coding task into a safe worktree workflow instead of letting an agent mutate your active branch.
Create or prepare a separate git worktree and branch for the agent so your current workspace stays clean.
Generate a clear packet with scope, branch, worktree path, output requirements, and review expectations.
Create review commands that save status, diff stats, and full patch output before anything is merged.
Log the packet and review-gate events so async work can be inspected later instead of trusted blindly.
Default to dry-run mode to generate the workflow files without modifying your repository.
Use Crazyrouter as the OpenAI-compatible API layer when routing planner, implementer, reviewer, and verifier calls.
Download the script, make it executable, and run it from your repository. Start with dry-run mode, inspect the generated packet, then switch to create mode when ready.
curl -L -o agent_worktree_launcher.sh \ https://raw.githubusercontent.com/xujfcn/crazyrouter-tools/main/agent_workflows/agent_worktree_launcher.sh chmod +x agent_worktree_launcher.sh ./agent_worktree_launcher.sh \ --repo . \ --task "Add async billing export validation in an isolated background branch" \ --base main \ --out generated/background_agents/billing-export \ --mode dry-run
The launcher creates a small workflow folder that can be handed to a human, Claude Code, Codex, OpenClaw, Cursor, or another coding agent.
generated/background_agents/billing-export/
├── README.md
├── trace.jsonl
├── commands/
│ ├── create-worktree.sh
│ └── review-before-merge.sh
└── packets/
└── 01-background-agent.md
Use dry-run mode first. Read the packet and make sure the scope is narrow enough for async work.
Run create mode only when your repository is clean. The script refuses to create a worktree if there are uncommitted changes.
Point your agent to the packet and worktree path. Keep all edits inside that branch.
Run the review command, inspect the saved diff, verify tests, then decide merge / request changes / abandon.
Background agents multiply model calls. A real async coding workflow can include planning, implementation, adversarial review, fixes, and verification. Crazyrouter gives you one OpenAI-compatible endpoint for routing those steps across different models.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_CRAZYROUTER_KEY",
base_url="https://crazyrouter.com/v1"
)
Use git worktrees for isolation, task packets for scope, trace logs for observability, and Crazyrouter for flexible model routing.