name: doey-planned-task
description: Plan-first task creation — research, breakdown, risk analysis, then create tasks from approved plan. Usage: /doey-planned-task
- Current tasks: !
doey task list 2>/dev/null || echo "No tasks"
- Plans dir: !
bash -c 'PD=$(grep "^PROJECT_DIR=" "$(tmux show-environment DOEY_RUNTIME 2>/dev/null | cut -d= -f2-)/session.env" 2>/dev/null | cut -d= -f2- | tr -d "\""); echo "${PD:-.}/.doey/plans"'
- Existing plans: !
bash -c 'PD=$(grep "^PROJECT_DIR=" "$(tmux show-environment DOEY_RUNTIME 2>/dev/null | cut -d= -f2-)/session.env" 2>/dev/null | cut -d= -f2- | tr -d "\""); ls "${PD:-.}/.doey/plans/"*.md 2>/dev/null | head -10 || echo "None"'
Worktrees + Branches Are Forbidden By Default
Never suggest /doey-worktree, branch creation, or worktree flow in plan output. All phases commit to the session's starting branch (typically main). If — and only if — the user's literal goal text contains the word "worktree", you may surface /doey-worktree as the explicit opt-in path.
Create a plan-first task from a natural-language goal. Goal from ARGUMENTS (if empty, use AskUserQuestion to ask, then stop).
1. Analyze Goal
Classify the goal:
- TRIVIAL — Direct question or lookup → answer directly, stop
- SIMPLE — Single obvious action → skip to
/doey-instant-task instead
- COMPLEX — Multi-step, has risks, needs breakdown → continue with planning
2. Research & Breakdown
Before writing anything, research the goal:
- Read relevant code files to understand current state
- Identify what needs to change and where
- Consider dependencies between changes
- Identify risks and unknowns
Structure findings into a plan with:
- Steps: Ordered list of concrete actions with estimated complexity
- Risks: What could go wrong, mitigation strategies
- Scope: Files affected, teams needed, estimated worker count
- Acceptance criteria: How to verify the work is done correctly
3. Save Plan
Determine next plan ID:
PD=$(grep '^PROJECT_DIR=' "$(tmux show-environment DOEY_RUNTIME 2>/dev/null | cut -d= -f2-)/session.env" 2>/dev/null | cut -d= -f2- | tr -d '"')
PLANS_DIR="${PD:-.}/.doey/plans"
mkdir -p "$PLANS_DIR"
PLAN_ID=$(( $(ls "$PLANS_DIR"/*.md 2>/dev/null | sed 's/.*\///' | grep -E '^[0-9]+\.md$' | sed 's/\.md//' | sort -n | tail -1) + 1 )) 2>/dev/null || PLAN_ID=1
echo "Next plan ID: $PLAN_ID"
Write the plan file using the Write tool to ${PLANS_DIR}/${PLAN_ID}.md:
---
plan_id: <PLAN_ID>
title: "<Plan Title>"
status: draft
created: <ISO 8601 timestamp>
updated: <ISO 8601 timestamp>
---
# <Plan Title>
## Goal
<Original goal from user>
## Steps
- [ ] Step 1: <description> (complexity: low/medium/high)
- [ ] Step 2: <description> (complexity: low/medium/high)
...
## Risks
- <Risk 1>: <mitigation>
- <Risk 2>: <mitigation>
## Scope
- **Files**: <list of files affected>
- **Teams**: <team assignment recommendation>
- **Workers**: <estimated count>
## Acceptance Criteria
- <criterion 1>
- <criterion 2>
4. Present Plan for Approval
Use AskUserQuestion to present the plan summary and ask the user to approve, modify, or reject:
- Show: title, step count, risks, scope estimate
- Options: "Approve and create tasks", "Modify plan", "Cancel"
If rejected or modified, iterate. Do NOT proceed to task creation without approval.
5. Create Tasks from Approved Plan
On approval, update plan status to active:
sed -i 's/^status: draft/status: active/' "${PLANS_DIR}/${PLAN_ID}.md"
Create task(s):
TASK_ID=$(doey task create --title "TITLE" --type "TYPE" --description "DESCRIPTION")
echo "Created task #${TASK_ID}"
Link task to plan:
doey task update --id "$TASK_ID" --field "TASK_PLAN_ID" --value "$PLAN_ID"
If the plan has multiple independent steps, create subtasks:
doey task subtask add --task-id "$TASK_ID" --description "Subtask title"
Update task with plan metadata.
Success criteria format: Each criterion must describe the expected result/state, not a command to run. Criteria should be independently verifiable by automation.
- BAD: "Run go build and check it passes"
- GOOD: "go build exits 0 with no errors on stderr"
- BAD: "Check that the file exists"
- GOOD: "File .doey/tasks//result.json exists and contains valid JSON with 'status: done'"
doey task update --id "$TASK_ID" --field "intent" --value "..."
doey task update --id "$TASK_ID" --field "success_criteria" --value "criterion 1, criterion 2"
doey task update --id "$TASK_ID" --field "dispatch_plan" --value "standard"
6. Dispatch to Taskmaster
Send message to Taskmaster to pick up the new task:
RD=$(tmux show-environment DOEY_RUNTIME 2>/dev/null | cut -d= -f2-)
TASKMASTER_PANE=$(grep '^TASKMASTER_PANE=' "${RD}/session.env" 2>/dev/null | cut -d= -f2-)
TASKMASTER_PANE="${TASKMASTER_PANE:-1.0}"
doey msg send --to "${SESSION_NAME}:${TASKMASTER_PANE}" --from "${DOEY_PANE_ID}" \
--subject "new_planned_task" \
--body "TASK_ID: ${TASK_ID}
PLAN_ID: ${PLAN_ID}
TITLE: ${TASK_TITLE}
PRIORITY: ${TASK_PRIORITY:-P2}
Planned task ready for dispatch. Plan: ${PLANS_DIR}/${PLAN_ID}.md"
doey msg trigger --pane "${SESSION_NAME}:${TASKMASTER_PANE}"
7. Output
Report to user: task ID, plan ID, title, step count, dispatch status. Include paths to both plan and task files.
Rules
- Always use AskUserQuestion for user interaction — never inline questions
- Use
doey task create — never duplicate the logic
- One clarifying question max before planning
- If goal is simple, redirect to
/doey-instant-task
- Plan file must have valid YAML frontmatter with plan_id, title, status, created, updated