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.
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 glance | Notes |
|---|---|
| Level | Advanced |
| Category | Coding |
| Shape | A coding agent, tests, a person, a pull request |
| Plan | Free and up |
| Needs a Claude key | Yes |
| Limits it comes with | 2 loops, 1800 seconds, $0.50 |
| Claude key limit for a run | $2.00 of Claude |
Opens it in the Playground as a flow of your own. Simulate shows what a run costs. Run asks before it starts.
The steps
| Step | Block | What it does |
|---|---|---|
| Get the repository | Run command | Makes a sample repository with three pricing bugs and a task in TASK.md. Swap in git clone for yours. |
| Install Claude Code | Run command | Installs Claude Code with qr-agents install claude. |
| Claude Code works | Run command | Runs claude -p with the task, through the gateway, so the real key never enters the sandbox. |
| Do the tests pass? | Decide | Runs the tests. No sends Claude Code back to work. |
| Open the pull request? | Approval | A person reads the diff and Claude Code's summary, then approves opening the pull request. |
| Open the pull request | Run command | Commits 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:
- 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.
- Choose Use this recipe. It becomes a flow of your own, so changing it never changes the recipe.
- 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.
- Choose Simulate to see the forecast, then Run.
- 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
- Save a GitHub token on the Secrets page as
GITHUB_TOKEN, allowed forgithub.comandapi.github.com, and add it to the flow's secrets. - In Get the repository, clone yours:
git clone https://github.com/you/app shop, and put your task inTASK.md(or read it from an issue with a trigger). - Change the test command in Do the tests pass?.
- 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.
| Notes | Typical | 1 in 10 runs | At most |
|---|---|---|---|
| Sandbox time | $0.004 | $0.005 | $0.02 |
| Claude, on your key | $0.0000 | $0.0000 | the run's spend limit |
| How long it takes | about 5 minutes | about 7 minutes | 1800 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.