← All use cases

中文

Building software · Claude Code

Force Claude Code to work task by task with one commit each

Idea + starter prompt, not run by us yet

For: Developers whose AI coding sessions drift into large messy changes

In a thread, one commenter kept tasks in a YAML file managed by a small Python script. A task-manager sub-agent has two actions: get the next task and mark one complete. Completion needs a commit ID, so each task ends in its own commit. It was not fully reliable. Claude Code sometimes ignored the sub-agent and used its built-in todo tool.

Steps

  1. Write your tasks in a simple YAML file, each with a short description and a done flag.
  2. Ask Claude Code to help write a small script and a sub-agent with two actions: next task and mark complete.
  3. Make completion require a commit ID so no task is closed without a commit.
  4. Watch the first few sessions. Claude may fall back to the built-in todo tool, so remind it of the rule when it does.
  5. Review each commit as it lands and revert any that go beyond the task.

Starter prompt

Starter prompt. Change the [brackets] first.

Trial first: do this in a scratch copy of the repo, [repo-trial], with two dummy tasks in [tasks.yaml]. Do not touch my real repo, and do not push anywhere.

Set up a task workflow. Store tasks in [tasks.yaml] with an id, description and status. Write a small Python script with two commands: next-task, which prints the first open task, and complete-task, which requires a commit id and marks that task done. Then create a sub-agent that can only use those two commands. Show me the plan and the files before you create them.

Rule for the sub-agent: work on one task at a time, make exactly one commit per task, and use no other todo list. Stop and wait for my yes before you apply this to the real repo or run any real task. A passing dummy run is not permission. Never push.

Original post: Reddit · found via agentusecases.ai. Written up in our own words. We haven't run it, so test it on made-up data first.