Execute task (continues incomplete work)
Executes a task with worktree isolation, subagent orchestration, and quality gates.
/plugin marketplace add cowwoc/claude-code-dog/plugin install dog@claude-code-dog[major.minor/task-name]Execute a task with worktree isolation, subagent orchestration, and quality gates.
This is DOG's core execution command. It:
<execution_context>
@${CLAUDE_PLUGIN_ROOT}/.claude/dog/workflows/execute-task.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/workflows/subagent-protocol.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/references/commit-types.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/skills/spawn-subagent/SKILL.md @${CLAUDE_PLUGIN_ROOT}/.claude/dog/skills/merge-subagent/SKILL.md
</execution_context>
<context>Task path: $ARGUMENTS
Load project state first: @.claude/dog/dog-config.json @.claude/dog/PROJECT.md @.claude/dog/ROADMAP.md
</context> <process> <step name="verify">MANDATORY FIRST STEP - Verify planning structure:
[ ! -d .claude/dog ] && echo "ERROR: No .claude/dog/ directory. Run /dog:new-project first." && exit 1
[ ! -f .claude/dog/dog-config.json ] && echo "ERROR: No dog-config.json. Run /dog:new-project first." && exit 1
Load configuration:
Read .claude/dog/dog-config.json to determine:
yoloMode - whether approval gates are skippedcontextLimit - total context window sizetargetContextUsage - soft limit for task sizeIdentify task to execute:
If $ARGUMENTS provided:
major.minor/task-name format.claude/dog/major/{major}/minor/{minor}/task/{task-name}/If $ARGUMENTS empty:
pending or in-progresscompleted# Find all task STATE.md files
find .claude/dog/major -name "STATE.md" -path "*/task/*/STATE.md" 2>/dev/null
For each task, check:
If no executable task found:
No executable tasks found.
Possible reasons:
- All tasks completed
- Remaining tasks have unmet dependencies
- No tasks defined yet
Use /dog:status to see current state.
Use /dog:add-task to add new tasks.
Exit command.
</step> <step name="load_task">Load task details:
Read the task's:
STATE.md - current status, progress, dependenciesPLAN.md - execution plan with stepsSTATE.md - for contextSTATE.md - for contextPresent task overview:
## Task: {task-name}
**Location:** Major {major}, Minor {minor}
**Status:** {status}
**Progress:** {progress}%
**Goal:**
{goal from PLAN.md}
**Approach:**
{approach from PLAN.md}
</step>
<step name="create_worktree">
Create task worktree and branch:
Branch naming: {major}.{minor}-{task-name}
# Ensure we're on main branch
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
# Create branch if it doesn't exist
TASK_BRANCH="{major}.{minor}-{task-name}"
git branch "$TASK_BRANCH" "$MAIN_BRANCH" 2>/dev/null || true
# Create worktree
WORKTREE_PATH="../.worktrees/$TASK_BRANCH"
git worktree add "$WORKTREE_PATH" "$TASK_BRANCH" 2>/dev/null || \
echo "Worktree already exists at $WORKTREE_PATH"
Update task STATE.md:
Set status to in-progress and record start time.
Execute the PLAN.md:
Determine execution strategy based on task complexity:
| Complexity | Strategy |
|---|---|
| Simple (1-2 files, <20 lines) | Execute directly in main context |
| Medium (3-5 files, moderate changes) | Spawn single subagent |
| Complex (many files, large changes) | Consider decomposition first |
For subagent execution:
Invoke /dog:spawn-subagent skill with:
Monitor subagent via /dog:monitor-subagents:
Collect results via /dog:collect-results:
For direct execution:
Error Handling:
If execution fails:
Check token usage:
If subagent reported compaction events:
Use AskUserQuestion:
Approval gate (Interactive mode only):
Skip if yoloMode: true in config.
Present work summary:
## Task Complete: {task-name}
**Files Changed:**
- path/to/file1.ext (+10, -5)
- path/to/file2.ext (+25, -0)
**Commits:**
- feature: add feature X
- test: add tests for feature X
- docs: update README
**Review branch:** {task-branch}
Use AskUserQuestion:
If "Review first": Provide commands to review:
git log {main}..{task-branch} --oneline
git diff {main}...{task-branch}
Wait for user to respond with approval.
If "Request changes": Receive feedback and loop back to execute step.
If "Abort": Clean up worktree and branch, mark task as pending.
</step> <step name="squash_commits">Squash commits by type:
Group commits by conventional commit type:
feature: - featuresbugfix: - bug fixestest: - testsrefactor: - refactoringdocs: - documentationconfig: - configuration and maintenanceCreate one squashed commit per type:
# Example: squash all feat commits
git rebase -i --autosquash {base}
Use /dog:git-squash skill for safe squashing.
Merge task branch to main:
git checkout {main}
git merge --no-ff {task-branch} -m "$(cat <<'EOF'
Merge {major}.{minor}-{task-name}
{Summary from PLAN.md goal}
EOF
)"
Handle merge conflicts:
Clean up worktree:
# Remove worktree
git worktree remove "$WORKTREE_PATH" --force
# Optionally delete branch if autoCleanupWorktrees is true
git branch -d "{task-branch}" 2>/dev/null || true
</step>
<step name="update_state">
Update STATE.md files:
Task STATE.md:
completed100Minor STATE.md:
Major STATE.md:
Task CHANGELOG.md:
Commit metadata updates:
git add .claude/dog/
git commit -m "$(cat <<'EOF'
docs: complete task {task-name}
Updates STATE.md and CHANGELOG.md for Major {major}, Minor {minor}.
EOF
)"
</step>
<step name="next_task">
Offer next task:
Find next executable task (pending + dependencies met).
If found:
---
## Task Complete
**{task-name}** merged to main.
## Next Up
**{next-task-name}** - {goal from PLAN.md}
`/dog:execute-task {major}.{minor}/{next-task-name}`
<sub>`/clear` first -> fresh context window</sub>
---
If no more tasks:
---
## Task Complete
**{task-name}** merged to main.
## All Tasks Complete
Minor version {major}.{minor} is complete!
Use `/dog:status` to see overall progress.
Use `/dog:add-task` to add more tasks.
Use `/dog:add-minor-version` to add a new minor version.
---
</step>
</process>
<deviation_rules>
During execution, handle discoveries automatically:
Only rule 4 requires user intervention.
</deviation_rules>
<commit_rules>
Per-Step Commits:
After each execution step:
NEVER use:
git add .git add -Agit add src/ or any broad directoryAlways stage files individually.
</commit_rules>
<success_criteria>
</success_criteria>