with one click
generate-stories
// Translate a single Epic into clear, actionable User Stories with explicit acceptance criteria. Activate when an Epic is defined and work needs to be prepared for Delivery execution.
// Translate a single Epic into clear, actionable User Stories with explicit acceptance criteria. Activate when an Epic is defined and work needs to be prepared for Delivery execution.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | generate-stories |
| description | Translate a single Epic into clear, actionable User Stories with explicit acceptance criteria. Activate when an Epic is defined and work needs to be prepared for Delivery execution. |
| license | ELv2 |
| compatibility | Works with any filesystem-based AI coding agent |
| metadata | {"author":"gaai-framework","version":"1.0","category":"discovery","track":"discovery","id":"SKILL-GENERATE-STORIES-001","updated_at":"2026-03-10T00:00:00.000Z","status":"stable"} |
| inputs | [{"one_epic":"contexts/artefacts/epics/{id}.epic.md (the parent Epic file)"},"prd (optional)"] |
| outputs | ["contexts/artefacts/stories/*.md","contexts/backlog/active.backlog.yaml (mandatory โ every story must be registered)"] |
Activate when:
Stories are the contract between Discovery and Delivery. They must be the main execution unit in GAAI.
Read the Story template at contexts/artefacts/stories/_template.story.md. Read the parent Epic file. Derive story IDs using the parent Epic ID prefix (e.g., Epic E01 produces stories E01S01, E01S02, etc.).
CRITICAL โ Decision Cross-Reference (MUST execute before writing any story):
contexts/memory/index.md for DECs whose domain, title, or tags match these keywords. Use grep on contexts/memory/decisions/ if the registry table is insufficient.related_decs frontmatter field. If a DEC imposes a specific implementation pattern (e.g., "all email via queues"), add an explicit AC referencing it (e.g., "AC-N: Email sent via CF Queue per DEC-11 โ no synchronous sendEmail() calls").related_decs: [] explicitly โ never leave the field empty by omission.sendEmail() utility despite DEC-11 (2026-02-19) explicitly prohibiting synchronous email calls. 6 subsequent stories reused it, creating 12 violations undetected for 17 days. The DEC was never referenced in any of the 6 stories because no cross-reference step existed.CRITICAL โ Collision Guard (MUST execute before writing any file):
contexts/backlog/active.backlog.yaml for any existing entries with the same Epic ID prefix. If entries exist, determine the next available story number (e.g., if E52S01โE52S05 exist, start at E52S06).contexts/artefacts/stories/{id}.story.md. If the file exists and its id frontmatter matches a different epic or title, STOP immediately โ this means an ID collision between two epics. Surface the conflict to the human and do not proceed.CRITICAL โ Definition of Ready (DoR) Enforcement (MUST execute after writing each story):
mandatory_ac_categories frontmatter field.i18n, copy-quality, url-routing, icp-targeting), verify that the story has at least one AC that explicitly addresses it.[REQUIRES CLARIFICATION] and flag it to the human.mandatory_ac_categories: [] (empty), skip this step.Read parent Epic domain. If Epic has a domain, set it as the story's default. Allow explicit override per story.
Write from the user's perspective
Focus on behavior, not UI or technology
Keep stories small and independent
Ensure every story is testable
Avoid technical solutions in story body
For each story, answer: "What should the user be able to do or experience?"
Output using canonical Story template
MANDATORY โ Validation gates via isolated sub-agents (MUST pass before backlog registration).
Before registering ANY story in the backlog, the Discovery Agent MUST execute both gates in sequence. Both gates MUST be invoked as isolated sub-agents (via the Agent tool) โ never executed inline by the main Discovery agent, even if the main agent is the one that created the story. The author of a story cannot objectively validate its own work (Core Principle #5 โ Independent Evaluation).
a) Format gate โ invoke validate-artefacts (SKILL-VALIDATE-ARTEFACTS-001) as an isolated sub-agent. Provide the generated stories and their parent Epic. If verdict is BLOCKED, fix the flagged issues in the main agent and re-invoke the sub-agent until PASS.
b) Independent Review gate โ invoke the Review Sub-Agent (SUB-AGENT-REVIEW-001) at the applicable tier. The Review Sub-Agent executes the review-story-alignment (SKILL-RSA-001) 3-pass process during Tier 2 review. Provide the stories + Epic + referenced DECs + Discovery Session Brief (if one was compiled). If no Session Brief exists, the reviewer runs in Tier 1 (DEC constraints + DoR + attestation + scope creep). If any story FAILs, the Discovery Agent resolves findings (from Brief + DECs) or escalates to the human, then re-invokes the reviewer. Maximum 2 review cycles โ after that, all remaining findings escalate to the human.
These gates are sequential: format must PASS before the independent review runs.
No exceptions. Both gates run for every story creation or modification โ regardless of batch size (1 story or 20), origin (full Epic session, bug triage, single amendment), or whether a Session Brief was compiled. For batch reviews (2+ stories), invoke a separate Review Sub-Agent per story to eliminate positional bias (see review.sub-agent.md ยง Positional bias mitigation).
A story registered in the backlog as refined without both gates passing via sub-agents is a governance violation. If this step is skipped, the commit message will lack gate evidence (e.g., "validate-artefacts: PASS, review[tier-2]: PASS"), which is detectable in review.
Rationale: (1) In a past incident, Discovery produced 14 stories and registered them as refined without running either gate โ the gates were not in the skill's step list. (2) Later, Discovery self-validated both gates inline, using the "no Session Brief" skip condition to bypass the alignment gate entirely. In both cases, the main agent marked its own homework โ no independent review occurred. This step closes both gaps by mandating sub-agent execution with no skip conditions. (3) Updated 2026-03-30: the alignment gate is now executed by the Review Sub-Agent (SUB-AGENT-REVIEW-001), enforcing Core Principle #5 (Independent Evaluation).
## Dependencies section. If it lists other Epics (e.g., "E39 must be complete before E40 starts"), identify the terminal stories of each listed Epic โ the stories with the highest IDs or the ones that other stories in that Epic depend on.depends_on list. This ensures the daemon cannot pick up stories from this Epic until the dependent Epic is fully delivered.depends_on. The daemon's scheduler reads depends_on, not Epic prose. Prose constraints that are not encoded in story dependencies are invisible to the daemon.contexts/backlog/active.backlog.yaml with:id, epic, title (from story frontmatter)status per gate state โ STRICT:
status: draft if EITHER validate-artefacts OR Reviewer Tier 2 has not yet returned PASS (cycle 1 or 2) for this specific story. This is the default for any story registered before its own gates have completed.status: refined ONLY after BOTH gates have returned PASS. Promote draft โ refined as a separate backlog write (not bundled with the initial registration).refined "for now" while still iterating โ the delivery daemon polls active.backlog.yaml for refined items and dispatches them immediately, snapshotting whatever is in the worktree at dispatch time. Refined-while-iterating creates a race condition where un-reviewed cycle-0 drafts (with potentially CRITICAL-severity factual errors) can be picked up before cycle-1 corrections land.draft initially. Run gates per story (the sequencing rule of step 10 still applies). Promote each to refined individually once its own cycle ends in PASS. Never bulk-promote at the end of a batch.priority (derived from Epic priority or explicit input)artefact path pointing to the story filedependencies (from story frontmatter depends_on or Epic execution order)notes (source context โ e.g., Discovery session date, governing DEC ; include gate trail once available)cutover_state.default_pipeline at the top of active.backlog.yaml is 3phase):
phase_status: not_started โ initial value for any new entry. The daemon's 3-phase dispatcher (refined โ planned โ implemented โ qa_passed โ done) reads this field on every poll. An entry without phase_status, or with phase_status: '', causes the daemon to fail with 3phase dispatch error at phase_status='' and leaves the entry stuck (the entry may also have its top-level status flipped to in_progress by the failed dispatch attempt before it errors out).delivery_pipeline: 3phase โ the per-entry pipeline assignment. Use the value of cutover_state.default_pipeline from the top of the backlog (typically 3phase once the 3-phase pipeline migration has landed in the project ; fallback legacy if cutover is reverted). Set explicitly even when matching the default โ the field is read per-entry, not inherited from cutover_state at dispatch time.cutover_state.default_pipeline: legacy) these fields can be omitted (legacy daemon ignores them), but writing them anyway is forward-compatible and recommended.impl_model field โ DO NOT SET unless overriding a default:
impl_model ABSENT in both story frontmatter and backlog entry. The daemon's tier-aware default coerces routing automatically :
impl_model: secondary ONLY on Tier 1 stories where cost optimization is intentional and the secondary model's context budget is comfortably sufficient.impl_model: secondary on Tier 2+ stories. The daemon hard-gate will refuse the Impl phase dispatch and flip phase_status: failed. This is a structural failure, not a transient one โ empirical evidence has shown that Tier 2 cumulative input crosses the secondary-model context-compact threshold within a small number of events on the secondary route, triggering rapid context-compact cascades and masked fallback.impl_model: primary explicitly only on Tier 1 stories that override the cost-optimal default for a sensitivity reason (security, compliance, accuracy-critical). For Tier 2+, leaving the field absent is preferred (the default coerces automatically โ no redundant directive).validate-artefacts (SKILL-VALIDATE-ARTEFACTS-001) returns BLOCKED on the tier โฅ 2 + impl_model: secondary combination. Stories that violate this rule must be either (a) decomposed to Tier 1 sub-stories per the story-scope-discipline pattern, (b) have the impl_model: secondary line removed (default coercion to primary), or (c) explicitly set impl_model: primary.impl_model: secondary from a sibling story pattern onto Tier 2 stories without realizing the daemon hard-gate had been added the same day. The daemon refused dispatch, marked phase_status: failed, leaving the stories stuck. Both the validation gate above and this skill text (prevention at authoring time) close the loop.A story that exists only as an artefact file but is not in the backlog is invisible to Delivery and will never be executed. This step is non-negotiable.
Rationale (status lifecycle): A prior Discovery batch had stories rolled back from in_progress because they were registered as refined while Discovery was still iterating Reviewer cycle-1 corrections. The daemon picked up the un-reviewed drafts and began implementing architecturally wrong code based on factual errors that the Reviewer would have caught. The fix is strict adherence to the draft โ refined lifecycle defined in base.rules.md ยง Backlog State Lifecycle โ this clause makes the timing explicit at skill level.
Rationale (pipeline-schema fields): A Discovery batch registered new stories without phase_status + delivery_pipeline fields. The daemon picked up the first story at the next poll, marked its top-level status to in_progress, then errored out at the 3-phase dispatch step (phase_status=''), leaving the entry in a stuck state. Root cause : this skill predated the 3-phase pipeline schema (introduced via a foundational backlog migration story when projects flip cutover_state.default_pipeline to 3phase) and never enumerated the new mandatory fields in step 12. Mitigation : the bullet above now mandates both fields whenever cutover_state.default_pipeline = 3phase, with an explicit pointer to the failure mode so the skill author understands why the field is non-optional rather than nice-to-have.
CRITICAL โ Backlog YAML write safety (MUST follow):
grep -m1 "^- id:" <backlog>. Use the same indent level (typically 0-space: - id: with 2-space properties).yaml.dump() to rewrite the file. It destroys comments, changes quotes, and alters indentation. Use line-by-line append or the scheduler (backlog-scheduler.sh --set-status, --set-field).python3 -c "import yaml; yaml.safe_load(open('<backlog>'))". If validation fails, fix before committing.cat >> heredoc (2-space items appended to a 0-space file) + yaml.dump() reformatting broke the backlog YAML, blocked the daemon, and required manual cleanup. These rules prevent recurrence.staging in the same step. Commit without push is a violation โ Delivery cannot pick up stories that exist only locally.
contexts/artefacts/stories/*.story.md), backlog (contexts/backlog/active.backlog.yaml), and any other modified GAAI context files (memory, decisions, etc.)chore(discovery): generate stories {id_range} for Epic {epic_id}
chore(discovery): generate stories E06S46โE06S50 for Epic E06staging branch immediately after commit โ never wait for human to request the pushTemplate: contexts/artefacts/stories/_template.story.md
Produces files at contexts/artefacts/stories/{id}.story.md:
As a {user role},
I want {goal},
so that {benefit/value}.
Acceptance Criteria:
- [ ] Given {context}, when {action}, then {expected result}
id and related_backlog_id match the parent Epic's ID prefixactive.backlog.yaml โ verify by counting story files vs backlog entries for this Epic. Mismatch = FAIL.epic frontmatter matches the intended Epic. Mismatch = CRITICAL FAILURE.related_decs field in frontmatter โ either a non-empty list of constraining DECs, or an explicit empty list []. Missing field = FAIL. Stories touching email, billing, booking, auth, or infrastructure domains with related_decs: [] should be double-checked โ these domains have the highest DEC density.This skill must NOT:
generate-epics)Stories are the contract. Ambiguous stories produce ambiguous software.