saml-todo-next Skill
Loops through ALL pending todo items until none remain. Each item goes through: plan → implement → commit → done.
Process
LOOP: Repeat steps 1–3 until no pending items remain. Each iteration processes one item in a fresh sub-agent context and creates one commit.
1. Find the next pending item
From .todo/todo.csv, find the first pending item sorted by:
severity: critical → high → medium → lowid(ascending numeric prefix)
import csv
SEVERITY_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3}
with open(".todo/todo.csv", newline="") as f:
pending = [r for r in csv.DictReader(f) if r["status"] == "pending"]
pending.sort(key=lambda r: (SEVERITY_ORDER.get(r["severity"], 9), r["id"]))
next_item = pending[0] if pending else None
If next_item is None → all items are done. Print summary and stop.
2. Read the detail file
Read the corresponding .todo/{id}.md file for full context:
cat .todo/{id}.md
3. Launch fresh sub-agent to process item
Launch a single general-purpose task sub-agent with a fresh context. This sub-agent is stateless — pass all context it needs in the prompt. The sub-agent will:
- Mark the item as
in_progressin.todo/todo.csv - Invoke
saml-planskill (automation mode — no interactive questions) - If plan passes: invoke
saml-implementskill with the plan file path - If implement passes:
git add . && git commit --file .git/GITGUI_MSG - Mark item as
donein.todo/todo.csv - Return result (success/failure + plan file path + summary)
Sub-agent context
Pass the following in the sub-agent prompt:
Todo item details:
- ID:
{next_item["id"]} - Title:
{next_item["title"]} - Description:
{next_item["description"]} - Severity:
{next_item["severity"]}
Detail file:
{contents of .todo/{id}.md}
Project context (to help the sub-agent navigate):
- AGENTS.md contents (list of available skills)
- Makefile if present in project root
Explicit instruction in prompt:
This is automation mode. You are processing a single todo item.
- Invoke
saml-planskill WITHOUT interactive questions (automation mode).- Pass the todo details as context to saml-plan.
- After plan succeeds, invoke
saml-implementwith the exact plan file path.- After implement succeeds, run:
git add . && git commit --file .git/GITGUI_MSG- Mark item done in .todo/todo.csv
- Report: STATUS: PASS|FAIL, plan file path, summary
Sub-agent expected output
The sub-agent must report back:
STATUS: PASSorSTATUS: FAIL- Plan file path (e.g.,
.plan/2025-01-15-14-30-01-itemlistscreen.md) - If FAIL: reason and which step failed (plan/implement/commit/mark-done)
Error handling for this step
- Sub-agent returns
STATUS: FAIL: Stop the loop. Report the failure reason and which step failed. Leave item asin_progressin.todo/todo.csv. - Sub-agent times out or crashes: Stop the loop. Leave item as
in_progressin.todo/todo.csv. Report timeout/crash.
→ Loop: Go back to Step 1 to process next item (if sub-agent succeeded and reported PASS).
Error Handling
- Sub-agent returns
STATUS: FAIL: Stop processing. Report the failure reason and which step failed. Leave item asin_progressin.todo/todo.csv. - Sub-agent times out or crashes: Stop processing. Leave item as
in_progress. Report timeout/crash to user. - Normal completion after all items done: Print summary of completed items and commits.
On any error, output a summary of:
- Items completed (marked
done) - Items in progress that encountered errors
- Next steps for the user
Workflow reference
From saml-code-review — "Working Through Todos":
- Pick the next pending item from
.todo/todo.csv(start with critical).saml-plan→ creates.plan/YYYY-MM-DD-hh-mm-TICKET-ID.mdsaml-implement→ implements from the plan, reviews, fixes. Only ifsaml-planwas successful.- Mark done in
.todo/todo.csvonly ifsaml-implementwas successful.- Execute
git add .andgit commit --file .git/GITGUI_MSGto create a commit, only if successful.- Repeat from step 1 until no pending items remain.
saml-todo-next handles all steps 1-6 automatically. User only invokes saml-todo-next once and it processes every pending item, one commit per item.