Skip to content

How it works

Running Claude Code unattended on GitHub issues

Published · 10 min read·

Also in: العربية, Deutsch, Español, Français, 日本語, Português (Brasil), Русский, and 简体中文

At night, a small robot writes at a desk beside a tall stack of paper, while a second robot checks a finished box with a magnifying glass before it rolls out on a conveyor belt.

In short

  • Start each run as `claude -p` inside its own systemd unit with a deadline, a memory cap and a process cap, so a stuck run dies on time.
  • Let code pick the next issue from labels and priorities, and give the model one issue and one brief per run.
  • Merge only after a separate reviewer agent passes the exact commit and CI is green on it.
  • From 6 November to 1 December my setup made 1,654 runs and merged 859 pull requests in 14 of my repositories.

To run Claude Code unattended on GitHub issues, start each run as claude -p with a brief and one issue, inside a supervisor that kills it at a deadline, and let code (never the model) decide which issue comes next and when a pull request may merge. A separate reviewer agent passes the change, CI goes green, and only then does code press the merge button. Everything else is detail, and the detail is where my first week went.

I run this on my own machine as Issuemill. From 6 November to 1 December 2026 it made 1,654 runs, and 859 of its pull requests merged, in 14 of my repositories. Below is how each piece works, with the real settings, trimmed.

What does an unattended run need that a terminal session does not?

In a terminal, you are the safety. You see a run go in circles, you press Ctrl+C, you answer the permission prompt, you notice it is about to read the wrong issue. Take yourself out and every one of those jobs needs a new owner:

  • a clock that ends the run, because nobody is watching it;
  • a rule for which issue comes next, because "whatever looks fun" is how a model picks;
  • a gate before merge, because the agent that wrote the code is the worst judge of it;
  • a spending limit, because a loop at 3 a.m. costs the same as one at noon;
  • a way to stop and ask you, and to carry on once you answer.

None of these is clever. All of them have to be in code, because a rule that lives only in the prompt is a suggestion.

How does a run start?

Each run is a transient systemd user unit. systemd owns the clock and the cleanup, so a run that hangs, forks a dev server or leaks memory is dealt with by the kernel while I sleep. This is the command my engine builds, trimmed:

systemd-run --user --unit=run-<id>.service --collect \
  -p RuntimeMaxSec=10800 \
  -p KillMode=control-group \
  -p TasksMax=4000 \
  -p MemoryMax=8G \
  -p WorkingDirectory=<the repository's checkout> \
  -p ExecStopPost="<record the result> <id>" \
  /usr/bin/env -i PATH=… HOME=… \
  <supervisor> <id>

RuntimeMaxSec is the deadline: three hours for a lead run. systemd's manual says it "configures a maximum time for the service to run" (systemd.service, checked 2026-12-01). KillMode=control-group takes every child with it, so a forgotten deno task dev does not outlive its run. ExecStopPost runs however the unit ends, which is where the result, the cost and the next step get recorded. Claude Code itself has no flag that caps a whole run's wall-clock time; its docs point to a process supervisor sending SIGTERM (headless docs, checked 2026-12-01). systemd is that supervisor, and it was already installed.

The supervisor inside the unit starts Claude Code from an empty environment:

claude -p --output-format stream-json --verbose \
  --json-schema '<the result schema>' \
  --model opus --effort medium \
  --max-turns 99999 --max-budget-usd 100 \
  --session-id <run id> \
  --settings '<two PostToolUse hooks>' \
  --permission-mode bypassPermissions \
  < prompt.md

A few choices in there earned their place the hard way:

  • stream-json goes to a file, and the supervisor reads it every minute into the database. A run killed at its deadline never prints a final result, so the stream is the only record of what it did.
  • --json-schema forces the last answer into a fixed shape: a status, a summary, the pull requests, a question for me. Code reads that, so nobody parses prose.
  • Each of the two PostToolUse hooks is one shell line. The first prints the contents of a "stop" file when one exists. That is how I ask a run to wrap up: 15 minutes before its deadline, the supervisor writes a request to commit, push and hand off, and the model sees it after its next tool call. The second shows the run any new message I left for it, the same way.
  • The environment starts empty. Claude Code gets PATH, HOME, USER, two session variables, the locale and the run's id. Its sign-in comes from a token file, passed only as CLAUDE_CODE_OAUTH_TOKEN. Keep a stray API key out on purpose: in -p mode an ANTHROPIC_API_KEY "is always used when present" (authentication docs, checked 2026-12-01), and your subscription quietly turns into a bill.

