Use when orchestrating sequential phases in plan execution - executes tasks one-by-one in main worktree using git-spice natural stacking (NO manual upstack commands, NO worktree creation, tasks build on each other)
Executes sequential task phases in the main worktree using natural git-spice stacking. Triggered when `execute` encounters a "Sequential" phase in plan.md, it runs tasks one-by-one where each builds on the previous, automatically creating stacked branches without manual commands.
/plugin marketplace add arittr/spectacular/plugin install spectacular@spectacularThis skill inherits all available tools. When active, it can use any tool Claude has access to.
test-scenarios.mdSequential phases use natural git-spice stacking in the main worktree.
Each task creates a branch with gs branch create, which automatically stacks on the current HEAD. No manual stacking operations needed.
Critical distinction: Sequential tasks BUILD ON each other. They need integration, not isolation.
Use this skill when execute command encounters a phase marked "Sequential" in plan.md:
{runid}-main worktreegs upstack onto)Sequential phases never use worktrees. They share one workspace where tasks build cumulatively.
SEQUENTIAL PHASE = MAIN WORKTREE + NATURAL STACKING
What natural stacking means:
gs branch create → automatically stacks on currentNo manual commands needed. The workflow IS the stacking.
Announce: "I'm using executing-sequential-phase to execute {N} tasks sequentially in Phase {phase-id}."
MANDATORY: Verify orchestrator is in main repo root before any operations:
REPO_ROOT=$(git rev-parse --show-toplevel)
CURRENT=$(pwd)
if [ "$CURRENT" != "$REPO_ROOT" ]; then
echo "❌ Error: Orchestrator must run from main repo root"
echo "Current: $CURRENT"
echo "Expected: $REPO_ROOT"
echo ""
echo "Return to main repo: cd $REPO_ROOT"
exit 1
fi
echo "✅ Orchestrator location verified: Main repo root"
Why critical:
git -C .worktrees/path or bash -c "cd path && cmd"First, verify we're on the correct base branch for this phase:
# Get current branch in main worktree
CURRENT_BRANCH=$(git -C .worktrees/{runid}-main branch --show-current)
EXPECTED_BASE="{expected-base-branch}" # From plan: previous phase's last task, or {runid}-main for Phase 1
if [ "$CURRENT_BRANCH" != "$EXPECTED_BASE" ]; then
echo "⚠️ WARNING: Phase {phase-id} starting from unexpected branch"
echo " Current: $CURRENT_BRANCH"
echo " Expected: $EXPECTED_BASE"
echo ""
echo "This means the previous phase ended on the wrong branch."
echo "Possible causes:"
echo "- Code review or quality checks switched branches"
echo "- User manually checked out different branch"
echo "- Resume from interrupted execution"
echo ""
echo "To fix:"
echo "1. Verify previous phase completed: git log --oneline $EXPECTED_BASE"
echo "2. Switch to correct base: cd .worktrees/{runid}-main && git checkout $EXPECTED_BASE"
echo "3. Re-run /spectacular:execute"
exit 1
fi
echo "✅ Phase {phase-id} starting from correct base: $CURRENT_BRANCH"
Then check and install dependencies from main repo (orchestrator never cd's):
# Check if dependencies installed in main worktree
if [ ! -d .worktrees/{runid}-main/node_modules ]; then
echo "Installing dependencies in main worktree..."
bash <<'EOF'
cd .worktrees/{runid}-main
{install-command}
{postinstall-command}
EOF
fi
Why heredoc: Orchestrator stays in main repo. Heredoc creates subshell that exits after commands.
Why main worktree: Sequential tasks were created during spec generation. All sequential phases share this worktree.
Red flag: "Create phase-specific worktree" - NO. Sequential = shared worktree.
Before spawning subagents, extract phase boundaries from plan:
The orchestrator already parsed the plan in execute.md Step 1. Extract:
Format for subagent context:
PHASE CONTEXT:
- Phase {current-phase-id}/{total-phases}: {phase-name}
- This phase includes: Task {task-ids-in-this-phase}
LATER PHASES (DO NOT IMPLEMENT):
- Phase {next-phase}: {phase-name} - {task-summary}
- Phase {next+1}: {phase-name} - {task-summary}
...
If implementing work beyond this phase's tasks, STOP and report scope violation.
Why critical: Spec describes WHAT to build (entire feature). Plan describes HOW/WHEN (phase breakdown). Subagents need both to avoid scope creep.
For each task in order, spawn ONE subagent with embedded instructions:
Task(Implement Task {task-id}: {task-name})
ROLE: Implement Task {task-id} in main worktree (sequential phase)
WORKTREE: .worktrees/{run-id}-main
CURRENT BRANCH: {current-branch}
TASK: {task-name}
FILES: {files-list}
ACCEPTANCE CRITERIA: {criteria}
PHASE BOUNDARIES:
===== PHASE BOUNDARIES - CRITICAL =====
Phase {current-phase-id}/{total-phases}: {phase-name}
This phase includes ONLY: Task {task-ids-in-this-phase}
DO NOT CREATE ANY FILES from later phases.
Later phases (DO NOT CREATE):
- Phase {next-phase}: {phase-name} - {task-summary}
❌ NO implementation files
❌ NO stub functions (even with TODOs)
❌ NO type definitions or interfaces
❌ NO test scaffolding or temporary code
If tempted to create ANY file from later phases, STOP.
"Not fully implemented" = violation.
"Just types/stubs/tests" = violation.
"Temporary/for testing" = violation.
==========================================
CONTEXT REFERENCES:
- Spec: specs/{run-id}-{feature-slug}/spec.md
- Constitution: docs/constitutions/current/
- Plan: specs/{run-id}-{feature-slug}/plan.md
- Worktree: .worktrees/{run-id}-main
INSTRUCTIONS:
1. Navigate to main worktree:
cd .worktrees/{run-id}-main
2. Read constitution (if exists): docs/constitutions/current/
3. Read feature specification: specs/{run-id}-{feature-slug}/spec.md
This provides:
- WHAT to build (requirements, user flows)
- WHY decisions were made (architecture rationale)
- HOW features integrate (system boundaries)
The spec is your source of truth for architectural decisions.
Constitution tells you HOW to code. Spec tells you WHAT to build.
4. VERIFY PHASE SCOPE before implementing:
- Read the PHASE BOUNDARIES section above
- Confirm this task belongs to Phase {current-phase-id}
- If tempted to implement later phase work, STOP
- The plan exists for a reason - respect phase boundaries
5. Implement task following spec + constitution + phase boundaries
6. Run quality checks with exit code validation:
**CRITICAL**: Use heredoc to prevent bash parsing errors:
bash <<'EOF'
npm test
if [ $? -ne 0 ]; then
echo "❌ Tests failed"
exit 1
fi
npm run lint
if [ $? -ne 0 ]; then
echo "❌ Lint failed"
exit 1
fi
npm run build
if [ $? -ne 0 ]; then
echo "❌ Build failed"
exit 1
fi
EOF
**Why heredoc**: Prevents parsing errors when commands are wrapped by orchestrator.
7. Create stacked branch using verification skill:
Skill: phase-task-verification
Parameters:
- RUN_ID: {run-id}
- TASK_ID: {phase}-{task}
- TASK_NAME: {short-name}
- COMMIT_MESSAGE: "[Task {phase}.{task}] {task-name}"
- MODE: sequential
The verification skill will:
a) Stage changes with git add .
b) Create branch with gs branch create
c) Verify HEAD points to new branch
d) Stay on branch (next task builds on it)
8. Report completion
CRITICAL:
- Work in .worktrees/{run-id}-main, NOT main repo
- Stay on your branch when done (next task builds on it)
- Do NOT create worktrees
- Do NOT use `gs upstack onto`
- Do NOT implement work from later phases (check PHASE BOUNDARIES above)
Sequential dispatch: Wait for each task to complete before starting next.
Red flags:
After all tasks complete (verify from main repo):
# Display and verify stack using bash subshell (orchestrator stays in main repo)
bash <<'EOF'
cd .worktrees/{runid}-main
echo "📋 Stack after sequential phase:"
gs log short
echo ""
# Verify stack integrity (each task has unique commit)
echo "🔍 Verifying stack integrity..."
TASK_BRANCHES=( {array-of-branch-names} )
STACK_VALID=1
declare -A SEEN_COMMITS
for BRANCH in "${TASK_BRANCHES[@]}"; do
if ! git rev-parse --verify "$BRANCH" >/dev/null 2>&1; then
echo "❌ ERROR: Branch '$BRANCH' not found"
STACK_VALID=0
break
fi
BRANCH_SHA=$(git rev-parse "$BRANCH")
# Check if this commit SHA was already seen
if [ -n "${SEEN_COMMITS[$BRANCH_SHA]}" ]; then
echo "❌ ERROR: Stack integrity violation"
echo " Branch '$BRANCH' points to commit $BRANCH_SHA"
echo " But '${SEEN_COMMITS[$BRANCH_SHA]}' already points to that commit"
echo ""
echo "This means one task created no new commits."
echo "Possible causes:"
echo "- Task implementation had no changes"
echo "- Quality checks blocked commit"
echo "- gs branch create failed silently"
STACK_VALID=0
break
fi
SEEN_COMMITS[$BRANCH_SHA]="$BRANCH"
echo " ✓ $BRANCH @ $BRANCH_SHA"
done
if [ $STACK_VALID -eq 0 ]; then
echo ""
echo "❌ Stack verification FAILED"
echo ""
echo "To investigate:"
echo "1. Check task branch commits: git log --oneline \$BRANCH"
echo "2. Review subagent output for failed task"
echo "3. Check for quality check failures (test/lint/build)"
echo "4. Fix and re-run /spectacular:execute"
exit 1
fi
echo "✅ Stack integrity verified - all tasks have unique commits"
EOF
Each gs branch create automatically stacked on the previous task's branch.
Verification ensures: Each task created a unique commit (no empty branches or duplicates).
Red flag: "Run gs upstack onto to ensure stacking" - NO. Already stacked naturally.
Check review frequency setting (from execute.md Step 1.7):
REVIEW_FREQUENCY=${REVIEW_FREQUENCY:-per-phase}
If REVIEW_FREQUENCY is "end-only" or "skip":
Skipping per-phase code review (frequency: {REVIEW_FREQUENCY})
Phase {N} complete - proceeding to next phase
Mark phase complete and continue to next phase.
If REVIEW_FREQUENCY is "optimize":
Analyze the completed phase to decide if code review is needed:
High-risk indicators (REVIEW REQUIRED):
Low-risk indicators (SKIP REVIEW):
Analyze this phase:
Decision: If ANY high-risk indicator present → Proceed to code review below If ONLY low-risk indicators → Skip review:
✓ Phase {N} assessed as low-risk - skipping review (optimize mode)
Reasoning: {brief explanation of why low-risk}
Phase {N} complete - proceeding to next phase
If REVIEW_FREQUENCY is "per-phase" OR optimize mode decided to review:
Use requesting-code-review skill, then parse results STRICTLY.
AUTONOMOUS EXECUTION: Code review rejections trigger automatic fix loops, NOT user prompts. Never ask user what to do.
Dispatch code review:
Skill: requesting-code-review
Context provided to reviewer:
- WORKTREE: .worktrees/{runid}-main
- PHASE: {phase-number}
- TASKS: {task-list}
- BASE_BRANCH: {base-branch-name}
- SPEC: specs/{run-id}-{feature-slug}/spec.md
- PLAN: specs/{run-id}-{feature-slug}/plan.md (for phase boundary validation)
**CRITICAL - EXHAUSTIVE FIRST-PASS REVIEW:**
This is your ONLY opportunity to find issues. Re-review is for verifying fixes, NOT discovering new problems.
Check EVERYTHING in this single review:
□ Implementation correctness - logic bugs, edge cases, error handling, race conditions
□ Test correctness - expectations match actual behavior, coverage is complete, no false positives
□ Cross-file consistency - logic coherent across all files, no contradictions
□ Architectural soundness - follows patterns, proper separation of concerns, no coupling issues
□ Scope adherence - implements ONLY Phase {phase-number} work, no later-phase implementations
□ Constitution compliance - follows all project standards and conventions
Find ALL issues NOW. If you catch yourself thinking "I'll check that in re-review" - STOP. Check it NOW.
Binary verdict required: "Ready to merge? Yes" (only if EVERYTHING passes) or "Ready to merge? No" (list ALL issues found)
Parse "Ready to merge?" field:
Re-review loop (if REJECTED):
Critical: Only "Ready to merge? Yes" allows proceeding. Everything else stops execution.
Phase completion:
REVIEW_FREQUENCY="per-phase": Phase complete ONLY when code review returns "Ready to merge? Yes"REVIEW_FREQUENCY="end-only" or "skip": Phase complete after all tasks finish (code review skipped)| Excuse | Reality |
|---|---|
| "Need manual stacking commands" | gs branch create stacks automatically on current HEAD |
| "Files don't overlap, could parallelize" | Plan says sequential for semantic dependencies |
| "Create phase-specific worktree" | Sequential phases share main worktree |
| "Review rejected, ask user" | Autonomous execution means automatic fixes |
| "Scope creep but quality passes" | Plan violation = failure. Auto-fix to plan |
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.