Walkthrough
Build it yourself, part by part.
Label an issue and walk away. A sandbox starts, an agent clones the repository there, finds the bug, fixes it, runs the tests and opens a pull request. You come back to a diff to review.
The agent in this example is Claude Code, but the pattern is the same for any of them. What matters is where it runs and what it is allowed to hold, so most of this walkthrough is about that.
-
A machine with the agent's tools on it
The agent needs git, the GitHub command and itself. Those go in a template, with one more line that matters: a secret group.
The GitHub token and the model's key are kept by Annex and put into the sandbox's environment when it starts. The small server that listens for GitHub never holds either of them.
annex.yml
name: issue-to-pr description: git, the GitHub CLI and Claude Code vcpu: 2 memory_gib: 4 route: cheapest secret_groups: [issue-to-pr] # GH_TOKEN and ANTHROPIC_API_KEY, kept by Annex (dashboard, Secrets) setup: - | S=; [ "$(id -u)" = 0 ] || S=sudo $S apt-get update && $S apt-get install -y git gh nodejs npm - | S=; [ "$(id -u)" = 0 ] || S=sudo $S npm install -g @anthropic-ai/claude-code -
Believe only GitHub
GitHub tells your server when an issue is labelled. Anyone on the internet can send the same message, so the server checks the signature GitHub puts on each one before reading a word of it.
server.mjs
const want = Buffer.from('sha256=' + createHmac('sha256', SECRET).update(body).digest('hex')) const got = Buffer.from(req.headers['x-hub-signature-256'] || '') if (got.length !== want.length || !timingSafeEqual(got, want)) return res.writeHead(401).end() -
The work is a short script
What runs in the sandbox is eight lines of shell: clone, make a branch, let the agent work, commit, push, open the pull request.
Look at how the issue gets there. Its text is a file and its title an environment variable; neither is ever part of a command. An issue is text a stranger wrote, and text pasted into a command line is a command.
server.mjs
const WORK = `set -e git clone --depth 50 "https://x-access-token:$GH_TOKEN@github.com/$REPO.git" /tmp/repo cd /tmp/repo git checkout -b "$BRANCH" IS_SANDBOX=1 claude -p "$(cat /tmp/issue.md)" --dangerously-skip-permissions git add -A git -c user.name="issue-to-pr" -c user.email="issue-to-pr@users.noreply.github.com" commit -m "Fix #$NUMBER: $TITLE" git push origin "$BRANCH" gh pr create --repo "$REPO" --head "$BRANCH" --title "$TITLE" --body "Closes #$NUMBER. Written by an agent: read it before merging."` -
Start, run, always stop
The server starts a sandbox for the issue, uploads the issue's text, runs the script and stops the sandbox whether it worked or not. A lifetime of two hours is a second guard against one that runs away.
server.mjs
const sb = await annex.start({ template: 'issue-to-pr', lifetime_minutes: 120 }) try { await annex.ready(sb.id) await annex.upload(sb.id, '/tmp/issue.md', prompt) // the issue, as a file await annex.run(sb.id, WORK, { timeout: 3600, env: { REPO: repo, NUMBER: String(issue.number), BRANCH: `agent/issue-${issue.number}`, TITLE: issue.title }, }) } finally { await annex.stop(sb.id) // whatever happened }
Before you rely on it
- The agent reads text a stranger can write while holding a token. The sandbox keeps a misled agent away from your computer, not away from the repository: use a token limited to that one repository, and label only issues you have read.
- Nothing here merges. Every pull request waits for a person.
- A long job is safer with checkpoints on, so a machine that is lost mid-way costs minutes, not the whole run.