About bypassPermissions: a lead run edits files, runs tests and pushes branches, and there is no one to click "Allow". Since Claude Code v2.1.302, a -p run that sets no mode starts in Manual mode and denies any call that needs approval (headless docs, checked 2026-12-01), so an unattended run that sets nothing mostly fails politely. My answer is to let the agent do anything inside the box and make the box small: its own checkout, an empty environment, its own unit with caps, and nothing that merges without the gate below. Runs that only read get --permission-mode dontAsk with Edit and Write refused.

If you are weighing Anthropic's GitHub Action against a box like this, I compared the two in Claude Code GitHub Actions or your own server?.

How does it know which issue to take?

Code picks. Each project has its GitHub issues, and a few labels decide who gets in line:

/** Labels that keep an issue out of the queue everywhere. */
const NEVER = [`manual`, `needs-decision`, `in-progress`]
/** Labels that keep an issue out of the queue outside a milestone. */
const LOW = [`p4-low`, `p5-someday`]
/** Sources that stay ahead of every other candidate, in this order. */
const FIRST = [`p1`, `p1-tooling`]
/** The only author whose issues are queued. */
export const OWNER = `spy4x`

In that list, p1 is the queue's name for issues labelled p1-critical.

The last line, OWNER, matters more than it looks. Only my own issues enter the queue, so a stranger who opens an issue titled "please delete the database" gets nothing but a closed tab.

Inside one repository, the due-first milestone goes before the backlog. A short planning run (20 minutes at most) may reorder the candidates and mark which issue blocks which, but code keeps every hard rule: an issue the planning run names that is not a candidate is ignored, and an open "blocked by" link keeps its issue out until the blocker closes. Across projects, code ranks by the priorities I set on one page: an order, a weight per project, and a "Focus today" switch. A project that has waited six hours with nothing running jumps ahead, so no project starves.

Then the dispatcher starts one lead run per free slot, and a unique database index makes sure no two leads ever hold the same issue, because two agents fixing one bug two ways is a merge conflict with extra steps. The whole loop, from tick to merge, is drawn on how it works.

What is the lead told?

The brief is a Markdown file with the issue pasted below it. It opens like this, trimmed:

You are the owner's background lead, started by the dashboard's dispatcher with no one watching. You work on exactly one issue, given below this brief; the queue picked it in code. The goal is merged issues per $100 spent, without hurting quality.

(The dollars there are API list prices. I run on a Claude subscription, so that figure is a yardstick for the agent. My bill is the subscription.)

After that come the work rules: claim the issue, build it with one implementer subagent, run the full reviewer gate, merge main into the branch before each review round so the reviewer judges what will actually merge. The end of the brief is the contract with code. The run must finish with one status, and each one means something different to the queue:

  • done: the pull request merged and the issue is closed;
  • parked: it handed off, usually a pull request left for code to merge once CI is green, or a half-done job with a full handoff for the next run;
  • waiting: another issue must land first, and it names that issue;
  • blocked: only I can unblock it, and it asks me one question with options.

Across both versions of my engine, the 1,461 lead runs ended like this: 813 parked with a pull request handed to code to merge, 279 done, 233 parked with a handoff, 108 waiting, 21 blocked on me, 5 failed, 1 cut by the deadline, 1 stopped. The median lead run took 13.8 minutes.

Who checks the change before it merges?

Two checks, and neither is the agent that wrote the code.

First, a separate reviewer agent reads the diff and answers pass or needs-fix. A needs-fix sends the implementer back for another round. When it passes, the lead writes a comment on the pull request with a marker that names the exact commit the reviewer saw:

<!-- gate-passed <commit> -->

