/ultrawork:ultrawork-plan [--auto] <goal> | --helpfrom ultrawork
Interactive planning phase - explore, clarify, design, then produce task breakdown
Ships in ultrawork. Installing the plugin adds it to Claude Code.
Standalone interactive planning - use when you want to plan before committing to execution.
This command follows the planning skill protocol (skills/planning/SKILL.md).
/ultrawork-plan "goal"
↓
Initialize → Exploration → Clarification → Design → Task Breakdown
↓
Output: design.md + tasks/ (ready for /ultrawork-exec)
The orchestrator MUST delegate exploration to sub-agents. Direct execution is prohibited except for Overview.
| Phase | Delegation | Direct Execution |
|---|---|---|
| Overview Exploration | N/A | ALWAYS via Skill(skill="ultrawork:overview-exploration") |
| Targeted Exploration | ALWAYS via Task(subagent_type="ultrawork:explorer") | NEVER |
| Planning (non-auto) | N/A | ALWAYS (interactive by design) |
| Planning (auto) | ALWAYS via Task(subagent_type="ultrawork:planner") | NEVER |
Exception: User explicitly requests direct execution (e.g., "run this directly", "execute without agent").
To allow user interruption during exploration, use background execution with polling.
# Poll pattern for all Task waits
while True:
# Check if session was cancelled
phase = Bash(f'bun "{CLAUDE_PLUGIN_ROOT}/src/scripts/session-get.js" --session ${CLAUDE_SESSION_ID} --field phase')
if phase.output.strip() == "CANCELLED":
return # Exit cleanly
# Non-blocking check
result = TaskOutput(task_id=task_id, block=False, timeout=5000)
if result.status in ["completed", "error"]:
break
All scripts require --session <id> flag. Extract the actual UUID from system-reminder, not placeholders.
📖 Detailed guide: See Session ID Handling Guide
Quick reference:
# Get SESSION_ID from system-reminder hook output
# Example: CLAUDE_SESSION_ID: 37b6a60f-8e3e-4631-8f62-8eaf3d235642
# Use actual UUID (NOT placeholders like ${CLAUDE_SESSION_ID})
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/setup-ultrawork.js" --session 37b6a60f-8e3e-4631-8f62-8eaf3d235642 --plan-only "goal"
# Get session directory
SESSION_DIR=~/.claude/ultrawork/sessions/37b6a60f-8e3e-4631-8f62-8eaf3d235642
# ${CLAUDE_SESSION_ID} is auto-replaced by Claude Code v2.1.9+
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/setup-ultrawork.js" \
--session ${CLAUDE_SESSION_ID} \
--plan-only \
--goal "$(cat <<'EOF'
$ARGUMENTS
EOF
)"
After initialization, get session_dir via variable:
SESSION_DIR=~/.claude/ultrawork/sessions/${CLAUDE_SESSION_ID}
Parse the setup output to get:
Before starting exploration, check session state to determine where to resume.
📖 Detailed guide: See Explorer Phase - Resume Check
Quick reference:
# Read session state
exploration_stage = Bash(f'bun "{CLAUDE_PLUGIN_ROOT}/src/scripts/session-get.js" --session ${CLAUDE_SESSION_ID} --field exploration_stage')
# Resume based on stage
# not_started → Begin overview
# overview → Check overview.md exists → proceed to targeted
# analyzing → Generate hints, set expected_explorers
# targeted → Check for missing explorers, re-spawn if needed
# complete → Skip to planning
Exploration happens in three stages: Overview → Analyze → Targeted.
📖 Detailed guide: See Explorer Phase Reference
Stage 1: Overview (Direct via Skill)
Skill(skill="ultrawork:overview-exploration")
Produces: exploration/overview.md, context.json
Stage 1b: Scope Analysis (Parallel with Overview)
Spawn scope analyzer to detect cross-layer dependencies:
# After overview exploration completes, spawn scope analyzer
Task(
subagent_type="ultrawork:scope-analyzer:scope-analyzer",
model="haiku",
prompt=f"""
SESSION_ID: ${CLAUDE_SESSION_ID}
SCRIPTS_PATH: ${CLAUDE_PLUGIN_ROOT}/src/scripts
REQUEST: {goal}
CONTEXT: (Read from exploration/overview.md after it exists)
"""
)
The scope analyzer runs in parallel with targeted exploration. It writes results to context.json via scopeExpansion field.
Stage 2: Analyze & Plan Targeted
# Update stage
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-update.js" --session ${CLAUDE_SESSION_ID} --exploration-stage analyzing
# Analyze overview + goal → generate hints
# Set expected explorers BEFORE spawning
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/context-init.js" --session ${CLAUDE_SESSION_ID} --expected "overview,exp-1,exp-2"
Stage 3: Targeted Exploration
# Update stage
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-update.js" --session ${CLAUDE_SESSION_ID} --exploration-stage targeted
# Spawn explorers (parallel, in single message)
# Task(subagent_type="ultrawork:explorer:explorer", ...) for each hint
# After completion
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-update.js" --session ${CLAUDE_SESSION_ID} --exploration-stage complete
Output: exploration/*.md, context.json with exploration_complete=true
📖 Detailed guides:
--auto was set → Auto ModeSpawn Planner sub-agent:
# SESSION_DIR is set via: SESSION_DIR=~/.claude/ultrawork/sessions/${CLAUDE_SESSION_ID}
Task(
subagent_type="ultrawork:planner:planner",
model="opus",
prompt=f"""
SESSION_ID: ${CLAUDE_SESSION_ID}
SCRIPTS_PATH: ${CLAUDE_PLUGIN_ROOT}/src/scripts
Goal: {goal}
Options:
- require_success_criteria: true
- include_verify_task: true
"""
)
# Foreground execution - waits for completion
Skip to Step 4 (Plan Review).
--auto was NOT set → Interactive ModeRun planning skill directly in main agent (YOU).
Reference: skills/planning/SKILL.md
# Get session directory
SESSION_DIR=~/.claude/ultrawork/sessions/${CLAUDE_SESSION_ID}
# Get context summary (AI-friendly markdown) - NEVER use Read on JSON
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/context-get.js" --session ${CLAUDE_SESSION_ID} --summary
# Or get specific fields
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/context-get.js" --session ${CLAUDE_SESSION_ID} --field key_files
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/context-get.js" --session ${CLAUDE_SESSION_ID} --field patterns
# Read detailed exploration files (Markdown OK)
Read("$SESSION_DIR/exploration/exp-1.md")
Read("$SESSION_DIR/exploration/exp-2.md")
Read("$SESSION_DIR/exploration/exp-3.md")
## Exploration Results
**Project Type**: {from exploration}
**Key Files**: {from context.json}
**Patterns Found**: {from exploration}
Based on the goal "{goal}", I found:
{summary of relevant findings}
If scope expansion was detected, display it and ask user preference:
# Get scopeExpansion via script (NEVER Read JSON directly)
# Bash: bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/context-get.js" --session ${CLAUDE_SESSION_ID} --field scopeExpansion
scopeExpansion = parse_json(scope_output)
if scopeExpansion and scopeExpansion.get('dependencies'):
# Display analysis
print(f"""
## 📊 Scope Expansion Analysis
**Original Request**: {scopeExpansion['originalRequest']}
**Detected Layers**: {', '.join(scopeExpansion['detectedLayers'])}
**Confidence**: {scopeExpansion['confidence']}
### Dependencies Detected
| From | To | Type | Reason |
|------|----|------|--------|
{format_dependency_table(scopeExpansion['dependencies'])}
### Suggested Additional Tasks
{format_suggested_tasks(scopeExpansion['suggestedTasks'])}
### Blocking Constraints
{format_constraints(scopeExpansion['blockingConstraints'])}
""")
# Ask user preference (Interactive mode only)
AskUserQuestion(questions=[{
"question": "Include scope expansion tasks?",
"header": "Scope",
"options": [
{"label": "Include all (Recommended)", "description": "Add all blocking + recommended dependencies"},
{"label": "Blocking only", "description": "Only add tasks for blocking dependencies"},
{"label": "Skip", "description": "Proceed with original request only"}
],
"multiSelect": False
}])
Store user's choice for planner to use when creating tasks.
Batch related questions (max 4 per call). Reference skills/planning/SKILL.md Phase 2-3 and commands/references/03-interview.md.
For each ambiguous or unclear aspect:
AskUserQuestion(questions=[{
"question": "Which authentication method should we implement?",
"header": "Auth method",
"options": [
{"label": "OAuth + Email/Password (Recommended)", "description": "Most flexible, supports both"},
{"label": "OAuth only", "description": "Simpler, relies on social providers"},
{"label": "Email/Password only", "description": "Traditional, no third-party deps"}
],
"multiSelect": False
}])
Question Types:
Continue until all decisions are made.
Present design in sections (~200-300 words each). After each section:
AskUserQuestion(questions=[{
"question": "Does this section look correct?",
"header": "Review",
"options": [
{"label": "Yes, continue", "description": "Move to next section"},
{"label": "Needs adjustment", "description": "I have feedback"}
],
"multiSelect": False
}])
IMPORTANT: Design documents go to PROJECT directory, not session directory.
NOTE: Do NOT include Execution Strategy in the design document at this point. The design is submitted to doc-review without it. Execution Strategy (task decomposition, dependency graph, wave planning) is added after doc-review passes.
# Get working directory from session
WORKING_DIR=$(bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-get.js" --session ${CLAUDE_SESSION_ID} --field working_dir)
# Create docs/plans directory if needed
mkdir -p "$WORKING_DIR/docs/plans"
# Generate filename with date and goal slug
# Format: YYYY-MM-DD-{goal-slug}-design.md
DESIGN_PATH="$WORKING_DIR/docs/plans/$(date +%Y-%m-%d)-{goal-slug}-design.md"
# Write design document to PROJECT directory (without Execution Strategy)
Write(
file_path=DESIGN_PATH,
content=design_content
)
# Store design doc path in session state (required for documentation phase)
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-update.js" --session ${CLAUDE_SESSION_ID} \
--design-doc "$DESIGN_PATH"
See skills/planning/SKILL.md Phase 4 for template.
Run Codex doc-review on the design document before proceeding to task decomposition.
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/codex-verify.js" \
--mode doc-review \
--design "$DESIGN_PATH" \
--goal "${goal}" \
--output /tmp/codex-doc-${CLAUDE_SESSION_ID}.json
Parse the result JSON:
Convergence-Aware Fix Loop:
Track error counts across attempts to detect convergence patterns:
error_history = [] # Track error count per attempt
max_attempts = 5
attempt = 0
while attempt < max_attempts:
attempt += 1
result = parse_result("/tmp/codex-doc-${CLAUDE_SESSION_ID}.json")
if result.verdict in ["PASS", "SKIP"]:
break # Success
# Track error count for convergence detection
error_count = len([i for i in result.doc_review.doc_issues if i.severity == "error"])
error_history.append(error_count)
# Detect convergence pattern (requires 2+ data points)
if len(error_history) >= 2:
trend = detect_trend(error_history)
# trend: "converging" (errors decreasing), "oscillating" (up/down),
# "diverging" (errors increasing), "stable" (no change)
# Early exit: sustained oscillation (2+ consecutive oscillating attempts)
if trend == "oscillating" and len(error_history) >= 3:
consecutive_oscillations = count_tail_oscillations(error_history)
if consecutive_oscillations >= 2:
AskUserQuestion(questions=[{
"question": f"Doc-review is oscillating ({error_history}). Auto-pass remaining issues?",
"header": "Convergence",
"options": [
{"label": "Auto-pass", "description": "Downgrade remaining errors to warnings and proceed"},
{"label": "Keep trying", "description": "Continue fix attempts"}
],
"multiSelect": False
}])
if user_chose_autopass:
break # Fall through to auto-pass below
# Show issues to user
AskUserQuestion(questions=[{
"question": f"Doc-review found {error_count} issues (attempt {attempt}/{max_attempts}):\n{doc_issues}\n\nHow to proceed?",
"header": "Doc Review",
"options": [
{"label": "Fix and re-review", "description": "Apply fixes and run doc-review again"},
{"label": "Skip review", "description": "Proceed without fixing (not recommended)"}
],
"multiSelect": False
}])
# Fix design document based on issues, then re-run codex-verify.js
Convergence Detection Logic:
def detect_trend(error_history):
"""Analyze error count trend across attempts."""
if len(error_history) < 2:
return "insufficient"
deltas = [error_history[i] - error_history[i-1] for i in range(1, len(error_history))]
if all(d < 0 for d in deltas):
return "converging" # Errors consistently decreasing
if all(d > 0 for d in deltas):
return "diverging" # Errors consistently increasing
if all(d == 0 for d in deltas):
return "stable" # No change
# Check for oscillation (alternating up/down)
sign_changes = sum(1 for i in range(1, len(deltas)) if deltas[i] * deltas[i-1] < 0)
if sign_changes >= len(deltas) - 1:
return "oscillating" # Errors bouncing up and down
return "mixed"
def count_tail_oscillations(error_history):
"""Count consecutive oscillating pairs from the tail."""
count = 0
for i in range(len(error_history) - 1, 1, -1):
d1 = error_history[i] - error_history[i-1]
d2 = error_history[i-1] - error_history[i-2]
if d1 * d2 < 0: # Sign changed = oscillation
count += 1
else:
break
return count
Auto-Pass Fallback (when max retries reached or user accepts):
If the loop exits without PASS after max 5 attempts (or user chose auto-pass on oscillation):
# 1. Transform FAIL result to PASS (downgrade errors to warnings)
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/codex-autopass.js" --session ${CLAUDE_SESSION_ID}
# 2. Append known issues section to design document
# Read remaining doc_issues from the auto-passed result
autopass_result = parse_result("/tmp/codex-doc-${CLAUDE_SESSION_ID}.json")
remaining_issues = [i for i in autopass_result.doc_review.doc_issues if "[auto-pass]" in i.detail]
if remaining_issues:
# Append to design document
issues_section = "\n\n## Known Doc-Review Issues (Auto-Passed)\n\n"
issues_section += "The following issues were auto-passed after convergence control:\n\n"
for issue in remaining_issues:
issues_section += f"- **{issue.category}**: {issue.detail.replace('[auto-pass] ', '')}\n"
# Edit design document to append
Edit(file_path=DESIGN_PATH, append=issues_section)
CLI Error Handling: If codex-verify.js fails to execute, retry once. On repeated failure, leave session in PLANNING and report.
Note: A gate in gate-enforcement.js will block session-update.js --phase EXECUTION if no passing Codex doc-review result exists.
NOTE: Write the Execution Strategy section to the design document BEFORE decomposing tasks. Now that doc-review has passed, add the Execution Strategy (task breakdown, dependency graph, wave planning) to the design doc, then create the task files.
Decompose design into tasks. Write each task:
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/task-create.js" --session ${CLAUDE_SESSION_ID} \
--id "1" \
--subject "Setup NextAuth provider" \
--description "Configure NextAuth with credentials" \
--complexity standard \
--criteria "Auth routes respond|Login flow works"
Always include verify task at end.
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-update.js" --session ${CLAUDE_SESSION_ID} --phase PLANNING_COMPLETE
Read the plan:
# Get working directory and session directory
WORKING_DIR=$(bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-get.js" --session ${CLAUDE_SESSION_ID} --field working_dir)
SESSION_DIR=~/.claude/ultrawork/sessions/${CLAUDE_SESSION_ID}
# List tasks
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/task-list.js" --session ${CLAUDE_SESSION_ID}
# Read design (from PROJECT directory)
Read("$WORKING_DIR/docs/plans/YYYY-MM-DD-{goal-slug}-design.md")
Display plan summary:
## Ultrawork Plan
**Goal**: {goal}
| ID | Task | Complexity | Blocked By |
| ------ | ------------ | ---------- | ---------- |
| 1 | Setup schema | standard | - |
| 2 | Build API | complex | 1 |
| verify | Verification | complex | 1, 2 |
**Waves:**
- Wave 1: [1] - can start immediately
- Wave 2: [2] - after Wave 1
- Wave 3: [verify] - after all
If Interactive mode (not --auto):
AskUserQuestion(questions=[{
"question": "Ready to proceed with this plan?",
"header": "Plan approval",
"options": [
{"label": "Approve", "description": "Execute this plan"},
{"label": "Request changes", "description": "Modify the plan"},
{"label": "Cancel", "description": "Cancel the session"}
],
"multiSelect": False
}])
/ultrawork-execPlanning creates:
Project Directory ($WORKING_DIR):
docs/plans/YYYY-MM-DD-{goal-slug}-design.md - comprehensive design documentSession Directory ($SESSION_DIR):
tasks/*.json - task files (internal metadata)context.json - exploration summariesexploration/*.md - detailed explorationRun /ultrawork-exec to execute the plan.
Session Directory (internal metadata):
~/.claude/ultrawork/sessions/${CLAUDE_SESSION_ID}
$SESSION_DIR/
├── session.json # Session metadata (JSON)
├── context.json # Explorer summaries (JSON)
├── exploration/ # Detailed exploration (Markdown)
│ ├── overview.md
│ ├── exp-1.md
│ ├── exp-2.md
│ └── exp-3.md
└── tasks/ # Task files (JSON)
├── 1.json
├── 2.json
└── verify.json
Project Directory (user deliverables):
bun "${CLAUDE_PLUGIN_ROOT}/src/scripts/session-get.js" --session ${CLAUDE_SESSION_ID} --field working_dir
$WORKING_DIR/
└── docs/
└── plans/
└── YYYY-MM-DD-{goal-slug}-design.md # Design document
| Aspect | Interactive (default) | Auto (--auto) |
|---|---|---|
| Exploration | Orchestrator spawns explorers | Same |
| Planning | Orchestrator runs planning skill | Planner sub-agent |
| User Questions | AskUserQuestion for decisions | Auto-decide |
| Confirmation | User approves plan | No confirmation |
| Best For | Important features, unclear requirements | Well-defined tasks, CI/CD |
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
17 commands in this plugin
/references:01-explorerExplorer Phase Reference**Used by**: `ultrawork.md`, `ultrawork-plan.md`/references:02-planningPlanning Phase Reference**Used by**: `ultrawork.md`, `ultrawork-plan.md`/references:03-interviewInterview Phase Reference**Used by**: `ultrawork-plan.md` (interactive mode only)/references:04-executeExecute Phase Reference**Used by**: `ultrawork.md`, `ultrawork-exec.md`/references:05-validateValidate Phase Reference**Used by**: `ultrawork.md`, `ultrawork-exec.md`/references:06-documentDocumentation Phase Reference**Used by**: `ultrawork.md`, `ultrawork-exec.md`npx claudepluginhub mnthe/hardworker-marketplace --plugin ultrawork