Courses / Build an Autonomous Claude Code AgentProLesson 6 of 93:56

Run Claude Headless on an Issue

One script runs Claude headless with the fix-issue skill on GitHub issue 178, in its own worktree, and opens a pull request. Why a worktree per issue, and how the same run moves to CI or a sandbox.

Transcript

Let's go. so this is as I said, this is very basic skill I have created just for following or just demonstrating how you can solve this problem. Okay. So I have added an issue 178 on GitHub. the issue is about you know splitting 10 dollars three ways loses a cent and like that's how you will do the split and so on. That is that is a very small very small issue ticket I created, and that issue have details on what need to be run. Let me okay. So this is the issue splitting $10, and it is actually running bin fix issue, and I will show what that what that fixed issue script have after running. The script ran the test itself and it actually finishes with a PR. Okay, basically that script have a headless mode Claude invocation. So the Claude is basically taking okay, Claude dash P and you know fix issue is our skill. It is calling the skill and it is giving what is the title and it is setting like okay, let's run with a headless mode and permission mode, don't ask. So automatically, this is the script to it. you create a worktree and you push to the origin. you create a PR and push it. So this is a pretty pretty much an automation just with this script on on a Claude Code repository Claude directory so why a worktree? So every time when you are you know going over multiple issues. for example, you are throwing multiple issues in a headless mode and you are creating your PR. If you are having a port of 4100 for your application, and if you are creating multiple PRs which has collisions, so automatically what happens is like untracked files will have 10 different changes if you are throwing 10 different issues, which is going on. So instead of doing that, you are basically throwing and creating a worktree environment. And I personally use there is a tool called Worktrunk. What it does is like you can configure pre-hook and post hook. it can even change your port dynamically or your database dynamically locally, it will call some of the database or whatever configuration which need to be dynamic per run. So it will the first will run 4100 and second will run 4101 and so on. So you can you know without any collision, it can able to run those again. This is something you can run. Yeah, headless mode can be run not only in your local machine. In this case, I am demonstrating with a local machine, but you can run Claude headless in your CA environment or even in your sandbox environment. Like instead of running it locally, you can just throw it for in your software factory, and you can say, okay, this plan is done, the triage is done, the plan is done, okay. You can execute it, and execution can happen in Modal or whatever environment you are picking up.

This lesson comes with Pro, $149 a year: Get Pro. This lesson is cut from the free Lightning session Build an Autonomous Claude Code Agent. The Live Labs build the same system with you, free, on Thursdays: see the Live Labs.