
OCDevel Claude Code · June 21
Auto-PR Workflows: Turning a Green Headless Run Into an Open Pull Request
0:00Duration unknown
transcript
show notes
Once a headless Claude run passes, the last rung is delivery: branch, commit, push, and open the PR with nobody at the keyboard. The trap that bites everyone is the PR whose own CI never runs, because GitHub won't trigger workflows for events made by the default token.
Act II continues. We turn a passing headless Claude Code run into an open pull request with no human at the keyboard, and we walk straight into the pitfall that breaks most first attempts.
News (June 17–21, 2026):
- v2.1.183 — Auto mode now blocks destructive git commands you didn't ask for (
git reset --hard,git checkout -- .,git clean -fd,git stash drop), blocksgit commit --amendon commits it didn't make this session, and guardsterraform destroy/pulumi destroy/cdk destroy. Newattribution.sessionUrlsetting omits the claude.ai link from commits and PRs. New/config --help; in the toggle, Esc now SAVES. - v2.1.181 —
/config key=valueinline from the prompt (works in-pand Remote Control),sandbox.allowAppleEvents,CLAUDE_CLIENT_PRESENCE_FILEto mute mobile pings, bundled Bun 1.4, line-by-line streaming, auto-retry on dropped connections. - v2.1.185 — Stream-stall hint reworded and now fires after 20s instead of 10s.
Tutorial — Auto-PR:
- Two homes for the logic: a local/cron bash script wrapping
claude -pthengit+gh, or a GitHub Actions workflow governed bypermissions:. - Prefer a deterministic shell GATE (tests green? non-empty diff? existing PR?) and scope Claude to the edit. Headless docs, CLI reference.
- Always
git push -u origin <branch>beforegh pr create— the push prompt is fatal with no TTY. - Actions needs
contents: writeANDpull-requests: write; missing the second is a silent 403. - The big one: PRs opened with the default
GITHUB_TOKENdo not trigger downstream workflows. Use a GitHub App token so the PR's own CI actually runs. - Idempotency: deterministic branch names +
gh pr list --headguard. Empty-diff guard withgit diff --quiet. --allowedToolsprefix footgun:Bash(git push *)with the trailing space, notBash(git push*).- The
pull_request_targetfootgun only bites on untrusted fork code; internal nightly auto-PR is on the safe side.
links10