AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 9, 2026, 22:00 JST

Claude Code cleans up crashed runs' uncommitted files

Claude Code cleans up crashed runs' uncommitted files

A write-up describes running Claude Code unattended every four hours via Windows Task Scheduler and Python, with each session reading a charter file; when a run dies on a usage limit, time cap, or PC crash, the next session sorts leftover uncommitted git changes by owner.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The write-up is drawn from the records of a small setup where Claude Code runs as a CEO role every four hours: Windows Task Scheduler wakes a Python launcher, the launcher starts claude -p, and the session picks work, delegates to subagents, and writes an end-of-run report. The keep-it-working premise is that each task is committed as it finishes, and that the launcher checks a lock file before starting so two runs never share one working tree.

What makes the recovery step hard is that leftover files are not all the same. A charter entry tells the session that files the launcher itself writes — instruction sheets, execution logs, failure and skip records, break notices — are not crash artifacts and should be committed as-is; a dated example shows an instruction sheet left untracked and committed with that reasoning. Human edits get a third lane: off-limits, logged, and handed back to a person.

The author is candid about limits. Deciding whether a prior run's work is complete is a judgment call, so countable finish criteria make it more mechanical. And because deletion is not permitted, untracked broken files simply remain until a human decides. The state file adds a second check: the board and the git history can disagree, so all three — tree, history, state — get compared.

FAQ
How does the next Claude Code session know a previous run crashed?
The author says commits are made one task at a time, so a clean working tree is expected after a run that finished. If uncommitted changes remain at the start of a run, the session treats them as a sign the prior run was cut off.
What happens to uncommitted changes a human made?
They are left alone. The write-up says one CEO session tried to commit a human-edited script, was blocked by a guard on git add, and asked a human instead of looking for a workaround; later runs skipped it and logged it.
Why restore files one by one instead of the whole working tree?
The charter calls for naming each file individually. The write-up reads this as a way to target only the prior Claude's half-finished work, since a human's edits can sit in the same repo for days.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleOpenAI halts Dark Clark, Iranian fake-byline influence ops