Day 6, 30 minutes · advanced
Why it matters
Everything so far still needed you to start the run. The last step is work that starts by itself or runs next to other work: a check every few minutes, two sessions in parallel, a job on a schedule. That is where unattended work really happens, and also where a mistake can sit unnoticed the longest.
So this lesson has two halves. First the tools: /loop for repeating a prompt in an open session, scheduled tasks that run without one, worktrees for parallel sessions that cannot collide, and GitHub Actions at a glance. Then the part that matters most: a short routine to check what an unattended run produced, before you trust it.
At the end Ines has run a loop and cancelled it, built a second batch of cards in a separate worktree and merged it, and has her own checklist for every run she does not watch.
Repeat a prompt with /loop
/loop repeats a prompt while your session stays open. /loop 10m git check, and tell me in one line whether every card passes runs every ten minutes. Without an interval, Claude picks the wait itself, between one minute and one hour. The scheduled tasks page sets the limits:
- A loop only fires while Claude Code is running and idle. Close the session and it stops.
- A fixed-interval loop does not stop with
Esc. Ask Claude to cancel it, for example "cancel the card check loop". "What scheduled tasks do I have?" lists them. - A recurring task ends by itself 30 days after you create it.
- Runs are spread out a little on purpose, so a ten-minute loop can start a few minutes late.
Each run is another turn in the same conversation, so do not leave a loop going in a long session you also use for other work.
Schedules that run without you
For work that must run while your laptop is closed, Claude Code has cloud scheduled tasks (formerly called routines). You create them with /schedule or at claude.ai/code/routines. They run on Anthropic's cloud and work in a fresh copy of the GitHub repositories you pick, not in files on your computer, so the practice project does not fit. They are a research preview, on Pro, Max, Ultra, Team and Enterprise plans. Desktop scheduled tasks run on your own computer and need it switched on.
The best practices page adds two warnings before you leave one running: protect your main branch with a GitHub rule the task cannot bypass, and watch the first few runs of anything new.
Parallel sessions with worktrees
A git worktree is a second working folder of the same repository, on its own branch. claude -w shelf-b starts Claude Code in a new worktree at .claude/worktrees/shelf-b, on a branch called worktree-shelf-b. Two sessions in two worktrees can edit at the same time without touching each other's files. The worktrees page covers the details:
- A worktree is a fresh checkout. Anything that is not committed, or that git ignores, is not there. Commit first.
- Add
.claude/worktrees/to.gitignore, so the worktree does not show up as new files in your main folder. - When you leave a worktree session, Claude Code checks it for work. If it has changes or new commits, Claude Code asks whether to keep or remove it. Removing deletes the folder and its branch, so merge first.
GitHub Actions at a glance
For a project on GitHub, the GitHub Actions page describes running Claude Code inside your repository's workflows: answering @claude in an issue or pull request, or running a prompt on any GitHub event. Setup starts with /install-github-app and needs admin access to the repository and the GitHub CLI. Costs come from two sides: GitHub Actions minutes and Claude usage. Its own advice is to cap runs with --max-turns and to review Claude's changes before you merge. You will not set it up in this course.
Check what an unattended run produced
A run you did not watch has to prove itself. Use the same routine every time:
- Read what changed.
git log --onelinefor the commits,git difffor the lines. Look for files outside the task. - Run the check yourself. Do not rely on the run's own "OK". Run
git checkin your terminal. - Read the evidence. For a goal,
/goalshows the turns, time and spend, andCtrl+Oshows each verdict and its reason. For a hook, the transcript shows its messages. For a-prun, the JSON and the exit code. - Decide. Merge, fix or throw away. Something you cannot take back, such as a push or a deploy, always needs a person's yes.
The best practices page boils this down to five questions before any run goes unattended: does it know what done looks like, can it check its own work, what may it touch, what stops it, and who signs off on the result? For taking this way of working to a client, see the course Ship AI at the client.
The steps
- Commit everything and ignore the worktrees folder.
- Start a loop, see it run, list it and cancel it.
- Open a worktree session in a second terminal and build three cards there.
- Check that your main folder did not change, then merge the branch.
- Close the worktree session and remove the worktree.
- Run the checking routine on the result.
- Write your unattended-run checklist.
Follow the steps for Claude Code below.
Example: Ines's checklist
"Done means: git check exits 0. Check: the Stop hook. May touch: items/ only; check.sh is denied. Stops: 10 turns. Sign-off: I read git log and git diff, run git check myself, then merge." She keeps it at the top of her project notes and reads it before every run she will not watch.
Deeper dive
Today's actions
Ticks are not saved without an accountDo it in Claude Code
Claude Code
- Start Claude Code in your practice folder and ask it to ignore the worktrees folder and commit everything, so a worktree starts from a complete copy.
Add the line .claude/worktrees/ to .gitignore, run git status, and commit everything with the message: Prepare for worktrees. - Start a loop. Claude confirms the schedule and a job ID. After the first run, list your scheduled tasks and cancel the loop, because
Escdoes not stop a fixed-interval loop./loop 10m git check, and tell me in one line whether every card passes - Ask for the list and the cancel in plain words.
What scheduled tasks do I have? Cancel the card check loop. - Open a second terminal, go into the practice folder and start a session in a new worktree. Then ask for three cards there.
cd kettleby-tools claude -w shelf-b - In the worktree session, paste this. Leave that session open afterwards.
Add cards in items/ for a spirit level, a tape measure and a staple gun, all on shelf B1 with Status: in. Run git check and commit with the message: Add shelf B cards. - Back in your first session, check that the main folder did not change, then merge the worktree's branch.
Run git status, then merge the branch worktree-shelf-b into the current branch and run git check. - In the worktree session type
/exit. Claude Code asks whether to keep or remove the worktree: the work is merged, so remove it. Then run the checking routine in your first session.! git log --oneline -5 ! git diff HEAD~1 --stat ! git check - Type
/exitand write your unattended-run checklist: what done looks like, how it checks itself, what it may touch, what stops it and who signs off.
Note: The first time you use -w, the folder must be trusted; yours is from lesson 1. Your hooks and settings come along because you committed them. A loop only runs while its session is open and idle. Cloud scheduled tasks and GitHub Actions need a project on GitHub, so this lesson only describes them.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The free Claude plan does not include Claude Code.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up