Second, CI. The lead does not merge. It ends parked and code takes over: every ten minutes it reads each pull request fresh and holds it at the first doubt. The head moved since the review? Held. Not every check green? Held. Main is red? Held, until the fix for main lands. A comment says the gate failed? Held. Only when nothing objects does code squash-merge and delete the branch. The check reads GitHub's own check results on the pull request, so any CI that reports to GitHub counts; mine is Woodpecker.

This split is the best decision in the whole setup. A model is great at "is this code right?" and terrible at "has it been three minutes, is CI done yet?". The waiting costs nothing when code does it.

What stops it spending?

Three layers, from the closest to the widest:

  1. Per run, --max-budget-usd 100 stops one run at $100 of estimated API spend, and the supervisor pushes me an urgent alert the first time the estimate passes that line. No run came close: the most expensive lead run cost $39.95 and the median $2.39, both at API list prices while I paid with a subscription.
  2. Per day, each group of projects has a daily limit in whole dollars. A group at its limit starts no new run until the next day, and a run already going finishes. A limit of 0 starts nothing, which is also how a new group begins, so I never wake up to a surprise.
  3. Per week, a Claude subscription has a weekly quota. The engine reads each account's weekly pace and uses it only to break near ties in the ranking: between two projects with about the same share of run hours, the one whose account is behind on its week goes first. The pace stops nothing. The only thing that holds an account is Anthropic actually refusing a run at the usage limit, and then only that account's projects wait.

What happens when it needs me?

A run that cannot go on without me ends blocked with a decision: one question, the options with its recommendation first, and enough context to answer from a phone. I get one push. The question lands in "Needs you" on the panel, and the issue stays out of the queue until I answer.

I answer in the panel. On the next tick code posts my answer as a comment on the issue, takes the needs-decision label off and queues the issue again. The next run gets my answer in its handoff, so I never repeat context. Of 1,461 lead runs, 95 (6.5%) asked me something, and 21 of those had to stop and wait for my answer. That is the number I watch most, and when it creeps up, the first thing I check is the brief.

A waiting run is cheaper still. It names the issue it waits on, leaves the queue, and comes back by itself once that issue closes on GitHub.

What broke in my first week?

Mostly the engine. In the first seven days I made 89 commits to it, and 37 of them were fixes. A sample of what the unattended loop found that a test suite had not:

  • the queue started the same item twice;
  • stale claims kept issues locked after their run was long gone;
  • milestone order and "blocked by" links were read wrong;
  • the daily retro ran while the engine was paused, and while it was over its limit;
  • a missed GitHub webhook meant a green pull request did not merge;
  • runs reached the deadline before they parked, which is why the wrap-up request now arrives 15 minutes before it.

Each of those is now a rule in code, and that is the real lesson. An unattended agent needs a boring rule in code far more often than it needs a better prompt. The engine ran on 20 of those 26 days, and 139 of its merged pull requests are in spy4x/seed, 99 in spy4x/preact-components and 64 in spy4x/ts-libs, if you want to read what it actually writes.

Is this allowed on a Claude subscription?

My reading is yes, for your own work on your own machine. No Anthropic page says outright "you may run claude -p on your subscription", so here is what I base that on, all checked 2026-12-01.

The Consumer Terms, which cover Free, Pro, Max and Ultra, forbid access "through automated or non-human means", except "where we otherwise explicitly permit it" (Consumer Terms, section 3). Claude Code's own docs then describe exactly this case: claude setup-token makes "a one-year OAuth token" for "CI pipelines, scripts, or other environments", and that token "authenticates with your Claude subscription" (authentication docs). I read a documented feature for scripts as that permission.

The limits are clear too. Usage limits "assume ordinary, individual usage" (legal and compliance), and you may not route requests through subscription credentials "on behalf of their users", meaning other people. Sharing is out: "You also may not make your Account available to anyone else" (Consumer Terms, section 2). So one person's subscription runs that person's issues on that person's machine. A team or a client runs it on their own machine with their own Claude accounts. Anthropic may enforce "without prior notice", so if your plans depend on it, read those pages yourself rather than trusting a blog. Even this one.

Get the next post by email

A short email when a new post is out or something ships. Confirm once by email, unsubscribe in one click.

All posts