skills/sprint-init/SKILL.md
Initializes a new ASTRA sprint. Creates an isolated sprint worktree (with port-isolated dev server settings), generates sprint prompt maps, progress trackers, and retrospective templates inside that worktree, and prints the cd path so all subsequent development and testing happens in the worktree. With --auto flag, also auto-executes the post-scaffolding pipeline: /test-scenario → implementation → /test-run → /pr-merge --auto (worktree auto-removed). Between each major stage (5.2/5.3/5.4/5.5 iteration/5.6), the skill performs a silent save (auto-state.yaml + commit) and applies a 'reference-avoidance' rule (don't re-read large prior artifacts; rely on yaml SSoT) so the system's built-in auto-compression keeps context manageable, then continues directly to the next stage without user intervention. --resume flag is reserved for true recovery (context crash, forced interrupt) — it reads auto-state.yaml and jumps to next_stage. Only halts on true blockers (gh auth, merge conflicts, Critical review issues).
npx skillsauth add astra-technology-company-limited/astra-methodology sprint-initInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Creates a sprint-level isolated worktree, writes port-isolated env settings, and generates prompt maps / progress trackers / retrospective templates inside that worktree.
v5.0+ policy: Every feature task and test for a sprint runs inside a single worktree (
.astra-worktrees/sprint-<N>-<name>/)./pr-mergereflects the work into dev and auto-removes the worktree. Trade-off: one PR per sprint — no per-feature review granularity, but clean per-sprint merge/rollback.
--resume flag)When to use: --resume is for true recovery. In normal operation, --auto mode never interrupts between stages — it only does a silent save (auto-state.yaml + commit) and then proceeds to the next stage automatically. Only in the following cases does the user explicitly invoke /sprint-init --resume to continue:
Since auto-state.yaml is the single source of truth (SSoT), in any of the above cases we read next_stage from the yaml and resume from exactly that point.
Parse the --resume flag from $ARGUMENTS first:
RESUME_MODE=0
for arg in $ARGUMENTS; do
if [ "$arg" = "--resume" ]; then
RESUME_MODE=1
break
fi
done
--resume mode behaviorIf RESUME_MODE=1:
docs/sprints/sprint-*/auto-state.yaml and filter entries with merge.merge_success != true. Adopt the largest sprint number N as the "most recent" (compare the N in directory names sprint-{N}-...). cd into that entry's sprint.worktree_path and continue the stages. If the worktree has already been removed (the case where only the yaml remains in dev after the merge), print an error and abort — --resume is only meaningful when an in-progress worktree is still alive.docs/sprints/sprint-{N}-{name}/auto-state.yaml (abort if missing).auto-state.yaml and restore all of the following variables:
SPRINT_N, SPRINT_NAME, WT_PATH, MAX_ITER, CURRENT_ITERprogress.next_stage, progress.last_iteration_summary, files_to_patch_nextprogress.next_stage. e.g., next_stage: 5.4 → run Step 5.4 immediately.🔄 sprint-init --resume resumed
Sprint: sprint-{N}-{name}
Worktree: {WT_PATH}
Previously completed: {completed_stages}
Resuming stage: Stage {next_stage} — {next_stage_description}
Iteration: {current_iter}/{max_iter}
If RESUME_MODE=0, proceed normally to Step 0.B.
This command creates a sprint worktree, so it must run in the main worktree only. Reject if already inside an isolated worktree:
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(ls -d ~/.claude/plugins/cache/*/astra-methodology/* 2>/dev/null | sort -V | tail -1)}"
if [ -z "$PLUGIN_ROOT" ] || [ ! -f "$PLUGIN_ROOT/scripts/worktree-helpers.sh" ]; then
echo "ERROR: CLAUDE_PLUGIN_ROOT not found. Verify the plugin cache path." >&2
exit 1
fi
source "$PLUGIN_ROOT/scripts/worktree-helpers.sh"
astra_ensure_main_worktree || exit 1
Parse from $ARGUMENTS:
docs/sprints/ matching the sprint-{N}-{name}/ pattern (e.g., sprint-1-auth/, sprint-2-workspace/) to determine the next number.--auto (optional flag): If present, set AUTO_MODE=1 and proceed to Step 5 (Auto Continue) after scaffolding. Without this flag, the skill stops at Step 4 (Output Sprint Planning Guide) as before.--max-iter=N (optional, only meaningful with --auto): max self-improving iteration count for the test loop (1 ≤ N ≤ 10). If --auto is set but --max-iter is missing, ask the user once via AskUserQuestion (default 3).--from-blueprint (optional flag, v5.8/5.9 legacy): Indicates this invocation was delegated from the old /blueprint Step 6.5 (blueprint-then-worktree flow). Set FROM_BLUEPRINT=1 when present. Read site: Step 4 below — when FROM_BLUEPRINT=1, suppress the full Sprint Planning Guide body so /blueprint Step 7 can render a single consolidated Next-Steps block. v5.10+ /blueprint uses --scaffold-only instead, but --from-blueprint is preserved for backward compatibility (treats it as equivalent to --scaffold-only).--scaffold-only (optional flag, v5.10+): Indicates this invocation is from the new worktree-first /blueprint flow where the blueprint has not been authored yet — /sprint-init only creates the worktree + writes port env file + scaffolds prompt-map / progress / retrospective, and then exits. Set SCAFFOLD_ONLY=1 when present. Read sites:
SCAFFOLD_ONLY=1, the prompt-map omits the Feature 1.1 (/blueprint ...) line entirely and renumbers the remaining steps (1.1=DB Design, 1.2=Test Cases, 1.3=Implementation). The blueprint is being authored by the calling context and will exist by the time the user runs Feature 1.1.--from-blueprint (parent renders consolidated output).--scaffold-only is incompatible with --auto. If both are present, abort with "❌ --scaffold-only and --auto cannot be combined (no blueprint exists yet to drive the auto pipeline)".Directory name format: sprint-{N}-{sprint-name}/ (e.g., sprint-1-auth/, sprint-2-payment/, sprint-3-dashboard/)
If the sprint name is not provided in $ARGUMENTS, ask the user for the primary feature/blueprint name. This name will be used as the directory suffix. Use kebab-case format (e.g., auth, workspace, payment-dashboard).
When scanning existing directories, extract the sprint number from directory names matching pattern sprint-{N}-{name} (e.g., sprint-1-auth → number 1).
The sprint worktree branches from a user-chosen base (default origin/dev). v5.11+ exposes this choice so a sprint can be branched from staging (matches an integration branch that's based on staging — cleanest sprint→integration→staging promotion) or from main/master (urgent hotfix path) when needed.
git fetch origin --quiet
AVAILABLE=()
for b in dev staging main master; do
git ls-remote --exit-code --heads origin "$b" >/dev/null 2>&1 && AVAILABLE+=("$b")
done
if [ ${#AVAILABLE[@]} -eq 0 ]; then
echo "ERROR: none of dev/staging/main/master found on origin" >&2
exit 1
fi
--auto mode — safe default: pick dev if present, else main/master/staging in that order. No prompt.
--scaffold-only / --from-blueprint mode (called by /blueprint) — /blueprint Step 1.5 has already validated the user is on a standard branch (dev/main/master) in the main worktree and has not changed cwd, so reading the current branch directly is correct:
SOURCE_BRANCH=$(git branch --show-current)
case "$SOURCE_BRANCH" in
dev|main|master|staging) : ;; # acceptable — /blueprint's guard passed
"")
# detached HEAD — shouldn't happen since /blueprint Step 1.5 guards against it,
# but defensive fallback: pick dev if present, else main, else master
for fallback in dev main master; do
git ls-remote --exit-code --heads origin "$fallback" >/dev/null 2>&1 && { SOURCE_BRANCH="$fallback"; break; }
done
;;
*)
# /blueprint should have aborted, but be defensive
echo "ERROR: --scaffold-only invoked from non-standard branch '$SOURCE_BRANCH'; expected dev/main/master/staging" >&2
exit 1
;;
esac
No prompt is issued — /blueprint already curated the entry conditions.
Normal mode — AskUserQuestion within the 4-option cap (Other is auto-appended by the harness outside the cap and lets the user type any custom ref like release/2026Q2). List only branches present in AVAILABLE:
dev (Recommended — standard sprint base)staging (when present — for sprints that target the fast staging-direct promotion path)main (when present — for urgent hotfix sprints branching from production state)master (only when main doesn't exist — otherwise drop this slot to keep within 4)Save the chosen branch as SOURCE_BRANCH. Validate:
git ls-remote --exit-code --heads origin "$SOURCE_BRANCH" >/dev/null 2>&1 || {
echo "ERROR: source branch '$SOURCE_BRANCH' not found on origin" >&2
exit 1
}
Aligning the main worktree to SOURCE_BRANCH first keeps the base always up to date.
git branch --show-currentgit status --porcelain shows changes, stash with git stash --include-untracked -m "astra-sprint-init"git fetch origin "$SOURCE_BRANCH" && git checkout "$SOURCE_BRANCH" && git pull origin "$SOURCE_BRANCH"git stash pop. On conflict, report to the user and abort.Main worktree post-state: the main worktree stays on
$SOURCE_BRANCHafter this step (e.g., if the user pickedstagingfor an urgent hotfix sprint, the main worktree is now onstaging). The sprint worktree itself is independent — feature work happens inside the worktree on the sprint branch — but other concurrent sessions or skills that assume the main worktree is ondevshouldgit checkout devthemselves./pr-mergeStep 9 explicitly returns the main worktree todevafter merge, which restores the typical post-merge state.
Create a new isolated worktree on the feat/sprint-{N}-{sprint-name} branch. All feature code and test deliverables are written inside it.
SPRINT_N="{confirmed sprint number}"
SPRINT_NAME="{confirmed sprint name}"
# Pass the user-chosen SOURCE_BRANCH from Step 1.5.2 as the base-ref (3rd arg).
# astra_create_sprint_worktree prepends "origin/" automatically when missing.
if ! out=$(astra_create_sprint_worktree "$SPRINT_N" "$SPRINT_NAME" "origin/${SOURCE_BRANCH}"); then
echo "ERROR: sprint worktree creation failed" >&2
exit 1
fi
IFS=$'\t' read -r SPRINT_BRANCH WT_PATH <<< "$out"
if [ -z "$WT_PATH" ] || [ ! -d "$WT_PATH" ]; then
echo "ERROR: could not determine sprint worktree path. helper output: '$out'" >&2
exit 1
fi
echo "Sprint worktree created from origin/${SOURCE_BRANCH}: $WT_PATH (branch: $SPRINT_BRANCH)"
astra_create_sprint_worktree absorbs branch/slug/port conflicts, so use the returned $SPRINT_BRANCH·$WT_PATH as-is (it may differ from the desired name).
Create .astra-worktree.env inside the worktree. /test-run sources this file before starting the server to apply the sprint-specific ports.
# Default port base: 3000 (Node-stack default). Other stacks are derived automatically by the conversion formula inside the env file.
PORT_BASE_DEFAULT=3000
if ! PORT_BASE=$(astra_compute_port_base "$PORT_BASE_DEFAULT" "$SPRINT_N"); then
echo "ERROR: could not find an available port base" >&2
exit 1
fi
astra_write_worktree_env "$WT_PATH" "$SPRINT_N" "$SPRINT_NAME" "$PORT_BASE" || exit 1
echo "Sprint port base: $PORT_BASE (offset=$((PORT_BASE - PORT_BASE_DEFAULT)))"
The generated file contains per-framework values such as ASTRA_PORT_BASE, PORT, VITE_PORT, SERVER_PORT, DJANGO_PORT, FASTAPI_PORT. /test-run picks the value matching the detected stack to start the server.
From here on, deliverable writing and progress tracking happen inside the worktree:
cd "$WT_PATH"
From this point on, the "current working directory" is
$WT_PATH, and every docs/sprints/* file is committed onto the sprint branch.
Create the file $WT_PATH/docs/sprints/sprint-{N}-{sprint-name}/prompt-map.md.
Scan docs/blueprints/ for numbered directories matching the sprint name (or use the blueprint names provided by the user). Each blueprint becomes a feature in the prompt map. Do NOT analyze or carry over items from previous sprints.
Variant by
SCAFFOLD_ONLY/FROM_BLUEPRINTflag (treated as equivalent —FROM_BLUEPRINT=1is the legacy alias forSCAFFOLD_ONLY=1):
- Neither flag set (direct user invocation without
--scaffold-onlyor--from-blueprint): Variant A — full 4-step prompt map below (1.1 = blueprint authoring, 1.2 = DB design, 1.3 = test cases, 1.4 = implementation).SCAFFOLD_ONLY=1ORFROM_BLUEPRINT=1(called by/blueprint): Variant B — the blueprint is authored by the calling context immediately after this skill returns, so the prompt map's Feature 1.1 (blueprint authoring) is removed entirely and the remaining steps are renumbered: 1.1 = DB Design, 1.2 = Test Cases, 1.3 = Implementation. The header above Feature 1 includes a note "(blueprint is authored by /blueprint — when this prompt-map is opened, the blueprint already exists)".
# Sprint {N} Prompt Map
## Sprint Goal
[Describe the business value to achieve in this sprint]
> **Worktree note**: Every task in this sprint runs inside `.astra-worktrees/sprint-{N}-{sprint-name}/`.
> New Claude Code sessions must be started from that path.
## Feature 1: {feature-name}
### 1.1 Blueprint Prompt
/blueprint {feature-name} --from-planner=docs/planner/{NNN}-{feature-name}
> The `/blueprint` skill takes `/service-planner` deliverables (auto-loaded when present) as input and writes a 10-standard-section blueprint to `docs/blueprints/{NNN}-{feature-name}/blueprint.md`.
> - **Included**: data flow, schema DDL, ER diagram, API JSON Schema, sequence diagrams, pseudocode logic, HITL Triggers
> - **Excluded**: executable implementation code, ORM annotations, framework-dependent expressions
> - Only asks 1-3 items that genuinely require human judgment (PK strategy, transaction boundary, external-dependency sync mode) automatically.
>
> **Numbering Rule**: Scan existing directories in `docs/blueprints/` to determine the next number. Use 3-digit zero-padded format (e.g., `001-`, `002-`).
### 1.2 DB Design Reflection Prompt
/feature-dev "Refer to docs/blueprints/{NNN}-{feature-name}/blueprint.md Section 3 (Data Model) and reflect those tables/columns/indexes/FK relationships into docs/database/database-design.md, including the ERD and FK relationship summary.
The blueprint is the single source of truth — do not change schema decisions, do not add columns not in the blueprint, do not rename. If you find a real inconsistency, stop and report instead of guessing.
HITL Guard: Before asking the user any question, first check Section 10 (HITL Triggers) of the blueprint. Only ask the user when the decision matches T1-T4 triggers (business decisions without a clear answer in the blueprint, security/permission choices, external dependency choices, destructive changes). For everything else, follow the blueprint and proceed automatically.
Do not modify any application code yet."
### 1.3 Test Case Prompt
/feature-dev "Based on docs/blueprints/{NNN}-{feature-name}/blueprint.md Section 9 (Test Strategy) and Section 9.1 (Required Test Cases), write test cases to docs/tests/test-cases/sprint-{N}/{feature-name}-test-cases.md.
Use Given-When-Then format. Cover: (a) Section 5.1 happy path, (b) Section 5.2 exception paths, (c) Section 2.3 business rules, (d) Section 7 error policy items. Include unit, integration, and edge cases.
HITL Guard: Section 10 (HITL Triggers) of the blueprint defines when to ask the user. Outside those triggers, derive test cases directly from the blueprint without asking. If a test case requires a decision not in the blueprint and not in Section 10, default to the most conservative coverage and note it as TODO instead of pausing.
Do not modify any application code yet."
### 1.4 Implementation Prompt
/feature-dev "Strictly follow docs/blueprints/{NNN}-{feature-name}/blueprint.md and docs/database/database-design.md to implement the feature. Write code that matches: Section 3 (DDL → ORM entities), Section 4 (API contract → controllers/DTOs), Section 5 (sequence diagrams → service orchestration), Section 6 (pseudocode → real implementation), Section 7 (error policy → exception handlers), Section 8 (non-functional → middleware/security config).
Write tests referencing docs/tests/test-cases/sprint-{N}/{feature-name}-test-cases.md. Once implementation is complete, run all tests and report results to docs/tests/test-reports/.
HITL Guard (important): The blueprint's Section 10 (HITL Triggers) tells you exactly when to ask the user during implementation. The four triggers are T1 (business decisions without a clear blueprint answer), T2 (security/permission policy choices), T3 (external dependency/3rd-party introduction), T4 (destructive changes like DROP/RENAME or public API signature change). Outside those triggers, do not ask — apply the blueprint as written and follow coding conventions.
Specifically do NOT ask the user about: variable/function names, code formatting, log levels, file layout, import order, DTO/Entity split, fine-grained HTTP status codes — those follow project conventions automatically. Waking the user too often defeats the automation."
## Feature 2: {feature-name}
{Repeat with the same structure as above}
SCAFFOLD_ONLY=1 OR FROM_BLUEPRINT=1 (v5.10+ worktree-first, or legacy v5.8/5.9 delegation)The blueprint authoring step is omitted because /blueprint already wrote (or is about to write) the blueprint immediately after this skill returns. The user will start from "1.1 DB Design Reflection".
# Sprint {N} Prompt Map
## Sprint Goal
[Describe the business value to achieve in this sprint]
> **Worktree note**: Every task in this sprint runs inside `.astra-worktrees/sprint-{N}-{sprint-name}/`.
> New Claude Code sessions must be started from that path.
>
> **Blueprint authoring note (v5.10+)**: The blueprint(s) for this sprint are authored by the `/blueprint` skill that created this worktree. When this prompt-map is opened by the user, the blueprint already exists under `docs/blueprints/{NNN}-{feature-name}/blueprint.md` on the sprint branch. Start from 1.1 below.
## Feature 1: {feature-name}
### 1.1 DB Design Reflection Prompt
/feature-dev "Refer to docs/blueprints/{NNN}-{feature-name}/blueprint.md Section 3 (Data Model) and reflect those tables/columns/indexes/FK relationships into docs/database/database-design.md, including the ERD and FK relationship summary.
The blueprint is the single source of truth — do not change schema decisions, do not add columns not in the blueprint, do not rename. If you find a real inconsistency, stop and report instead of guessing.
HITL Guard: Before asking the user any question, first check Section 10 (HITL Triggers) of the blueprint. Only ask the user when the decision matches T1-T4 triggers (business decisions without a clear answer in the blueprint, security/permission choices, external dependency choices, destructive changes). For everything else, follow the blueprint and proceed automatically.
Do not modify any application code yet."
### 1.2 Test Case Prompt
/feature-dev "Based on docs/blueprints/{NNN}-{feature-name}/blueprint.md Section 9 (Test Strategy) and Section 9.1 (Required Test Cases), write test cases to docs/tests/test-cases/sprint-{N}/{feature-name}-test-cases.md.
Use Given-When-Then format. Cover: (a) Section 5.1 happy path, (b) Section 5.2 exception paths, (c) Section 2.3 business rules, (d) Section 7 error policy items. Include unit, integration, and edge cases.
HITL Guard: Section 10 (HITL Triggers) of the blueprint defines when to ask the user. Outside those triggers, derive test cases directly from the blueprint without asking. If a test case requires a decision not in the blueprint and not in Section 10, default to the most conservative coverage and note it as TODO instead of pausing.
Do not modify any application code yet."
### 1.3 Implementation Prompt
/feature-dev "Strictly follow docs/blueprints/{NNN}-{feature-name}/blueprint.md and docs/database/database-design.md to implement the feature. Write code that matches: Section 3 (DDL → ORM entities), Section 4 (API contract → controllers/DTOs), Section 5 (sequence diagrams → service orchestration), Section 6 (pseudocode → real implementation), Section 7 (error policy → exception handlers), Section 8 (non-functional → middleware/security config).
Write tests referencing docs/tests/test-cases/sprint-{N}/{feature-name}-test-cases.md. Once implementation is complete, run all tests and report results to docs/tests/test-reports/.
HITL Guard (important): The blueprint's Section 10 (HITL Triggers) tells you exactly when to ask the user during implementation. The four triggers are T1 (business decisions without a clear blueprint answer), T2 (security/permission policy choices), T3 (external dependency/3rd-party introduction), T4 (destructive changes like DROP/RENAME or public API signature change). Outside those triggers, do not ask — apply the blueprint as written and follow coding conventions.
Specifically do NOT ask the user about: variable/function names, code formatting, log levels, file layout, import order, DTO/Entity split, fine-grained HTTP status codes — those follow project conventions automatically. Waking the user too often defeats the automation."
## Feature 2: {feature-name}
{Repeat with 1.1/1.2/1.3 structure — additional blueprints are added via secondary /blueprint invocations inside this worktree.}
---
## At Sprint End (after all features are implemented)
### Z.1 Integration Test
/test-run
> Boots the server using the sprint-specific ports in `.astra-worktree.env` and runs tests.
> When the tests finish, the server processes on those ports are also cleaned up automatically.
### Z.2 Merge to dev (two-phase, v5.9+)
/pr-merge
> Sprint Phase: runs commit → push → PR → code review → fix loop inside this worktree, then stops.
>
> Once Sprint Phase completes, follow the printed `cd` command to move to the main worktree and re-invoke `/pr-merge` — it will auto-detect the pending sprint PR (base=dev) and finalize the merge, then remove this sprint worktree.
>
> Tip: `/pr-merge --auto` chains both phases end-to-end in one invocation (sprint-init's auto pipeline and /autorun do this automatically).
Read the prompt map created in Step 2 (docs/sprints/sprint-{N}-{sprint-name}/prompt-map.md) and extract feature names from ## Feature {#}: {name} headers (where {#} is the feature ordinal, e.g., 1, 2, 3).
Create the docs/sprints/sprint-{N}-{sprint-name}/progress.md file:
# Sprint {N} Progress Tracker
## Sprint Information
- **Sprint Number**: {N}
- **Sprint Name**: {sprint-name}
- **Sprint Branch**: feat/sprint-{N}-{sprint-name}
- **Worktree**: .astra-worktrees/sprint-{N}-{sprint-name}/
- **Port Base**: {PORT_BASE}
- **Sprint Goal**: [copy from prompt map Sprint Goal section]
- **Start Date**: {YYYY-MM-DD}
- **End Date**: {YYYY-MM-DD} (+7 days)
- **Status**: In Progress
<!-- PROGRESS_TABLE_START -->
## Feature Progress
| Feature | Blueprint | DB Design | Test Cases | Implementation | Test Report | Status |
|---------|-----------|-----------|------------|----------------|-------------|--------|
| {feature-1} | - | - | - | - | - | Not Started |
| {feature-2} | - | - | - | - | - | Not Started |
**Legend**: `-` Not Started, `WIP` In Progress, `Done` Completed, `N/A` Not Applicable
<!-- PROGRESS_TABLE_END -->
<!-- SUMMARY_START -->
## Summary
- **Total Features**: {N}
- **Completed**: 0
- **In Progress**: 0
- **Overall Progress**: 0%
- **Last Updated**: {YYYY-MM-DD HH:MM}
<!-- SUMMARY_END -->
<!-- ACTIVITY_LOG_START -->
## Activity Log
| Timestamp | Event | File | Details |
|-----------|-------|------|---------|
<!-- ACTIVITY_LOG_END -->
- (Not Started) in every column.Create the docs/sprints/sprint-{N}-{sprint-name}/retrospective.md file:
# Sprint {N} Retrospective
## Date: {YYYY-MM-DD}
## AI Analysis Data
- code-review recurring issues: [auto-collected]
- security-guidance blocked count: [auto-collected]
- astra-methodology violation frequency: [auto-collected]
## Team Discussion (areas AI cannot catch)
### What went well (Keep)
-
### What to improve (Problem)
-
### What to try (Try)
-
## Automated Improvement Actions
- /hookify [codify recurring mistakes found in this sprint]
- CLAUDE.md update content: [describe added rules]
Commit the 3 generated sprint documents (prompt-map.md, progress.md, retrospective.md) to the sprint branch. This keeps them separate from later feature commits and makes tracking easy at merge time.
git add "docs/sprints/sprint-${SPRINT_N}-${SPRINT_NAME}/"
git commit -m "chore: scaffold sprint ${SPRINT_N} (${SPRINT_NAME})"
Do not push to remote — the push is bundled with the first feature commit or with /pr-merge.
Delegated-from-/blueprint mode (
FROM_BLUEPRINT=1orSCAFFOLD_ONLY=1): When invoked by/blueprint(legacy Step 6.5 =--from-blueprint, or v5.10+ Step 1.6 =--scaffold-only), the parent/blueprintskill prints its own consolidated output (Step 7 Case A) right after this skill returns. To avoid duplicate output, prefix this section with(invoked from /blueprint — see consolidated output below)and keep the body minimal: just the worktree path, branch, and port base./blueprintStep 7 owns the user-facing "Next steps" section.
## Sprint {N} Initialization Complete
### Worktree
- Path: {WT_PATH}
- Branch: {SPRINT_BRANCH}
- Port base: {PORT_BASE}
- env file: {WT_PATH}/.astra-worktree.env
### Generated Files (in worktree)
- docs/sprints/sprint-{N}-{sprint-name}/prompt-map.md (prompt map)
- docs/sprints/sprint-{N}-{sprint-name}/progress.md (progress tracker)
- docs/sprints/sprint-{N}-{sprint-name}/retrospective.md (retrospective template)
### Next Steps
1. cd {WT_PATH}
2. Run Feature 1.1 ~ 1.4 of the prompt-map above in order (design → DB → tests → implementation)
3. After every feature is done: /test-run → /pr-merge
> **Multi-session note**: New Claude Code sessions must be started from {WT_PATH}.
> The main worktree (dev) may have other sprint work in progress.
### Sprint Planning Procedure (1 hour, run inside worktree)
1. (10 min) Review AI analysis report
2. (20 min) Confirm business priorities with DE and agree on sprint goal
3. (20 min) Discuss prompt design direction per item + DSA shares design direction
4. (10 min) Finalize sprint backlog
Branch: Without the
--autoflag, stop here. With--auto, continue to Step 5.
--scaffold-only early exitIf SCAFFOLD_ONLY=1, the calling context (typically /blueprint) is responsible for the remaining flow (blueprint authoring + commit + final output). Do not enter Step 5 even if --auto was somehow also passed — instead:
SCAFFOLD_ONLY=1 and AUTO_MODE=1, abort with "❌ --scaffold-only and --auto cannot be combined (no blueprint exists yet to drive the auto pipeline)".--from-blueprint mode wording also covers --scaffold-only). Nothing more to print.if [ "$SCAFFOLD_ONLY" = "1" ] || [ "$FROM_BLUEPRINT" = "1" ]; then
if [ "$SCAFFOLD_ONLY" = "1" ] && [ "$AUTO_MODE" = "1" ]; then
echo "❌ --scaffold-only and --auto cannot be combined (no blueprint exists yet to drive the auto pipeline)" >&2
exit 1
fi
# Legacy --from-blueprint case: the calling /blueprint already authored the blueprint *before*
# invoking us, so under --auto we could theoretically continue into Step 5. In practice the
# legacy flow never combined --from-blueprint with --auto either (the legacy Step 6.5 invocation
# was a synchronous scaffolding call). Treat both flags identically here for simplicity.
exit 0
fi
Why this guard lives between Steps 4 and 5 rather than at Step 0/1: Steps 1.5–3.5 (sync dev, create worktree, write env file, scaffold docs, commit) are the exact responsibilities a
--scaffold-onlyinvocation wants. Only the auto pipeline (Step 5+) is out of scope. Aborting earlier would lose the very work the caller asked for.
Why
FROM_BLUEPRINTalso exits here: In Step 1 we documented--from-blueprintas an alias for--scaffold-only. To stay consistent (and prevent a legacy--from-blueprintinvocation from accidentally entering the Step 5 auto pipeline if someone added--auto), both flags trip the same exit. The legacy flow never combined them either, so this is purely a safety belt.
--auto flag is set)After scaffolding finishes, run the following pipeline sequentially in unattended mode:
/test-scenario all → implementation (blueprint-based) → /test-run → (self-improvement loop on failure) → /pr-merge --auto → worktree auto-removed
Default principles (same as autorun):
AskUserQuestion (the only exception is the one-time prompt in Step 1 when --max-iter is not provided).$(pwd) must equal $WT_PATH. Abort if not.docs/blueprints/[0-9][0-9][0-9]-{feature-name}/blueprint.md must exist inside the worktree (or in the merged base branch).
❌ --auto mode requires blueprints to be authored in advance.
Missing blueprint: {feature-name}
Fix: author the blueprint with /service-planner {feature-name} or /feature-dev, then re-run.
--max-iter=N argument. If absent, ask once via AskUserQuestion (options 1/3/5, default 3).Create todos via TodoWrite:
Iteration tracking variables:
MAX_ITER = the N determined aboveCURRENT_ITER = 1ITER_DIR = docs/sprints/sprint-{N}-{sprint-name}/iterations/mkdir -p "$ITER_DIR"--auto mode accumulates a large amount of context per stage (file contents, test logs, code review output). At the end of each major stage, persist the state to yaml, then apply the "reference-avoidance rule" and immediately proceed to the next stage. No user intervention.
The manual /compact slash command is intentionally not used — Claude Code's system auto-compression triggers on its own as the context approaches the limit, and in the meantime the LLM avoids re-referencing large objects to minimize new token accumulation.
This protocol is invoked at the end of Step 5.2, end of 5.3, end of 5.4, end of 5.5 iteration, and end of 5.6.
At the end of each stage, update $WT_PATH/docs/sprints/sprint-{N}-{sprint-name}/auto-state.yaml:
# auto-state.yaml — SSoT for sprint-init --auto resume
sprint:
number: {N}
name: {sprint-name}
worktree_path: {WT_PATH}
branch: feat/sprint-{N}-{sprint-name}
port_base: {PORT_BASE}
iteration:
max_iter: {MAX_ITER}
current_iter: {CURRENT_ITER}
progress:
completed_stages: [5.0, 5.1, 5.2, ...] # list of stage numbers completed so far
next_stage: 5.3 # stage to jump to on resume
next_stage_description: "Implementation (iteration 1 only)"
features:
- name: {feature-name-1}
blueprint: docs/blueprints/{NNN}-{feature-name-1}/blueprint.md
status: pending | done | in-progress
scenarios:
generated_dir: docs/tests/test-cases/sprint-{N}-{sprint-name}/
files: [auth-test-cases.md, payment-test-cases.md, ...] # filled after 5.2
implementation:
entities_created: [User.java, Payment.java, ...]
services_created: [...]
controllers_created: [...]
last_test_result:
passed: {N}
total: {M}
failed_tests: []
log_excerpt: "..." # last failure log essence, within 100 lines
last_iteration_classification: null | CODE_BUG | SPEC_GAP | DESIGN_MISALIGN | ENV_ISSUE
files_to_patch_next: [] # used on iteration 2+ entry (src/ files indicated by the summary)
merge:
pr_url: null
merge_success: null
worktree_removed: null
Commit the state file to the sprint branch. Skipping this step causes the file to disappear in the following cases:
/pr-merge --auto's git add -u only stages tracked files → untracked auto-state.yaml is not included in the merge → it is removed together with the worktree.--resume looks for the yaml from the main worktree, the yaml must exist in the merged dev.git add "docs/sprints/sprint-${SPRINT_N}-${SPRINT_NAME}/auto-state.yaml"
git commit -m "chore: auto-state checkpoint after Stage ${X}"
Since this commit occurs during
--autoprogress, the message is generated automatically. Push is handled in bulk by/pr-merge --autoor the next checkpoint, so it can be omitted here (however, if the user wants to--resumefrom another machine mid-way, push is needed).
Right after writing/committing the checkpoint, lightly print the following one line and immediately invoke the next stage. Do not exit:
✅ Stage {X} complete → auto-advancing to Stage {Y} (state: docs/sprints/sprint-{N}-{sprint-name}/auto-state.yaml)
And just before entering the next stage, the LLM must apply the following context-efficiency rule to itself:
⚡ Context-efficiency rule (at every auto-advance stage boundary)
- Do not re-reference the large objects loaded in the previous stage (entire test logs, browser snapshots, full contents of previously implemented files).
- Single source of truth (SSoT):
auto-state.yaml(+ on iteration resume, thelast_iteration_summaryfile).- For files needed in the next stage, Read/Edit them selectively — do not re-read the full directory tree or the full blueprint.
- This makes Claude Code's system auto-compression (triggered when nearing the context limit) work effectively and prevents mid-skill token explosion.
--resume mode (true-recovery only)--resume is not invoked on the normal path. Use only on the following abnormal paths (see Step 0.A):
Key points:
auto-state.yaml is the SSoT — even if variables vaporized due to context compression, this file restores everythingprogress.next_stagelast_iteration_summary file and the files_to_patch_next listAt every checkpoint, fully overwrite auto-state.yaml. Partial updates are forbidden — they can break inter-stage consistency. Always write the latest state snapshot as a whole.
Each checkpoint creates a new git commit (chore: auto-state checkpoint after Stage X). When the PR is merged, those commits are either squashed or merged as-is (depending on the user's git workflow).
Note: This protocol is
--automode only. Running sprint-init without--autois unaffected.
Invoke Skill('test-scenario', 'all'). Scenarios are generated under docs/tests/test-cases/sprint-{N}-{sprint-name}/ for every feature.
Success criterion: ≥ 1 scenario file exists.
Immediately after Step 5.2 ends, run the Step 5.1.5 Silent Save Protocol:
completed_stages: [5.0, 5.1, 5.2], next_stage: 5.3, scenarios.files: [...] in auto-state.yaml + commitFor each feature extracted from prompt-map.md, run sequentially:
Skill('generate-entity', '{table-name}') (or author the entity directly from the blueprint)coding-convention, data-standard, code-standard) fire on every Write/Edit.Success criterion: every table definition and API endpoint in the blueprint is reflected in code under src/ (or the project's standard location).
Step 5.3 is the stage that accumulates the most context (multiple entity/service/controller generations). Always run the 5.1.5 Silent Save Protocol:
completed_stages: [..., 5.3], next_stage: 5.4, implementation.{entities/services/controllers}_created: [...] in auto-state.yaml + commitInvoke Skill('test-run', ''). Boots the server using the sprint-specific ports in .astra-worktree.env, runs tests, and cleans up the ports automatically on exit.
/test-run accumulates large artifacts in the context (browser snapshots, console logs, network request logs). Always run the 5.1.5 Silent Save Protocol:
completed_stages: [..., 5.4], last_test_result: { passed, total, failed_tests, log_excerpt } in auto-state.yaml + commit
next_stage: 5.6CURRENT_ITER < MAX_ITER → next_stage: 5.5CURRENT_ITER == MAX_ITER → next_stage: 5.7 (jump directly to the report)log_excerpt to the essence of the last failure log within 100 lines (do not embed the full log in the yaml)log_excerpt from the yaml into the next stage)next_stage immediately — no exit / no user inputAll tests pass → proceed immediately to Step 5.6 (early exit).
Failed + CURRENT_ITER < MAX_ITER:
Failure classification (same pattern matching as autorun Stage 7.5.4 + tester-persona delegation as fallback):
| Signal | Classification | Re-entry |
|--------|----------------|----------|
| TypeError, NullPointer, panic, src/ in stack trace | CODE_BUG | Direct Patch (Edit src/ files, no sub-skill re-invocation) |
| 404 Not Found, schema mismatch, behavior not in blueprint | SPEC_GAP | abort (blueprint fix required) |
| UI failure such as screenshot diff, aria-label, contrast | DESIGN_MISALIGN | abort (UX fix required) |
| ECONNREFUSED, port in use, db connection | ENV_ISSUE | abort (user intervention) |
Direct Patch (no sub-skill re-invocation — same principle as autorun Stage 7.5.5):
CODE_BUG case: directly Edit the src/ files indicated by the summary. Re-invoking sub-skills such as new entity generation is forbidden.Clear abort message:
❌ {classification} category — sprint-init --auto does not self-improve this category.
{when SPEC_GAP}:
A blueprint fix is required. sprint-init does not redraw blueprints.
Two resolutions:
(1) Manually edit docs/blueprints/{NNN}-{feature}/blueprint.md, then /pr-merge --auto
(2) /autorun "{feature description}" --max-iter=N — the full pipeline that auto-patches blueprints too
{when DESIGN_MISALIGN}:
HTML planning screens (styles.css, SCR-*.html) need to be fixed.
Resolution: re-run /service-planner then /pr-merge --auto, or use the /autorun full pipeline.
{when ENV_ISSUE}:
Environment/infrastructure problem — needs user diagnosis.
Log: {log location}
Write iteration summary: $ITER_DIR/iter-{CURRENT_ITER}-summary.md (within 200 lines, same format as autorun).
CURRENT_ITER += 1.
Inter-iteration context cleanup is mandatory. Debug logs, previous patch attempts, and classification analyses accumulate, posing a high risk that the next iteration hits the token limit early. Always run the 5.1.5 Silent Save Protocol:
auto-state.yaml: current_iter: {CURRENT_ITER}, last_iteration_classification: {classification}, files_to_patch_next: [{list of src/ file paths flagged by the summary}], next_stage: 5.5 (or 5.4 — retry flow) + commit$ITER_DIR/iter-{CURRENT_ITER-1}-summary.md) in auto-state.yaml's progress.last_iteration_summary field (so the next iteration reads only this summary file on resume)files_to_patch_next into the next iteration.files_to_patch_next files, then re-invoke 5.4 (test-run) — no exit / no user inputContext-efficiency rule (on iteration re-entry): Read only
auto-state.yamlandlast_iteration_summary, then Edit the patch target files. Do not Read the full blueprint, planning docs, or src files from a previous iteration again.
Failed + CURRENT_ITER == MAX_ITER:
❌ Max iterations ({MAX_ITER}) exhausted with unresolved failures — stopping without /pr-merge/pr-merge.Persist the state one more time just before the merge. /pr-merge --auto itself consumes additional context for PR creation, code review, issue fixes, and re-review — the lighter the entering context, the more stable.
This save is stricter than others: once pr-merge starts and merges, the worktree disappears, so auto-state.yaml must be included in a sprint branch commit so it is accessible from the main worktree after dev merge.
Run the 5.1.5 Silent Save Protocol with the following extra checks:
completed_stages: [..., 5.5_passed], next_stage: 5.6.B, final last_test_result in auto-state.yamlgit add docs/sprints/sprint-${N}-${SPRINT_NAME}/auto-state.yaml
git commit -m "chore: pre-merge checkpoint (Stage 5.6.A)"
✅ Pre-merge save complete → invoking /pr-merge --auto (worktree will be removed)
/pr-merge --autoInvoke Skill('pr-merge', '--auto').
/pr-merge --auto handles the two-phase workflow (v5.9+) end-to-end:
Sprint Phase (inside the sprint worktree):
Sprint→Main handoff (Step 8.5 under --auto):
/pr-merge itself cd's to the main worktree (the skill performs the transition under --auto).Main Phase (in the main worktree):
Since sprint-init is running inside the sprint worktree, after the merge completes, /pr-merge removes the very worktree it is in. The user is automatically returned to the main worktree (dev) upon merge completion. Without
--auto, Sprint Phase would stop after the review loop and the user wouldcdto the main worktree to re-invoke/pr-merge— but--auto(the default for sprint-init's pipeline) chains both phases automatically.
auto-state.yamlRight after the worktree is removed, in the main worktree do the following:
cd $(astra_main_worktree_root) (it should already be the main worktree once the sprint worktree is removed, but specify it explicitly for safety)pr_url, merge_success: true, worktree_removed: true) into docs/sprints/sprint-{N}-{sprint-name}/auto-state.yaml (main worktree path)Path note: With the worktree removed,
auto-state.yamlnow lives in the main worktree'sdocs/sprints/sprint-{N}-{sprint-name}/(the file landed in dev via the sprint branch merge). If the path is missing in the main worktree (the sprint branch should have carried the file into dev), sync withgit pull origin devand verify again.
The Step 5.7 report is generally lightweight on context, so no separate silent save is needed. Since 5.6.C already recorded the merge result (pr_url, merge_success) in the yaml, Step 5.7 only needs to re-read that yaml — proceed directly to Step 5.7 with no exit / no user confirmation.
Data source: Re-read auto-state.yaml to fill the report values. To guard against the case where in-flight variables vaporized due to system auto-compression, do not rely on values left in context — use the state file as the single source of truth.
═══════════════════════════════════════════════════════
{✅ / ❌ / ⚠️} Sprint {N} --auto complete
🔁 Iterations: {iteration.current_iter}/{iteration.max_iter}
✅ Tests: {last_test_result.passed}/{last_test_result.total}
📦 Sprint Branch: feat/sprint-{N}-{sprint-name}
🌿 Worktree: {merge.worktree_removed ? "removed" : "preserved (kept due to failure)"}
📁 Deliverables:
- Blueprint: docs/blueprints/[NNN]-*/blueprint.md
- Sprint: docs/sprints/sprint-{N}-{sprint-name}/
- Tests: docs/tests/test-cases/sprint-{N}-{sprint-name}/
- Iteration summaries: docs/sprints/sprint-{N}-{sprint-name}/iterations/
- Auto-run state: docs/sprints/sprint-{N}-{sprint-name}/auto-state.yaml
{merge.pr_url (on merge success)}
{If last_iteration_classification is set, summarize unresolved failures}
═══════════════════════════════════════════════════════
After the report is printed, preserve auto-state.yaml (for debug/reproduction). A new file is written in the next sprint.
/pr-merge auto-removes the worktree. v5.9+: the actual gh pr merge runs from the main worktree — manual /pr-merge invocations stop after Sprint Phase (review loop) and instruct the user to cd to the main worktree to finalize. --auto invocations (sprint-init's pipeline, autorun) chain both phases automatically. If the worktree remains due to a conflict or interruption, the user resolves it and re-invokes /pr-merge to continue..astra-worktree.env — /test-run sources it automatically.--auto mode:
SPEC_GAP / DESIGN_MISALIGN, abort without auto-merge — blueprint/UX fixes require user judgment./autorun {feature description} instead.tools
Runs UAT (User Acceptance Testing) cases in TRUE PARALLEL using Playwright Test runner with isolated browser contexts per worker (separate cookies, localStorage, sessionStorage). Solves the two main limits of /user-test: (1) sequential single-page execution that does not scale beyond a few cases, and (2) one stuck case blocking the rest of the run. Reuses 100% of the /user-test UAT case Markdown+YAML format under docs/tests/uat-cases/, runs them via `npx playwright test --workers=N`, and emits the same report layout (index.html + issues.md + session.json + screenshots/) under docs/tests/uat-reports/. Use when the user asks to "run UAT in parallel", "speed up UAT", "test multi-user", "song song", "uat parallel", or runs /uat-parallel. Distinct from /user-test (sequential Chrome MCP, supports interactive mode), /test-run (developer integration tests), /test-scenario (scenario authoring).
tools
Performs end-user UAT (User Acceptance Testing) by driving a real browser through Chrome MCP, self-verifying each step with hard assertions (DOM / Network / URL / Console), auto-assigning severity on failure, and emitting an HTML report plus issues.md into a timestamped session folder. Supports two modes: interactive (URL + Vietnamese natural-language flow description) and --auto (batch-run pre-authored test cases under docs/tests/uat-cases/). Use when the user asks for "UAT", "user acceptance test", "kiểm thử người dùng", "regression test", or runs /user-test, /uat. Distinct from /test-run (developer-authored technical integration testing) and /test-scenario (scenario authoring from blueprints).
tools
Authors and validates LLM tool descriptions and input schemas (Anthropic Tool Use, MCP servers, LangChain @tool, Pydantic, Zod). Use when the user mentions "tool description", "function calling", "MCP tool", "Pydantic schema", "Zod schema", "@tool decorator", "input_schema", "tool spec", "툴 정의", "함수 호출 스키마", or when editing files that define LLM tool surfaces. Enforces the six required attributes (one-line summary, anti-pattern, synonyms, parameter examples, enum constraints, return shape) and blocks the seven known failure modes — wrong-tool selection, skipped tool, malformed arguments, retry loops, user-intent bypass, wrong side-effect, and un-auditable traces. For authoring ASTRA SKILL.md files use /skill-author instead — this skill is for *runtime* LLM tool surfaces, not for skill files themselves.
development
Creates new SKILL.md files or refactors existing skills to comply with the ASTRA skill best practices guide (docs/development/skill-best-practices.md). Use when user mentions "new skill", "create skill", "SKILL.md", "skill authoring", "스킬 작성", "스킬 만들기", or when editing any file matching skills/**/SKILL.md.