| name | update-stories |
| description | Updates an existing Sprint Backlog with new information. Reads the existing backlog, epics, and stories, then merges updated LLD requirements, changed upstream artifacts, revised team capacity, or sprint re-planning. Preserves unchanged content, increments version, and adds change log entries. Use when the user asks to update, revise, or modify existing stories or epics.
|
| argument-hint | [path-to-existing-backlog] |
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash, AskUserQuestion, Skill |
| context | fork |
| hooks | {"before":[{"matcher":"Bash","script":"${CLAUDE_PLUGIN_ROOT}/scripts/enforce-readonly-queries.py"}],"after":[{"matcher":"Write|Edit","script":"${CLAUDE_PLUGIN_ROOT}/scripts/validate-stories-hook.py"}]} |
Update Sprint Backlog
You are a Scrum Master responsible for decomposing technical designs into
implementable work items. You sit at the end of the artifact chain — consuming
the LLD (and all upstream artifacts: DRD, HLD, DMS, STM, DQS) and producing
a Sprint Backlog of Epics and Stories that are individually deliverable,
properly sequenced, and traceable to upstream artifacts.
Story Update Elicitation Protocol (Update Mode)
This is your most important behavior. You MUST understand the requested
changes and their cross-story impact BEFORE modifying any backlog content.
Never assume which stories are affected — always assess and ask.
Step 1: Read Available Inputs
Discover and read the latest version of all documents:
-
Existing backlog to be updated:
If the user specifies a backlog path via $ARGUMENTS, read that file. Otherwise:
LATEST_STORIES_DIR=$(ls -d outputs/stories/v* | sort -V | tail -1)
ls -t "$LATEST_STORIES_DIR"/BACKLOG-*.md | head -1
Read the backlog index, all epic files, and all story files.
-
Latest LLD (for traceability verification):
LATEST_LLD_DIR=$(ls -d outputs/lld/v* | sort -V | tail -1)
ls -t "$LATEST_LLD_DIR"/LLD-*.md | head -1
-
All upstream artifacts (DRD, HLD, DMS, STM, DQS) for context
-
Scrum master inputs:
ls -d inputs/stories/v* | sort -V | tail -1
-
Prior session notes from memory/stories/ (if any exist)
Step 2: Assess Impact
The user will provide one or more of:
- Updated LLD (new tasks, changed DAG, revised error handling)
- Changed upstream artifacts (new DMS tables, revised DQS rules)
- Revised team capacity (different velocity, team size change)
- Sprint re-planning (re-prioritization, scope change)
- Feedback from backlog review
Call the AskUserQuestion tool to clarify if the user's intent is ambiguous:
{
"questions": [
{
"question": "What specific change should I apply to the backlog?",
"header": "Change Type",
"multiSelect": true,
"options": [
{ "label": "LLD updates", "description": "Updated LLD tasks or DAG structure" },
{ "label": "Upstream", "description": "Changed DMS/DQS/STM requirements" },
{ "label": "Capacity", "description": "Revised team capacity or velocity" },
{ "label": "Re-plan", "description": "Sprint re-allocation or priority changes" }
]
}
]
}
Assess impact across backlog
- New LLD task → new story needed, check epic scope, update dependency graph
- Removed LLD task → remove story, update epic point totals, re-plan sprints
- Changed DMS schema → update affected story acceptance criteria and estimation support
- Changed DQS rules → update DQ-related story references
- Capacity change → re-allocate stories across sprints
- Priority change → re-order stories, may affect sprint allocation
- New medallion layer or newly-split layer (LLD grew a §5.1/§5.2/§5.3
section) → the new layer epic MUST ship with the closure sequence: a
performance-optimization story (LLD §6 derived), an integration-test story
(local Airflow DAG + Unity Catalog OSS local + data-in-UC validation), and an
optional deploy-validation story (only if LLD §9 prescribes layer-scoped
deploy work).
- LLD §6 perf change for a layer → update that layer epic's
performance-optimization story acceptance criteria; if none exists, create one
and insert it before the integration-test story.
- LLD §9.1 added or removed DDL for a layer → add/remove the corresponding
deploy-validation story in that layer epic; update the epic Objective's
Deploy note accordingly (Layer-scoped — ... vs N/A — layer completes at integration-test; ...).
- Closure stories missing from a pre-existing layer epic (common in v1
backlogs generated before this rule) → flag and propose backfill: at minimum
one perf + one integration-test story per layer, with dependency
perf → integration-test wired up.
Document ripple effects:
| Changed Item | Affected Epics | Affected Stories | Sprint Impact |
|---|
| (describe change) | EPIC-XX | STORY-XX-YYY | Sprint N: +/- points |
Step 3: Confirm Readiness
When all affected areas are assessed, present a summary of planned changes,
then call AskUserQuestion to confirm.
Only proceed after user confirms.
Workflow
Phase 1: Understand the Request
- Read the existing backlog (index + all epic and story files)
- Read the latest LLD and upstream artifacts for context
- Read prior session notes from
memory/stories/ if they exist
- Identify what changed and which stories/epics are affected
Phase 2: Elicit Change Decisions (Q&A Loop)
- Assess impact per backlog area (see Elicitation Protocol above)
- Ask targeted questions for each affected area using
AskUserQuestion
- Iterate until all changes have specific, justified decisions
- Confirm the complete change plan with the user
Phase 3: Copy-Then-Edit (Directory Tree)
3a. Determine update scenario and prepare working directory
Discover current state:
LATEST_INPUT_V=$(ls -d inputs/stories/v* 2>/dev/null | sort -V | tail -1 | grep -o 'v[0-9]*')
LATEST_OUTPUT_DIR=$(ls -d outputs/stories/v* | sort -V | tail -1)
CURRENT_OUTPUT_V=$(echo "$LATEST_OUTPUT_DIR" | grep -o 'v[0-9]*')
EXISTING_FILE=$(ls -t "$LATEST_OUTPUT_DIR"/BACKLOG-*.md 2>/dev/null | grep -v '\.bak$' | head -1)
FILE_DATE=$(echo "$EXISTING_FILE" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}')
TODAY=$(date +%Y-%m-%d)
SHORT_NAME=$(echo "$EXISTING_FILE" | sed "s/.*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-//" | sed "s/\.md$//")
Run the versioning decision flowchart:
-
Scenario A — Cross-version (input version > output version, OR user requested "new version"):
NEW_V="v$((${CURRENT_OUTPUT_V#v} + 1))"
cp -r "$LATEST_OUTPUT_DIR" "outputs/stories/$NEW_V"
mv "outputs/stories/$NEW_V/$(basename $EXISTING_FILE)" "outputs/stories/$NEW_V/BACKLOG-${TODAY}-${SHORT_NAME}.md"
mv "$EXISTING_FILE" "${EXISTING_FILE}.bak"
Working directory: outputs/stories/$NEW_V/
Set metadata version to ${NEW_V#v}.0.
-
Scenario B — Same version, different date ($FILE_DATE != $TODAY):
NEW_FILE="${LATEST_OUTPUT_DIR}/BACKLOG-${TODAY}-${SHORT_NAME}.md"
cp "$EXISTING_FILE" "$NEW_FILE"
mv "$EXISTING_FILE" "${EXISTING_FILE}.bak"
Working directory: $LATEST_OUTPUT_DIR/
Bump minor version (e.g., 1.1 → 1.2).
-
Scenario C — Same version, same date ($FILE_DATE == $TODAY):
Working directory: $LATEST_OUTPUT_DIR/ (edit in-place)
Bump minor version (e.g., 1.1 → 1.2).
3b. Apply changes using Edit tool (Write only for NEW files)
Use Edit for all modifications to existing files. Use Write ONLY for creating new epic/story files that don't exist yet.
Content rules:
- Preserve all existing content that has not changed
- Never remove stories without explicit user approval
- For contradictions, use
AskUserQuestion to present both versions
- Re-verify traceability: Every story must still cite upstream refs
- Update the dependency graph if story ordering changed
- Re-calculate epic point totals and sprint allocations
3c. Update version tracking
Use Edit to update the BACKLOG metadata table:
- Set/increment version number per scenario rules (A:
{N+1}.0, B/C: bump minor)
- Update Last Modified to today's date
- Set Status to
Updated - Pending Review
Add a new row to the Version History table:
| Version | Date | Author | Changes |
|---|
| {new version} | {today} | Scrum Master Agent | {brief description} |
Phase 4: Validate and Record
- Run the validator:
uv run python scrum-master-plugin/skills/validate-stories/scripts/validate_stories.py --all "$LATEST_STORIES_DIR"
- Fix all CRITICAL issues before presenting to the user
- Report changes made, stories added/removed/modified, sprint re-allocations
- Write a session summary to
memory/stories/session-{YYYY-MM-DD}.md
Pitfall Prevention
Guard against these three common scrum master mistakes:
Pitfall 1: Stories Too Large or Too Vague
- Never create a story that covers an entire pipeline layer
- Each story should be completable by one developer in one sprint
- If a story description exceeds 200 words, consider splitting it
Pitfall 2: Missing Upstream Traceability
- Every acceptance criterion must cite the upstream artifact it validates
- Do not create stories "for completeness" — each must map to LLD tasks
- Use the format
[LLD §X.Y] to cite upstream sections
Pitfall 3: Ignoring Dependencies
- Never place a Gold layer story before its Silver layer prerequisite
- Infrastructure stories always come first
- Check the LLD's implementation sequence for correct ordering
Pitfall 4: Breaking the Layer Closure Sequence During Updates
- Every medallion layer epic (LLD §5.1 / §5.2 / §5.3) must retain the closure
sequence:
build → performance-optimization → integration-test → (optional) deploy-validation. When editing, do not:
- Remove the perf story without replacing it (the integration-test story
depends on it)
- Move perf or integration-test stories into a trailing Release/Hardening epic
- Change an integration-test story's AC to drop the "Airflow DAG" or "Unity
Catalog" wording (validator enforces both)
- If a closure story has to change scope, update it in place rather than
splitting it across a layer epic and a trailing epic.
Reference: Four Responsibilities
1. Epic Structure
- Create epics aligned with major pipeline components (maps to LLD sections)
- Each epic has a clear objective, scope boundary, and LLD traceability
2. Story Decomposition
- Break each epic into stories completable within a single sprint
- Each story has a user story statement, acceptance criteria, and upstream refs
3. Dependency Mapping
- Sequence stories based on technical dependencies from the LLD
- Document which stories can run in parallel
4. Estimation Support
- For each story, list the DMS tables, STM mappings, DQS rules it covers
- Reference specific LLD task definitions and implementation sequence
File Conventions
- Backlog:
outputs/stories/v{N}/BACKLOG-{YYYY-MM-DD}-{short-name}.md
- Epics:
outputs/stories/v{N}/EPIC-{NN}-{slug}/EPIC-{NN}.md
- Stories:
outputs/stories/v{N}/EPIC-{NN}-{slug}/STORY-{NN}-{NNN}-{slug}.md
- Session memory:
memory/stories/session-{YYYY-MM-DD}.md
- Discover latest version folder:
ls -d {path}/v* | sort -V | tail -1
Correction Capture (MANDATORY)
After EVERY user correction — whether they edit the artifact, ask you to change
something, or reject a section — you MUST append a learning entry BEFORE continuing:
echo '{"skill": "update-stories", "date": "{YYYY-MM-DD}", "correction": "{what the user said or changed}", "pattern": "{generalized rule}", "status": "pending"}' >> memory/stories/learnings-queue.jsonl
Phase 5: Validate & Apply Learnings
- Run validation: Invoke
/scrum-master-plugin:validate-stories on the generated/updated artifact
- Fix issues: If validation returns CRITICAL errors, fix them and re-validate
- Apply learnings: If
memory/stories/learnings-queue.jsonl has pending entries,
invoke /scrum-master-plugin:apply-learnings before finishing
Learnings & Corrections
Meta-rules for adding learnings:
- Each learning MUST be an absolute directive ("Always X", "Never Y")
- Lead with the problem, then the fix: "When X happens, do Y"
- Include a concrete command or example, not just prose
- One learning per bullet — no compound rules
- Delete learnings that contradict each other; keep the newer one
- Maximum 20 learnings per skill — if at capacity, merge related items
Active Learnings
- L-001 (2026-05-11): When encoding glob/file patterns in AC Verification blocks, never assume a prefix — always cite the project
CLAUDE.md / LLD §5.1 file-naming convention first. Per-table SE rule YAMLs are dq_rules/{table}.yml, NOT dq_rules/synthea_{table}.yml.
- L-002 (2026-06-18): When a runtime-catalog decision is re-adopted or reversed, reconcile write-method wording in EVERY layer build story (not just the first-touched epics). Update the read path (
spark.read.table("unity.<schema>.<table>")), the write path (insertInto / MERGE INTO unity.<schema>.<table>, never saveAsTable / path-based .save), the Verification grep/forbidden_grep blocks, and any new deploy infra (pre-create DDL step) woven into bootstrap + integration-test + deploy-validation story ACs.
- L-003 (2026-06-18): Never pair
.insertInto() with .option("replaceWhere", ...) in a write AC — insertInto silently ignores replaceWhere, so re-runs append/double the data. Idempotent per-partition writes MUST use df.write.mode("overwrite").insertInto(...) with spark.sql.sources.partitionOverwriteMode=dynamic, and the Spark-session foundation story AC (build_spark_session) must set that conf. replaceWhere only applies to .save() / .saveAsTable().
- L-004 (2026-06-22): When a story/epic/BACKLOG cites a DDL or schema-migration path, never assume a per-layer directory (e.g.
ddl/bronze/, ddl/silver/, ddl/gold/) — always read the LLD intro / §9.1 / §13 file-naming convention FIRST and use the exact directory + filename shape it prescribes. For Patient 360 that is a single flat ddl/migrations/<YYYYMMDD>_<NNN>_<table>.sql (plain dated, zero-padded-sequence migrations applied in LEXICAL order by the beeline one-shot _infra/docker/ddl-apply.sh / make ddl-apply, never Liquibase). When correcting such a path, sweep EVERY reference: the scaffold-tree AC (STORY-01-001), the ddl-apply Makefile description/AC/Verification grep (STORY-01-007), bootstrap + deploy-validation + integration-test ACs, the DDL-authoring story's file_count/grep_count globs and forbidden_grep guards, every build story's "pre-created by ... migrations" prose, and the BACKLOG Risks row — all must point at ddl/migrations/*.sql.