quiet robot

Recipe: Claude Code to a pull request

Installs Claude Code in a sandbox, has it fix a repository until the tests pass, and opens a pull request once a person approves. What it does, when to use it, how to make it yours, and what a run costs.

View as Markdown

Installs Claude Code in a sandbox, gives it a task on a repository, and runs the tests. If they fail, Claude Code goes again. When they pass, a person reviews the change, and approving it commits it on a new branch and opens a pull request. Your Claude key reaches Claude Code only as a stand-in, and the run's key budget caps what it can spend.

At a glanceNotes
LevelAdvanced
CategoryCoding
ShapeA coding agent, tests, a person, a pull request
PlanFree and up
Needs a Claude keyYes
Limits it comes with2 loops, 1800 seconds, $0.50
Claude key limit for a run$2.00 of Claude
Claude Code to a pull request, as it is on the canvas.Get the repository (Run command), Install Claude Code (Run command), Claude Code works (Run command), Do the tests pass? (Decide), Open the pull request? (Approval), Open the pull request (Run command), Not opened (Output). Arrows: Get the repository to Install Claude Code; Install Claude Code to Claude Code works; Claude Code works to Do the tests pass? on Either way; Do the tests pass? to Claude Code works on No; Do the tests pass? to Open the pull request? on Yes; Open the pull request? to Open the pull request on Approved; Open the pull request? to Not opened on Denied.Either wayNoYesApprovedDenied>_ RUN COMMANDGet the repository>_ RUN COMMANDInstall Claude Code>_ RUN COMMANDClaude Code works◆ DECIDEDo the tests pass?✋ APPROVALOpen the pull request?>_ RUN COMMANDOpen the pull request⚑ OUTPUTNot opened
Claude Code to a pull request, as it is on the canvas.
Try it nowSimulateRun

Opens it in the Playground as a flow of your own. Simulate shows what a run costs. Run asks before it starts.

The steps

StepBlockWhat it does
Get the repositoryRun commandMakes a sample repository with three pricing bugs and a task in TASK.md. Swap in git clone for yours.
Install Claude CodeRun commandInstalls Claude Code with qr-agents install claude.
Claude Code worksRun commandRuns claude -p with the task, through the gateway, so the real key never enters the sandbox.
Do the tests pass?DecideRuns the tests. No sends Claude Code back to work.
Open the pull request?ApprovalA person reads the diff and Claude Code's summary, then approves opening the pull request.
Open the pull requestRun commandCommits on a new branch, writes PR.md, and opens the pull request when a repository and GITHUB_TOKEN are set.

When to use it

  • You want Claude Code to work on a real repository unattended, in a machine that isn't yours.
  • Every change must pass the tests and be seen by a person before it becomes a pull request.
  • You want its spend capped per run.

Run it

The quick way: choose Try it now under the drawing. It opens the recipe in the Playground as a flow of your own, after you sign in if you aren't yet. Simulate opens it and shows the forecast, and Run opens it and asks before it starts, with what the run will likely cost. From the dashboard instead:

  1. In the dashboard sidebar, open Agent Playground → Recipes and find Claude Code to a pull request. Choose Advanced to filter the list. In the builder, Recipes in the toolbar lists them too.
  2. Choose Use this recipe. It becomes a flow of your own, so changing it never changes the recipe.
  3. If you haven't yet, save your Claude key on the Secrets page. The builder offers Add a key… in the step's key list if it's missing.
  4. Choose Simulate to see the forecast, then Run.
  5. When the run waits for a person, approve or deny it from the banner, from Approvals, or from the approval email.

What you'll see: Installing takes about half a minute, then Claude Code works for a minute or two. Open Claude Code works for its summary. The run waits at Open the pull request?; approve it and the last step says it committed and wrote PR.md. With the sample repository nothing is pushed.

Make it yours

  1. Save a GitHub token on the Secrets page as GITHUB_TOKEN, allowed for github.com and api.github.com, and add it to the flow's secrets.
  2. In Get the repository, clone yours: git clone https://github.com/you/app shop, and put your task in TASK.md (or read it from an issue with a trigger).
  3. Change the test command in Do the tests pass?.
  4. The flow's key limit caps Claude Code at $2 a run. The Policy panel shows it; change it in the flow's JSON under policy.keyBudgets.

What a run costs

These are the builder's own forecast for the recipe as it comes, with its limits, rounded. Simulate shows the same numbers for your version, and they change as you change the flow.

NotesTypical1 in 10 runsAt most
Sandbox time$0.004$0.005$0.02
Claude, on your key$0.0000$0.0000the run's spend limit
How long it takesabout 5 minutesabout 7 minutes1800 seconds

A typical run uses $0.004 of sandbox time, so about 270 runs cost $1, and every plan includes $5 of usage a month. The time includes a person taking a minute or two to answer the approval. The clock, and the sandbox, keep running while the run waits. Claude is billed by Anthropic to your own key, at their usual prices. The run counts it toward its spend limit, so it can't overspend, but we don't charge you for it. At most is the most a run could cost with these limits: it stops at $0.50 or 1800 seconds, whichever comes first.

  • Agent PlaygroundQuickstart: build and run your first flow
  • Agent PlaygroundBlocks
  • Agent PlaygroundRecipes
  • SandboxesQuickstart: your first sandbox
  • SandboxesMCP server
  • SandboxesAPI reference
  • InsightsAll posts