INIT=$(gsd-sdk query init.todos)
if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
Extract from init JSON: commit_docs, date, timestamp, todo_count, todos, pending_dir, todos_dir_exists.
Ensure directories exist:
mkdir -p .planning/todos/pending .planning/todos/completed
Note existing areas from the todos array for consistency in infer_area step.
Without arguments: Analyze recent conversation to extract:
- The specific problem, idea, or task discussed
- Relevant file paths mentioned
- Technical details (error messages, line numbers, constraints)
Formulate:
title: 3-10 word descriptive title (action verb preferred)problem: What's wrong or why this is neededsolution: Approach hints or "TBD" if just an ideafiles: Relevant paths with line numbers from conversation
| Path pattern | Area |
|---|---|
src/api/*, api/* |
api |
src/components/*, src/ui/* |
ui |
src/auth/*, auth/* |
auth |
src/db/*, database/* |
database |
tests/*, __tests__/* |
testing |
docs/* |
docs |
.planning/* |
planning |
scripts/*, bin/* |
tooling |
| No files or unclear | general |
Use existing area from step 2 if similar match exists.
If potential duplicate found:
- Read the existing todo
- Compare scope
Text mode (workflow.text_mode: true in config or --text flag): Set TEXT_MODE=true if --text is present in $ARGUMENTS OR text_mode from init JSON is true. When TEXT_MODE is active, replace every AskUserQuestion call with a plain-text numbered list and ask the user to type their choice number. This is required for non-Claude runtimes (OpenAI Codex, Gemini CLI, etc.) where AskUserQuestion is not available.
If overlapping, use AskUserQuestion:
- header: "Duplicate?"
- question: "Similar todo exists: [title]. What would you like to do?"
- options:
- "Skip" — keep existing todo
- "Replace" — update existing with new context
- "Add anyway" — create as separate todo
Generate slug for the title:
slug=$(gsd-sdk query generate-slug "$title" --raw)
Write to .planning/todos/pending/${date}-${slug}.md:
---
created: [timestamp]
title: [title]
area: [area]
files:
- [file:lines]
---
## Problem
[problem description - enough context for future Claude to understand weeks later]
## Solution
[approach hints or "TBD"]
- Use
todo_countfrom init context (or re-runinit todosif count changed) - Update "### Pending Todos" under "## Accumulated Context"
gsd-sdk query commit "docs: capture todo - [title]" .planning/todos/pending/[filename] .planning/STATE.md
Tool respects commit_docs config and gitignore automatically.
Confirm: "Committed: docs: capture todo - [title]"
[title] Area: [area] Files: [count] referenced
Would you like to:
- Continue with current work
- Add another todo
- View all todos (/gsd-check-todos)
</step>
</process>
<success_criteria>
- [ ] Directory structure exists
- [ ] Todo file created with valid frontmatter
- [ ] Problem section has enough context for future Claude
- [ ] No duplicates (checked and resolved)
- [ ] Area consistent with existing todos
- [ ] STATE.md updated if exists
- [ ] Todo and state committed to git
</success_criteria>