Skip to main content

Claude Code: Keeping It Running for Hours

· 5 min read
Craig P. Motlin
Software Engineer

How I use todo lists and agents to keep Claude Code running autonomously for over an hour, processing entire task lists within the 200k token context window.

This post is part of my Claude Code setup series. If you're new to agents, read From Slash Commands to Agents first.

As I scaled up my Claude Code usage with slash commands and git worktrees, I found myself babysitting instances of Claude Code. I was trying to figure out how to get Claude to work for longer without my input when Anthropic released subagents. After converting slash commands into subagents I figured I could build higher-level subagents to "loop" and keep Claude running autonomously for longer.

First Attempt: The /todo Command​

The final slash command in my original setup was /todo. This command would find the next incomplete task in todo.md and do it. It worked but I was still babysitting. I'd have multiple Claude instances running across different projects and I'd periodically check in, to see which ones were getting stuck or needed help. But when things were going well, I would just watch and occasionally type /todo to kick off the next task.

I briefly experimented with worktrees to run multiple tasks in parallel, but found it was often more trouble than it was worth.

My next attempt is what I settled on. /todo became the markdown-tasks:do-one-task skill, and a looping markdown-tasks:do-all-tasks skill runs it repeatedly. Now my process is:

  • Create a markdown todo list in .llm/todo.md
  • Run /do-all-tasks to have Claude work through the entire list
  • Occasionally check in, and potentially append or reorder tasks while Claude works

This works well. I've had Claude run for over an hour several times, and much longer on occasion. The longest I've had it run is on a porting task where each todo item took the form "Port file X from JavaScript to TypeScript". Claude worked through the entire list autonomously, with no human intervention, for over 2 hours. If my JavaScript project was bigger, Claude could have kept going for longer.

The Current Solution: do-one-task and do-all-tasks​

The /todo command is now the do-one-task skill, and the looping do-all-tasks skill processes the entire list.

The do-one-task Skill​

The do-one-task skill is nearly identical to the /todo slash command from my previous post. It gets the next task with task_get.py, implements it, runs the orchestration:finish skill (git:commit, build:precommit, git:git-rebase), and marks it complete with task_mark.py.

The do-all-tasks Skill​

The do-all-tasks skill is where the magic happens:

  • Find whether there is an incomplete task using task_get.py
  • Launch a fresh subagent that follows the do-one-task skill
  • Check that the subagent left exactly one commit and that it passes precommit
  • Repeat until no incomplete tasks remain

The main conversation stays clean throughout this process. All the verbose output - test failures, build logs, git operations, file edits - happens inside each subagent's separate context and never touches the main window. This context isolation is what makes it possible to run for over an hour without hitting the token limit.

Skill Hierarchy: Skills Calling Skills​

The full hierarchy looks like this:

do-all-tasks → launch a subagent per task... Repeat until no incomplete tasks
└── do-one-task → Implement the task... then run orchestration:finish:
├── Commit to git using git:commit
├── Verify the build passes using build:precommit
└── Rebase on upstream with git:git-rebase
└── Resolve merge conflicts with git:conflicts

Each skill has a focused job. The prompts explicitly tell each skill when to hand off to another. This creates a deep chain of automation where each piece handles one specific concern.

Try It Yourself​

Start with a simple todo list:

- [ ] Add a test for feature X
- [ ] Implement feature X
- [ ] Update documentation

Save it to .llm/todo.md, then run /do-all-tasks. Watch Claude work through the entire list autonomously.

You can copy my setup from the markdown-tasks plugin, along with the git, build, and orchestration plugins its skills call.