[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M754434FN3RY2CSZS7A0T8H4":3,"skill-same:01M754434FN3RY2CSZS7A0T8H4":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M754434FN3RY2CSZS7A0T8H4","x-internal-create-story",null,"Generate Story files from Epic or from an existing Feature artifact: data contracts, inherited RNFs, dependency declarations, sub-tasks, quality validation, optional Jira integration. Invoked by orchestrators and focused public wrappers.","review-bench\u002Federcnj_ia-dev-environment","review-bench","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F286778065?v=4","01M7517F9NTEPDZDAXJBR30FWT","ReviewBench","01M7517FAC9F4P7TGWCNJ8VYVW",0,"MIT","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-event-driven\u002F.claude\u002Fskills\u002Fx-internal-create-story\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: x-internal-create-story\ndescription: \"Generate Story files from Epic or from an existing Feature artifact: data contracts, inherited RNFs, dependency declarations, sub-tasks, quality validation, optional Jira integration. Invoked by orchestrators and focused public wrappers.\"\nvisibility: internal\nuser-invocable: false\nmodel: sonnet\nallowed-tools: Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, Skill\nrequires-capabilities: []\ncontext-budget: heavy\n---\n\n> 🔒 **INTERNAL SKILL** — Invoked only by other skills via the Skill tool. Not user-invocable.\n\n## Output Policy\n\n- **Language**: Portuguese (pt-BR) for all content. English for technical terms (cache, timeout, handler, endpoint) and code identifiers.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers and greetings to save tokens.\n\n# Skill: Story Creator\n\n## Purpose\n\nGenerate individual story files from an Epic and system specification **or from an existing Feature artifact**. Each story is self-contained: a developer can implement it without going back to the original source. Stories include data contracts, inherited RNFs, dependency declarations, tagged sub-tasks, and quality gate validation.\n\n## Triggers\n\n- `\u002Fx-story-create \u003Cspec_file> \u003Cepic_file>` — generate all stories from the epic index\n- `\u002Fx-story-create --from-feature \u003Cfeature-file|feature-id> --epic-id \u003CEPIC-NNNN|NNNN>` — generate focused stories from a feature artifact\n- User asks to create stories, generate user stories from an epic, or break an epic into implementable stories\n- User mentions writing acceptance criteria, detailing technical stories, or creating story files with contracts and diagrams\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|-----------|------|----------|---------|-------------|\n| `\u003CSPEC_FILE>` | Path | Yes | — | Path to the system specification file |\n| `\u003CEPIC_FILE>` | Path | Yes | — | Path to the Epic file (with story index and rules table) |\n| `--from-feature \u003Cfeature-file\\|feature-id>` | String | No | — | Feature artifact source for Product-First Feature → Story generation |\n| `--epic-id \u003CEPIC-NNNN\\|NNNN>` | String | No | — | Epic linkage required in `--from-feature` mode |\n| `--capability-file \u003Cpath>` | Path | No | — | Capability artifact used to enrich inherited RNFs in `--from-feature` mode |\n| `--product-file \u003Cpath>` | Path | No | — | Product artifact used to enrich inherited RNFs in `--from-feature` mode |\n| `--quality-threshold` | int | No | 70 | Minimum score (0-100) required for a story to be saved |\n| `--jira` | String | No | — | Jira project key (e.g., PROJ). When provided, skip AskUserQuestion and create stories in Jira directly (EPIC-0042). |\n| `--no-jira` | Boolean | No | false | Skip Jira integration entirely, no prompting (EPIC-0042). |\n| `--dry-run` | Boolean | No | false | When true, story files are written to disk but Steps P4 \u002F P5 (planning-commit \u002F push) become no-ops with a `\"dry-run, skipping commit\"` warning (EPIC-0049 \u002F RULE-007). |\n| `--no-commit` | Boolean | No | false | When true, skip Steps P4 and P5. Used by orchestrators (e.g., `x-epic-decompose`, `x-plan-story`) that batch-commit at the parent level (EPIC-0049 \u002F RULE-007). |\n| `--legacy-template-v1` | Boolean | No | false | **DEPRECATED** (Rule 19 §Skill Renaming — removed in 2 releases). Use v1 template structure. Emits deprecation warning on stderr on every invocation. |\n\n## Prerequisites\n\nRead the following files before starting:\n\n**Template (output structure):**\n- `.claude\u002Ftemplates\u002F_TEMPLATE-STORY.md` — The exact structure to follow (v2 value-driven: 9 sections + Refinement Verdict — default since EPIC-0070). When `--legacy-template-v1` is set, use v1 structure and emit deprecation warning (see below).\n\n> **`--legacy-template-v1` deprecation warning:** When the flag is present, emit to stderr before writing each story file:\n> ```\n> WARN [legacy-template] --legacy-template-v1 is DEPRECATED.\n>       Templates v1 will be removed in 2 releases.\n>       Migrate to v2: \u002Fx-migrate-templates \u003Cstory-id>\n> ```\n> Also emit telemetry event `metadata: {flag: \"legacy-template-v1\", skill: \"x-story-create\"}` for adoption tracking.\n\n**Decomposition philosophy (sizing and boundary heuristics):**\n- `.claude\u002Fskills\u002Fx-epic-decompose\u002Freferences\u002Fdecomposition-guide.md`\n\n**Gherkin completeness requirements:**\n- `.claude\u002Fknowledge\u002Fstory-planning.md` — Rule 13, section SD-02 (mandatory scenario categories and TPP ordering)\n\n**Required inputs from the user:**\n- The system specification file (original spec)\n- The Epic file (with story index and rules table) — generated by `x-epic-create` skill\n\n## Workflow\n\n### Step P1 — Detect Worktree Context (EPIC-0049 \u002F RULE-001)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P1-Worktree-Detect`\n\nInvoke `x-manage-worktrees` in detect-context mode to record whether the current checkout is already inside an epic worktree (`STORY_OWNS_WORKTREE=false`, `EPIC_WORKTREE_DETECTED=true|false`). Result is advisory only — `x-internal-ensure-epic-branch` (Step P2) makes the authoritative decision.\n\n    Skill(skill: \"x-manage-worktrees\", args: \"detect-context\")\n\nContinue on any detect-context failure (fail-open, RULE-006) — log a WARNING and proceed to Step P2.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P1-Worktree-Detect ok`\n\n### Step P2 — Ensure `epic\u002F\u003CID>` Branch (EPIC-0049 \u002F RULE-001)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P2-Epic-Branch-Ensure`\n\nResolve the effective epic ID by reading the `**ID:**` header of the supplied `\u003CEPIC_FILE>` (e.g., `EPIC-0049` → `0049`). This is the authoritative source — do NOT scan `plans\u002F` folders here.\n\nInvoke `x-internal-ensure-epic-branch` so the canonical `epic\u002F\u003CID>` branch exists locally AND on origin (idempotent). The skill is a no-op when the current checkout is already on `epic\u002F\u003CID>` or a worktree rooted at that branch.\n\n    Skill(skill: \"x-internal-ensure-epic-branch\", args: \"--epic-id \u003CXXXX>\")\n\nOn failure (non-zero exit), abort with `EPIC_BRANCH_ENSURE_FAILED` — a clean audit trail cannot be produced without the canonical branch.\n\nWhen `--no-commit` is set (orchestrator mode), skip this step — the parent owns branch lifecycle.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P2-Epic-Branch-Ensure ok`\n\n### Step 1 — Read the Epic and Spec\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-1-Context-Gathering`\n\nRead the source inputs completely.\n\n- **Epic mode (default):** read both the Epic and Spec. From the Epic, extract:\n- The story index (IDs, titles, dependencies)\n- The rules table (RULE-001..N) — stories reference these by ID\n- The DoD (copied into each story for quick reference)\n\n- **Feature mode (`--from-feature`):** read the Feature artifact and target `--epic-id`. In this mode, derive stories from the feature use cases, render inherited RNFs into `## 2. RNFs Herdadas`, and intentionally omit `## 2. Persona & Cenário`, `## 4. AC (...)`, and `## 8. Decision Rationale`.\n\nFrom the upstream source, understand the technical context: journeys, data contracts, protocol mappings, state machines, error codes, and metrics.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-1-Context-Gathering ok`\n\n### Step 2 — Generate Each Story\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-2-Generation-Loop`\n\nFor each story in the Epic's index, create a file following `_TEMPLATE-STORY.md`. Process\nstories in dependency order (foundations first, then core, then extensions).\n\n**v2 sections (default — EPIC-0070):**\n1. **Visão**: User story format with measurable outcome\n2. **Persona & Cenário**: Specific role and trigger context (not \"o sistema\")\n3. **Entrega de Valor**: Falsifiable value proposition + measurable metric + business impact\n4. **AC (Gherkin — 4 categorias mandatórias)**: Degenerate, Happy, Error\u002FBoundary, Performance\u002FSLA, Security\u002FAuth\n5. **Contratos**: Typed request\u002Fresponse; no `Object`\u002F`Map\u003CString, Any>`; event schemas when applicable\n6. **Tasks**: Formal task decomposition (TASK-XXXX-YYYY-NNN, testability patterns, LOC bounds)\n7. **Dependências**: Blocked By \u002F Blocks cross-references consistent with epic index\n8. **Decision Rationale**: 4-line micro-template (`**Decisão:** \u002F **Motivo:** \u002F **Alternativa descartada:** \u002F **Consequência:**`)\n9. **Refinement Verdict**: `Status: TBD`, all dimensions unchecked\n\n**Story header (mandatory):**\nEvery generated story MUST include at the top:\n```markdown\n**Status:** Pendente\n**Refinement Verdict:** TBD\n```\n\nWhen `--legacy-template-v1` is set, use v1 structure instead and emit the deprecation warning (see Prerequisites).\n\n#### 2.1 — Dependencias\n\n| Blocked By | Blocks |\n| :--- | :--- |\n| Stories this one depends on | Stories that depend on this one |\n\nMust be consistent with the Epic's index. Cross-check: if story-0001-0003 lists story-0001-0002 as\nblocker, then story-0001-0002 must list story-0001-0003 in its Blocks column.\n\n#### 2.2 — Regras Transversais Aplicaveis\n\nReference only the rules from the Epic that impact this specific story. Omit rules\nirrelevant to this story's scope.\n\n#### 2.3 — Descricao\n\nStart with user story format: \"Como **\u003CPersona>**, eu quero \u003Ccapability>, garantindo que \u003Coutcome>.\"\n\nFollow with 2-3 paragraphs of technical context: why this story exists, how it fits in the\nepic, what architectural patterns it establishes or reuses. Include specific protocol details,\ncomponent names, and design decisions from the spec.\n\nAdd numbered subsections (3.1, 3.2, ...) for each distinct technical requirement. Be specific:\nprotocol details, framing formats, concurrency requirements, timeout values — everything a\ndeveloper needs.\n\n#### 2.4 — Entrega de Valor (Section 3.5 — Mandatory)\n\nEvery story MUST contain a Section 3.5 with exactly 3 bullets articulating measurable business\nvalue. This is the most important section for stakeholder communication. It answers: \"What does\nthe business gain when this story is done?\"\n\n**Structure (exactly 3 bullets, all mandatory):**\n- **Valor Principal:** A single sentence — the measurable business outcome\n- **Metrica de Sucesso:** How to verify value was delivered (quantitative when possible)\n- **Impacto no Negocio:** Direct impact on users\u002Fstakeholders\n\n**Rules (Non-Negotiable):**\n- Value MUST be from the business\u002Fuser perspective, NOT technical\n- FORBIDDEN: \"Migrar classes A, B, C para Java\" (technical task, no business value)\n- CORRECT: \"Endpoint de pagamento com credito disponivel em Java, permitindo desligamento do servico legado .NET\"\n- FORBIDDEN: \"Implementar repositorio de dados\" (infrastructure detail)\n- CORRECT: \"Persistencia de transacoes garantida com integridade referencial, habilitando auditoria\"\n- FORBIDDEN: \"Codigo funciona\" (non-measurable)\n- CORRECT: \"100% dos endpoints respondem em \u003C 200ms p95, validado por teste de carga\"\n- FORBIDDEN: \"Melhorar o sistema\" (vague)\n- CORRECT: \"Reducao de 30% no tempo de onboarding de novos desenvolvedores\"\n- Layer 0 (Foundation) stories express enablement value: \"Infraestrutura de banco pronta, desbloqueando N historias de dominio\"\n- Layer 4 (Cross-cutting) stories express risk reduction: \"Cobertura de testes >= 95%, reduzindo risco de regressao em deploys futuros\"\n\n**Anti-Patterns for Value Articulation:**\n\n| Anti-Pattern | Example | Why It Fails |\n|:---|:---|:---|\n| Technical-only language | \"Implementar repositorio\" | No business value expressed |\n| Non-measurable metric | \"Codigo funciona\" | Cannot be objectively verified |\n| Vague impact | \"Melhorar o sistema\" | No quantifiable improvement |\n\nA story missing Section 3.5 or with any bullet containing purely technical language without\nbusiness value MUST be rejected by the quality gate and refined before saving.\n\n#### 2.5 — Definicoes de Qualidade Locais\n\n**DoR Local**: Specific preconditions for this story. Use checkboxes `- [ ]`.\nExamples: \"Porta TCP definida\", \"Schema da tabela X criado\", \"Decisao sobre Y tomada\".\n\n**DoD Local**: Specific acceptance criteria for this story. Use checkboxes.\nExamples: \"Servidor TCP aceitando conexoes\", \"Handler X funcional\", \"Teste de carga validado\".\n\n**DoD Global**: Copy from the Epic verbatim. This is for quick reference during code review.\n\n#### 2.6 — Contratos de Dados (Data Contract)\n\nThis is the most critical section. Data contracts must be copy-paste precise.\nRich data contracts eliminate ambiguity by providing explicit types, validations,\nexamples, and error codes for every endpoint.\n\n##### 2.6.1 — Request Table\n\nFor REST-based stories, use the expanded Request format:\n\n| Campo | Tipo | M\u002FO | Validacoes | Exemplo |\n| :--- | :--- | :--- | :--- | :--- |\n| `field_name` | `UUID` \u002F `BigDecimal` \u002F `String(255)` \u002F `Integer` \u002F `List\u003CString>` | M ou O | min\u002Fmax, regex, enum values | valor concreto |\n\nFor protocol-based stories (binary protocols, gRPC, etc.), use the format:\n\n| Campo | Formato | Request | Response | Origem \u002F Regra |\n| :--- | :--- | :--- | :--- | :--- |\n| `field_name` | type format | M\u002FO\u002F- | M\u002FO\u002F- | Generate\u002FEcho\u002FDerive — description |\n\n##### 2.6.2 — Response Table\n\n| Campo | Tipo | Sempre presente | Descricao |\n| :--- | :--- | :--- | :--- |\n| `field_name` | `UUID` \u002F `String` \u002F `BigDecimal` | Sim ou Nao | descricao do campo |\n\n##### 2.6.3 — Error Codes Mapeados\n\nEvery endpoint MUST declare its error codes following RFC 7807 (RULE-006 — Problem Details for HTTP APIs):\n\n| HTTP Status | Error Code | Condicao | Mensagem (RFC 7807) |\n| :--- | :--- | :--- | :--- |\n| `400` | `INVALID_FIELD` | Campo obrigatorio ausente ou formato invalido | `{\"type\":\"...\",\"title\":\"Bad Request\",\"status\":400,\"detail\":\"...\"}` |\n| `404` | `NOT_FOUND` | Recurso nao encontrado | `{\"type\":\"...\",\"title\":\"Not Found\",\"status\":404,\"detail\":\"...\"}` |\n| `409` | `CONFLICT` | Violacao de regra de negocio | `{\"type\":\"...\",\"title\":\"Conflict\",\"status\":409,\"detail\":\"...\"}` |\n| `422` | `UNPROCESSABLE` | Validacao de dominio falhou | `{\"type\":\"...\",\"title\":\"Unprocessable Entity\",\"status\":422,\"detail\":\"...\"}` |\n\nError codes follow RFC 7807 format with fields: `type`, `title`, `status`, `detail`, and `instance`.\n\n##### 2.6.4 — Event Schema (event-driven stories)\n\nFor stories with `eventDriven: true`, include the Event Schema section:\n\n| Campo | Tipo | Obrigatorio | Descricao |\n| :--- | :--- | :--- | :--- |\n| `eventType` | `String` | Sim | Tipo do evento (e.g., `OrderCreated`, `PaymentProcessed`) |\n| `eventVersion` | `String` | Sim | Versao do schema do evento (e.g., `1.0.0`) |\n| `timestamp` | `Instant` | Sim | Momento da emissao do evento (ISO-8601 UTC) |\n| `correlationId` | `UUID` | Sim | ID de correlacao para rastreamento |\n| `payload` | `Object` | Sim | Payload do evento (schema especifico do dominio) |\n\n**Event versioning notes:**\n- **Backward compatibility:** New fields MUST be optional; existing fields MUST NOT change type\n- **Schema evolution strategy:** Use additive-only changes; breaking changes require new event type\n- **Deprecation policy:** Deprecated event versions MUST be supported for at least 2 release cycles\n\n##### Data Contract Precision Rules\n\n- Field names must match the spec exactly (same casing, same naming)\n- Types must be explicit with format: `UUID`, `BigDecimal`, `String(255)`, `Integer`, `List\u003CString>`, etc.\n- M\u002FO flags must reflect the actual contract, not guesses\n- Derivation rules must explain exactly how values are computed\n- Fields without a declared type MUST emit a warning: \"field type is required for rich contracts\"\n- Stories without endpoints MUST include a note: \"Nenhum endpoint declarado nesta story\"\n\n#### 2.7 — Diagramas\n\nCreate Mermaid sequence diagrams showing the complete flow for this story's main operation.\nUse the actual component names from the spec (not generic \"Service A\", \"Service B\").\n\nInclude:\n- The trigger (client request, Kafka event, timer)\n- Validation steps\n- Business logic (decision engine, routing)\n- Persistence (DB writes, cache updates)\n- Async operations (Kafka publish, logging)\n- Response construction\n- Error paths (at least one error scenario)\n\n##### Diagram Requirement Matrix\n\n| Story Type | Sequence Diagram | Deployment Diagram | Activity Diagram |\n|:---|:---|:---|:---|\n| Request-Response flow (REST, gRPC, TCP) | **MANDATORY** | — | Recommended if 3+ branches |\n| Event-driven flow (producer-broker-consumer) | **MANDATORY** | — | Recommended if 3+ branches |\n| Infrastructure \u002F deployment change | — | **MANDATORY** | — |\n| Complex business logic (3+ decision branches) | Recommended | — | **MANDATORY** |\n| Documentation \u002F configuration only | Not required | Not required | Not required |\n| Refactoring (no behavior change) | Recommended | — | — |\n\nRules:\n- A story involving data flow between 2+ components MUST include a sequence diagram.\n- A story altering infrastructure MUST include a deployment diagram.\n- A story with no data flow and no infrastructure change MAY omit diagrams but should note \"Diagram not required for this story type.\"\n\n##### Inter-Layer Sequence Diagram Template\n\nUse this template as the starting point for stories involving request-response flows:\n\n```mermaid\nsequenceDiagram\n    participant Client as Client\n    participant Inbound as Inbound Adapter\u003Cbr\u002F>(REST\u002FgRPC\u002FCLI)\n    participant App as Application\u003Cbr\u002F>(Use Case)\n    participant Domain as Domain\u003Cbr\u002F>(Engine\u002FModel)\n    participant Outbound as Outbound Adapter\u003Cbr\u002F>(DB\u002FAPI\u002FQueue)\n\n    Client->>Inbound: Request (DTO)\n    Inbound->>Inbound: Validate & Map DTO→Command\n    Inbound->>App: Execute(Command)\n    App->>Domain: Process(Entity)\n    Domain->>Domain: Apply business rules\n    Domain-->>App: Result\n    App->>Outbound: Persist\u002FSend\n    Outbound-->>App: Confirmation\n    App-->>Inbound: Response\n    Inbound-->>Client: Response (DTO)\n\n    alt Validation Error\n        Inbound-->>Client: 400 Bad Request\n    end\n\n    alt Domain Rule Violation\n        Domain-->>App: BusinessException\n        App-->>Inbound: Error Result\n        Inbound-->>Client: 422 Unprocessable Entity\n    end\n```\n\nParticipant naming rules:\n- Use actual component names from the spec (not generic \"Service A\").\n- Must show at least: trigger - validation - business logic - persistence - response.\n- Must include at least 1 error scenario with `alt` block.\n\n##### Diagram Validation Checklist\n\n- [ ] Participants use real component names (not \"Service A\", \"Service B\")\n- [ ] Diagram shows at least 3 architecture layers (e.g., Inbound - Application - Domain)\n- [ ] At least 1 error path is shown using `alt` block\n- [ ] All data transformations are visible (DTO-Command, Entity-Domain)\n- [ ] Async operations (if any) are distinguished from sync calls\n- [ ] Response construction path is complete (from domain result back to client)\n\n#### 2.8 — Criterios de Aceite (Gherkin)\n\nWrite Gherkin scenarios in Portuguese (DADO\u002FQUANDO\u002FENTAO\u002FE\u002FMAS).\n\n**Mandatory scenario categories (TPP order):**\n1. **Degenerate cases** (first): null input, empty collection, zero value, missing required field — at least 1 scenario\n2. **Happy path**: Main success flow with concrete values — at least 1 scenario\n3. **Error paths**: Each documented error type must have a corresponding scenario with expected error code\u002Fmessage — at least 1 per error type\n4. **Boundary values**: Triplet pattern for each bounded input — (at-minimum, at-maximum, past-maximum) — at least 1 triplet\n5. **Complex edge cases** (if applicable): Combinations, race conditions, state transitions\n\n**Minimum floor:** 4 scenarios per story (degenerate + happy + error + boundary\u002Fedge). If fewer than 4, add scenarios from under-represented categories or emit a warning.\n\n**TPP ordering rationale:** Scenarios ordered from simplest (degenerate\u002Fnull guards) to most complex (edge cases) to match the natural TDD red-green-refactor cycle. Degenerate cases MUST appear before happy paths.\n\n**Boundary value triplet pattern:**\nWhen a story involves bounded inputs (numeric ranges, string lengths, collection sizes), generate three scenarios per bound:\n- At-minimum (e.g., value = 1 for range [1, 100])\n- At-maximum (e.g., value = 100)\n- Past-maximum (e.g., value = 101)\nIf the story has no naturally bounded inputs, boundary scenarios may be omitted but the 4-scenario minimum must still be met.\n\n**Quality rules for Gherkin:**\n- Use concrete values, not abstractions (\"valor de R$ 100,50\" not \"um valor qualquer\")\n- Each scenario should be independently testable\n- Avoid overlapping scenarios — each tests a distinct behavior\n- Include field-level assertions (\"o campo DE 39 deve ser '00'\")\n\n#### 2.9 — Formal Task Decomposition (Section 8)\n\nSection 8 decomposes each story into formal, testable tasks with unique IDs, testability\npatterns, and size constraints. Each task is the atomic unit of delivery — one PR per task.\n\n##### 2.9.1 — Task ID Format\n\nEvery task receives a unique ID in the format `TASK-XXXX-YYYY-NNN`:\n- `XXXX` — Epic number (4 digits, zero-padded)\n- `YYYY` — Story number (4 digits, zero-padded)\n- `NNN` — Sequential task number within the story (3 digits, starting at 001)\n\nExample: `TASK-0029-0013-001`, `TASK-0029-0013-002`, ...\n\n##### 2.9.2 — Task Table Format\n\nSection 8 MUST contain a table with these columns:\n\n| ID | Descricao | Camada | Dependencias | Tag | Padrao de Testabilidade | Estimativa LOC |\n| :--- | :--- | :--- | :--- | :--- | :--- | :--- |\n| `TASK-XXXX-YYYY-001` | Concise task description | domain | — | [Dev] | Domain+UnitTest | 80 |\n| `TASK-XXXX-YYYY-002` | Concise task description | port | TASK-XXXX-YYYY-001 | [Dev] | Port+Adapter+IT | 60 |\n| `TASK-XXXX-YYYY-003` | Concise task description | test | TASK-XXXX-YYYY-002 | [Test] | — | 100 |\n\nEach row represents one atomic task. Use checkboxes `- [ ]` for tracking after the table.\n\n##### 2.9.3 — Valid Testability Patterns\n\nEvery `[Dev]` task MUST follow one of these 6 valid testability patterns:\n\n| Pattern | Component | Expected Test |\n| :--- | :--- | :--- |\n| Domain+UnitTest | Entity, Value Object, Engine | Unit test of business logic |\n| Port+Adapter+IT | Interface + Implementation | Integration test with real dependency |\n| UseCase+AT | Application use case | Acceptance test end-to-end |\n| Endpoint+APITest | Controller\u002FResource | HTTP test with status\u002Fbody\u002Ferrors |\n| Migration+Smoke | Schema migration | Smoke test of connectivity |\n| Config+VerificationTest | Configuration | Verification test of loading |\n\n`[Test]` tasks in Layer 4 (cross-cutting) are exempt from this requirement.\n`[Doc]` tasks do not require a testability pattern.\n\n##### 2.9.4 — Anti-Patterns (Rejected)\n\nThe following task decomposition patterns are anti-patterns and MUST be detected and\nrejected during generation. When detected, merge or reformulate the task.\n\n| Anti-Pattern | Detection Rule | Remediation |\n| :--- | :--- | :--- |\n| Interface-only | Task creates a port\u002Finterface without adapter | Merge with adapter task to form Port+Adapter+IT |\n| DTO-only | Task creates DTO without endpoint or service usage | Merge with endpoint\u002Fservice task |\n| Test-only (outside Layer 4) | Task creates test without production code | Merge with corresponding [Dev] task (TDD pair) |\n| Config-only without test | Task creates configuration without verification | Add Config+VerificationTest pattern |\n\nWhen an anti-pattern is detected, log: `\"Anti-pattern detected: \u003Ctype> task reformulated\"`\n\n##### 2.9.5 — Sizing Constraints\n\n| Constraint | Value | Action When Violated |\n| :--- | :--- | :--- |\n| Minimum tasks per story | 3 | Decompose existing tasks further |\n| Maximum tasks per story | 8 | Merge related tasks |\n| Minimum LOC per task | 20 | Merge with adjacent task in same layer |\n| Maximum LOC per task | 300 | Split into 2+ tasks |\n| Recommended LOC per task | 50-150 | Ideal range, no action needed |\n\n**Merge rules:**\n- Tasks below 20 LOC MUST be merged with an adjacent task in the same layer\n- After merging, the resulting task MUST still follow a valid testability pattern\n- If merging would exceed 300 LOC, split differently\n\n**Split rules:**\n- Tasks above 300 LOC MUST be split into 2 or more tasks\n- Each resulting task MUST follow a valid testability pattern\n- Each resulting task MUST have 20-300 LOC\n\n**Story rejection:**\n- A story with fewer than 3 tasks after all merge\u002Fsplit operations MUST be rejected\n  with message: `\"Minimum 3 tasks required, found N\"`\n- A story with more than 8 tasks after all merge\u002Fsplit operations MUST have tasks\n  merged until the count is within range\n\n##### 2.9.6 — Mandatory Test Task\n\nEvery story MUST include at least one of these test-tagged tasks:\n- `[Test] Smoke\u002FE2E: \u003Cteste automatizado validando criterio de aceite principal de ponta a ponta>`\n- `[Test] Integracao: \u003Cteste de integracao validando fluxo completo>`\n\nA story without ANY automated end-to-end validation task is INCOMPLETE and must not be saved.\n\n##### 2.9.7 — Task Tags\n\n- `[Dev]` — Implementation tasks (handler, service, repository, migration)\n- `[Test]` — Test tasks (unit, integration, E2E, performance)\n- `[Doc]` — Documentation tasks (diagrams, wiki, API docs)\n\n### Step 3 — Optional Jira Integration (per story)\n\nAfter generating each story's markdown content but before saving, optionally create the\nstory in Jira.\n\n#### 3.1 — Cascaded from Orchestrator\n\nIf a `jiraContext` was provided by the orchestrator (`x-epic-decompose`) with\n`jiraContext.enabled == true` and `jiraContext.cascadeToStories == true`:\n\nFor each story (no additional user prompting needed):\n1. Call `mcp__atlassian__createJiraIssue` to create a Story issue:\n   - `cloudId`: `jiraContext.cloudId`\n   - `projectKey`: `jiraContext.projectKey`\n   - `issueTypeName`: \"Story\"\n   - `summary`: the story title\n   - `description`: the user story text from Section 3 (the \"Como **Persona**...\" paragraph)\n   - `contentFormat`: \"markdown\"\n   - `parent` (optional): `jiraContext.epicIssueKey` — include only if `jiraContext.epicIssueKey` is present; omit entirely when absent (e.g., epic creation failed in Phase B) to avoid MCP errors and maintain non-blocking behavior\n   - `additional_fields`: `{ \"labels\": [{ \"name\": \"generated-by-ia-dev-env\" }, { \"name\": \"story-XXXX-YYYY\" }] }` (where `story-XXXX-YYYY` is the local story ID for bidirectional sync)\n2. Capture the returned Jira issue key\n3. Replace `\u003CCHAVE-JIRA>` in the story markdown with the actual key\n4. Store the mapping `{ storyId -> jiraKey }` for later dependency linking\n\nIf creation fails for a story: log a warning, set `\u003CCHAVE-JIRA>` to `—`, continue\nwith remaining stories.\n\n#### 3.2 — Standalone Invocation (EPIC-0042)\n\nIf no `jiraContext` was provided (skill invoked directly, not via orchestrator):\n\n1. Check if `mcp__atlassian__createJiraIssue` is available. If not available, skip Jira\n   integration entirely — replace all `\u003CCHAVE-JIRA>` with `—`.\n\n2. **Roteamento por flag (EPIC-0042):**\n\n   - Se `--no-jira` estiver presente: pular a integracao com Jira completamente.\n     Substituir todos os `\u003CCHAVE-JIRA>` por `—`. Log:\n     `\"Jira integration skipped (--no-jira, EPIC-0042)\"`. Pular para o Step 4.\n\n   - Se `--jira \u003CPROJECT_KEY>` estiver presente: usar a chave de projeto fornecida\n     diretamente. Pular AskUserQuestion. Descobrir o `cloudId` chamando\n     `mcp__atlassian__getAccessibleAtlassianResources`. Usar o `id` do primeiro site\n     disponivel como `cloudId`. Se a chamada falhar ou nao retornar sites, alertar o\n     usuario e pular a integracao com Jira (substituir todos os `\u003CCHAVE-JIRA>` por `—`).\n     Caso contrario, prosseguir para criar as historias no Jira (step 3d abaixo, usando\n     a chave de projeto fornecida pela flag). Log:\n     `\"Jira integration via --jira flag: project {PROJECT_KEY} (EPIC-0042)\"`\n\n   - Se nenhuma flag estiver presente: prosseguir para o step 3 (prompt interativo\n     compativel com a versao anterior).\n\n3. Use `AskUserQuestion`:\n   ```\n   question: \"Deseja criar as historias no Jira?\"\n   header: \"Jira\"\n   options:\n     - label: \"Sim, criar no Jira\"\n       description: \"Criar cada historia como issue no Jira via MCP\"\n     - label: \"Nao, apenas markdown\"\n       description: \"Gerar apenas os arquivos markdown sem integracao com Jira\"\n   multiSelect: false\n   ```\n\n3a. If \"Sim\":\n   a. Ask for the Jira project key\n   b. Discover the `cloudId` by calling `mcp__atlassian__getAccessibleAtlassianResources`.\n      Use the first available site's `id` as the `cloudId`. If the call fails or returns\n      no sites, warn the user and skip Jira integration (replace all `\u003CCHAVE-JIRA>` with `—`).\n   c. Ask if there is a parent epic in Jira:\n      ```\n      question: \"Existe um epico pai no Jira para vincular as historias? Se sim, informe a chave (ex: PROJ-123). Caso nao exista, deixe em branco ou responda 'Nao'.\"\n      header: \"Epic Link\"\n      ```\n      If the user informs a non-empty value different from \"Nao\", use it as the `parent`.\n      If the answer is empty or \"Nao\", create the stories without a parent link.\n   d. For each story, call `mcp__atlassian__createJiraIssue`:\n      - `cloudId`: the discovered `cloudId`\n      - `projectKey`: the user-provided project key\n      - `issueTypeName`: \"Story\"\n      - `summary`: the story title\n      - `description`: the user story text from Section 3\n      - `contentFormat`: \"markdown\"\n      - `parent` (optional): the epic key from step c, if provided\n      - `additional_fields`: `{ \"labels\": [{ \"name\": \"generated-by-ia-dev-env\" }, { \"name\": \"story-XXXX-YYYY\" }] }` (where `story-XXXX-YYYY` is the local story ID for bidirectional sync)\n\n3b. If \"Nao\": replace all `\u003CCHAVE-JIRA>` with `—` and continue\n\n#### 3.3 — Jira Dependency Linking (second pass)\n\nAfter ALL stories are created and have Jira keys, perform a second pass to create\ndependency links in Jira:\n\nFor each story's \"Blocked By\" list:\n- If the blocking story has a Jira key, call `mcp__atlassian__createIssueLink`:\n  - `cloudId`: the discovered `cloudId` (or `jiraContext.cloudId`)\n  - `type`: \"Blocks\"\n  - `inwardIssue`: the blocker's Jira key (the issue that blocks)\n  - `outwardIssue`: the current story's Jira key (the issue that is blocked)\n- If linking fails: log a warning, continue\n\nThis step is best-effort. Report: \"N dependency links criados no Jira\"\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-2-Generation-Loop ok`\n\n### Step 4 — Quality Gate Validation (pre-write check)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-3-Validation`\n\nBefore writing any story file to disk, run a quality gate evaluation on the generated\nmarkdown content. This step ensures that low-quality stories do not reach the backlog\nwithout refinement.\n\n#### 4.1 — Quality Gate Flag\n\n| Flag | Type | Default | Range | Description |\n|:---|:---|:---|:---|:---|\n| `--quality-threshold` | int | 70 | 0-100 | Minimum score required for a story to be saved |\n\n- Value `0` disables the quality gate entirely (all stories pass)\n- Value `100` requires a perfect score\n\n#### 4.2 — Scoring Dimensions\n\nEvaluate each story against these dimensions (each scored 0-100, then weighted):\n\n| Dimension | Weight | What to Check |\n|:---|:---|:---|\n| Gherkin completeness | 20% | Minimum 4 scenarios, TPP ordering, degenerate cases present, concrete values (not abstractions) |\n| Data contract precision | 20% | All fields typed, M\u002FO flags present, validation rules declared, error codes mapped (RFC 7807) |\n| Task testability | 20% | All [Dev] tasks follow one of 6 valid testability patterns; no anti-patterns (interface-only, DTO-only, test-only outside Layer 4, config-only without test) |\n| Task independence | 10% | Tasks can be implemented and tested independently; circular dependencies between tasks are forbidden; each task produces a verifiable artifact |\n| Dependency consistency | 10% | Blocked By\u002FBlocks cross-references match the Epic index bidirectionally |\n| Diagram coverage | 10% | Sequence diagram present for data-flow stories, deployment diagram for infra stories |\n| Value articulation | 5% | Section 3.5 present with exactly 3 bullets (Valor Principal, Metrica de Sucesso, Impacto no Negocio) using business-perspective language (not technical tasks) |\n| Sub-task completeness | 5% | At least one `[Test]` task, task count between 3-8, all tasks within 20-300 LOC range |\n\n#### 4.3 — Evaluation Flow\n\nFor each generated story (after content generation, before file write):\n\n1. Compute the weighted score across all dimensions\n2. Compare against the `--quality-threshold` (default: 70)\n3. If `score >= threshold`: proceed to file write\n4. If `score \u003C threshold`: enter refinement loop\n\n#### 4.4 — Automatic Refinement Loop\n\nWhen a story fails the quality gate:\n\n1. Display the full quality report with score breakdown and specific action items per dimension\n2. Display: `\"Score N\u002F100 below threshold T. Refining scenarios before proceeding.\"`\n3. Attempt automatic refinement based on the action items:\n   - Add missing degenerate Gherkin scenarios if absent\n   - Add field types to data contract entries missing types\n   - Add boundary value triplets for bounded inputs\n   - Add missing error code mappings\n   - Fix dependency cross-references\n   - Reformulate tasks with anti-patterns (merge interface-only with adapter, etc.)\n   - Merge tasks below 20 LOC with adjacent tasks in same layer\n   - Split tasks above 300 LOC into smaller tasks\n   - Add Section 3.5 if missing, replace technical language with business value\n4. Re-evaluate the refined story\n5. If `score >= threshold`: save the file and report `\"Story refined: oldScore -> newScore (attempt N)\"`\n6. If still below threshold after attempt 1: repeat refinement (attempt 2)\n7. If still below after 2 attempts: display `\"Score still N\u002F100 after 2 refinements. Manual intervention needed.\"` and do NOT save the file\n\nMaximum automatic refinement attempts: **2**\n\n#### 4.5 — Quality Report Format\n\nWhen displaying a quality gate report (on rejection or after refinement), use this format:\n\n```\nQuality Gate Report — story-XXXX-YYYY\nScore: N\u002F100 (threshold: T)\n\n  Gherkin completeness:     NN\u002F100 (weight 20%)\n    - [ACTION] Add degenerate scenario for null input\n    - [ACTION] Reorder scenarios: degenerate before happy path\n  Data contract precision:  NN\u002F100 (weight 20%)\n    - [ACTION] Field 'amount' missing type declaration\n    - [OK] Error codes mapped for all endpoints\n  Task testability:         NN\u002F100 (weight 20%)\n    - [ACTION] TASK-0029-0013-002 uses anti-pattern: interface-only\n    - [OK] 5 of 6 tasks follow valid testability patterns\n  Task independence:        NN\u002F100 (weight 10%)\n    - [OK] No circular dependencies between tasks\n    - [ACTION] TASK-0029-0013-003 cannot be tested without TASK-0029-0013-005\n  Dependency consistency:   NN\u002F100 (weight 10%)\n    - [OK] All cross-references valid\n  Diagram coverage:         NN\u002F100 (weight 10%)\n    - [ACTION] Missing sequence diagram for REST flow\n  Value articulation:       NN\u002F100 (weight 5%)\n    - [OK] Section 3.5 present with 3 business-value bullets\n  Sub-task completeness:    NN\u002F100 (weight 5%)\n    - [OK] 5 tasks within 3-8 range, all within 20-300 LOC\n\nAction items: K issue(s) to resolve\n```\n\n### Step 5 — Save and Report\n\nSave each story as `story-XXXX-YYYY.md` in the same directory as the Epic (inside `ai\u002Fepics\u002Fepic-XXXX\u002F`).\nThe XXXX is the epic number (extracted from the Epic file) and YYYY is the story sequence (from the Epic's index).\nReport: total stories generated, dependency graph summary, any inconsistencies found.\n\nIf Jira integration was active, also report:\n- Stories created in Jira: N of M\n- Dependency links created: K\n- Failures: list any failed items\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-3-Validation ok`\n\n### Step P4 — Commit Planning Artifacts (EPIC-0049 \u002F RULE-007)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P4-Planning-Commit`\n\nIf `--dry-run` or `--no-commit` is set, log `\"dry-run, skipping commit\"` (dry-run) or `\"orchestrated mode, skipping commit\"` (no-commit) and skip this step entirely.\n\nOtherwise, delegate the commit to `x-commit-planning` so the newly written `ai\u002Fepics\u002Fepic-XXXX\u002Fstory-XXXX-YYYY.md` files are versioned on the canonical `epic\u002F\u003CID>` branch without triggering the code pre-commit chain (format \u002F lint \u002F compile):\n\n    Skill(skill: \"x-commit-planning\",\n          args: \"--scope docs --story-id \u003CXXXX-YYYY> --paths ai\u002Fepics\u002Fepic-\u003CXXXX>\u002Fstory-\u003CXXXX-YYYY>.md --subject \\\"add user story\\\"\")\n\nWhen multiple stories are generated in one invocation, batch them into a single commit by passing all paths at once (comma- or space-separated per `x-commit-planning` contract). Subject becomes `\"add N user stories\"`.\n\nIdempotency: re-executing the skill with identical inputs produces `commitSha=null` (silent no-op). The contract is enforced by `x-commit-planning` itself.\n\nOn `COMMIT_FAILED` (exit 4 from `x-commit-planning`), abort the workflow with the same error code so operators receive a single, unambiguous signal.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P4-Planning-Commit ok`\n\n### Step P5 — Push to Origin (optional, EPIC-0049)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P5-Push`\n\nIf `--dry-run` or `--no-commit` is set, log `\"dry-run, skipping push\"` \u002F `\"orchestrated mode, skipping push\"` and skip.\n\nDelegate the push to `x-push-branch` so the canonical `epic\u002F\u003CID>` branch is synchronized with origin:\n\n    Skill(skill: \"x-push-branch\", args: \"--branch epic\u002F\u003CXXXX>\")\n\nOn push failure (remote rejection, no connectivity), log a WARNING and continue — the local commit is preserved; the operator can re-run Step P5 or `git push` manually. Do NOT abort.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P5-Push ok`\n\n## Sizing Heuristics\n\n**Too big** (split it):\n- More than 2 endpoints in one story\n- More than 1 protocol flow (e.g., X200 + X420)\n- More than 8 Gherkin scenarios\n- More than 10 sub-tasks\n\n**Too small** (merge it):\n- No testable endpoint or flow\n- Less than 4 Gherkin scenarios\n- Could be a sub-task of another story\n\n**Just right**:\n- 1 clear capability, 4-8 Gherkin scenarios, 4-8 sub-tasks\n- Produces testable artifacts (endpoint, handler, migration)\n\n## Error Handling\n\n| Scenario | Action |\n|----------|--------|\n| Template file missing | Abort with message: \"Template _TEMPLATE-STORY.md not found\" |\n| Epic file missing or unparseable | Abort with message: \"Epic file not found or invalid format\" |\n| Spec file missing | Abort with message: \"Specification file not found\" |\n| Circular dependency detected | Warn and list the cycle; proceed with best-effort ordering |\n| Quality gate failure after 2 retries | Skip story, report: \"Manual intervention needed\" |\n| Jira MCP unavailable | Replace `\u003CCHAVE-JIRA>` with `—`, continue without Jira |\n| Jira issue creation fails | Log warning, set `\u003CCHAVE-JIRA>` to `—`, continue with next story |\n| `x-internal-ensure-epic-branch` fails (Step P2) | Abort with `EPIC_BRANCH_ENSURE_FAILED`; canonical branch is required for versioning |\n| `x-commit-planning` exit 4 (Step P4) | Abort with `COMMIT_FAILED`; story file(s) already written but not versioned |\n| `x-commit-planning` exit 0 + `noOp=true` (Step P4) | Silent no-op — re-execution idempotency confirmed; continue to Step P5 |\n| `x-push-branch` fails (Step P5) | WARN only; local commit preserved; operator re-runs manually |\n| `--dry-run` set | Steps P4 and P5 become no-ops with log line `\"dry-run, skipping commit\"` \u002F `\"dry-run, skipping push\"` |\n| `--no-commit` set | Steps P2, P4 and P5 become no-ops — parent orchestrator owns branch + commit lifecycle |\n\n## Common Mistakes\n\n- **Vague data contracts**: \"Enviar dados do cartao\" is useless. The contract must list every field with type, format, and mandatory flag\n- **Abstract Gherkin**: \"DADO que o sistema esta funcionando\" tests nothing. Use concrete preconditions\n- **Missing error scenarios**: Every story should have at least 2 error Gherkin scenarios\n- **Inconsistent dependencies**: If story-0001-0003 says \"Blocked By: story-0001-0002\" but story-0001-0002 does not list story-0001-0003 in Blocks, there is a bug\n- **Copy-paste from spec without adaptation**: The spec describes the system. The story describes the work. Reframe from \"the system does X\" to \"implement X so that Y\"\n- **Missing degenerate cases**: Every story must test null\u002Fempty\u002Fzero inputs. If the story has parameters, there must be at least one degenerate scenario\n- **Boundary values without triplet**: A single \"big number\" test is insufficient. Use the triplet pattern: at-min, at-max, past-max\n- **Happy-path-first ordering**: Degenerate cases must appear before happy paths (TPP ordering). Reorder if needed\n- **Under-counting scenarios**: The minimum is 4 scenarios per story. If only happy + 1 error exist, add degenerate and boundary scenarios\n\n## Integration Notes\n\n| Skill | Relationship | Context |\n|-------|-------------|---------|\n| x-epic-create | produces | Produces the Epic file read by this skill |\n| x-epic-decompose | called-by | Orchestrator invokes x-story-create in Phase C |\n| x-epic-map | reads | Implementation Map reads generated story files |\n| x-create-jira-stories | calls | Creates Jira issues from generated story files |\n| x-manage-worktrees | calls (Step P1) | Detect-context (EPIC-0049 \u002F RULE-001) |\n| x-internal-ensure-epic-branch | calls (Step P2) | Ensure `epic\u002F\u003CID>` exists locally + origin (EPIC-0049 \u002F RULE-001) |\n| x-commit-planning | calls (Step P4) | Batch-commit story file(s) without code pre-commit chain (EPIC-0049 \u002F RULE-007) |\n| x-push-branch | calls (Step P5) | Push canonical epic branch to origin (optional) |\n| story-planning | reads | Reads decomposition guide and Gherkin rules |\n\n## Knowledge Pack References\n\n| Knowledge Pack | Usage |\n|----------------|-------|\n| story-planning | Decomposition philosophy, sizing heuristics, TPP ordering |\n\n## Examples\n\n```\n# Default — v2 template (EPIC-0070 default)\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md\")\n\n# With quality threshold override\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --quality-threshold 80\")\n\n# Legacy v1 template during deprecation window (Rule 19)\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --legacy-template-v1\")\n# → Emits: WARN [legacy-template] --legacy-template-v1 is DEPRECATED...\n\n# Orchestrator mode — parent handles branch + commit\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --no-commit\")\n\n# With Jira integration\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --jira PROJ\")\n```\n","> 🔒 **INTERNAL SKILL** — Invoked only by other skills via the Skill tool. Not user-invocable.\n\n## Output Policy\n\n- **Language**: Portuguese (pt-BR) for all content. English for technical terms (cache, timeout, handler, endpoint) and code identifiers.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers and greetings to save tokens.\n\n# Skill: Story Creator\n\n## Purpose\n\nGenerate individual story files from an Epic and system specification **or from an existing Feature artifact**. Each story is self-contained: a developer can implement it without going back to the original source. Stories include data contracts, inherited RNFs, dependency declarations, tagged sub-tasks, and quality gate validation.\n\n## Triggers\n\n- `\u002Fx-story-create \u003Cspec_file> \u003Cepic_file>` — generate all stories from the epic index\n- `\u002Fx-story-create --from-feature \u003Cfeature-file|feature-id> --epic-id \u003CEPIC-NNNN|NNNN>` — generate focused stories from a feature artifact\n- User asks to create stories, generate user stories from an epic, or break an epic into implementable stories\n- User mentions writing acceptance criteria, detailing technical stories, or creating story files with contracts and diagrams\n\n## Parameters\n\n| Parameter | Type | Required | Default | Description |\n|-----------|------|----------|---------|-------------|\n| `\u003CSPEC_FILE>` | Path | Yes | — | Path to the system specification file |\n| `\u003CEPIC_FILE>` | Path | Yes | — | Path to the Epic file (with story index and rules table) |\n| `--from-feature \u003Cfeature-file\\|feature-id>` | String | No | — | Feature artifact source for Product-First Feature → Story generation |\n| `--epic-id \u003CEPIC-NNNN\\|NNNN>` | String | No | — | Epic linkage required in `--from-feature` mode |\n| `--capability-file \u003Cpath>` | Path | No | — | Capability artifact used to enrich inherited RNFs in `--from-feature` mode |\n| `--product-file \u003Cpath>` | Path | No | — | Product artifact used to enrich inherited RNFs in `--from-feature` mode |\n| `--quality-threshold` | int | No | 70 | Minimum score (0-100) required for a story to be saved |\n| `--jira` | String | No | — | Jira project key (e.g., PROJ). When provided, skip AskUserQuestion and create stories in Jira directly (EPIC-0042). |\n| `--no-jira` | Boolean | No | false | Skip Jira integration entirely, no prompting (EPIC-0042). |\n| `--dry-run` | Boolean | No | false | When true, story files are written to disk but Steps P4 \u002F P5 (planning-commit \u002F push) become no-ops with a `\"dry-run, skipping commit\"` warning (EPIC-0049 \u002F RULE-007). |\n| `--no-commit` | Boolean | No | false | When true, skip Steps P4 and P5. Used by orchestrators (e.g., `x-epic-decompose`, `x-plan-story`) that batch-commit at the parent level (EPIC-0049 \u002F RULE-007). |\n| `--legacy-template-v1` | Boolean | No | false | **DEPRECATED** (Rule 19 §Skill Renaming — removed in 2 releases). Use v1 template structure. Emits deprecation warning on stderr on every invocation. |\n\n## Prerequisites\n\nRead the following files before starting:\n\n**Template (output structure):**\n- `.claude\u002Ftemplates\u002F_TEMPLATE-STORY.md` — The exact structure to follow (v2 value-driven: 9 sections + Refinement Verdict — default since EPIC-0070). When `--legacy-template-v1` is set, use v1 structure and emit deprecation warning (see below).\n\n> **`--legacy-template-v1` deprecation warning:** When the flag is present, emit to stderr before writing each story file:\n> ```\n> WARN [legacy-template] --legacy-template-v1 is DEPRECATED.\n>       Templates v1 will be removed in 2 releases.\n>       Migrate to v2: \u002Fx-migrate-templates \u003Cstory-id>\n> ```\n> Also emit telemetry event `metadata: {flag: \"legacy-template-v1\", skill: \"x-story-create\"}` for adoption tracking.\n\n**Decomposition philosophy (sizing and boundary heuristics):**\n- `.claude\u002Fskills\u002Fx-epic-decompose\u002Freferences\u002Fdecomposition-guide.md`\n\n**Gherkin completeness requirements:**\n- `.claude\u002Fknowledge\u002Fstory-planning.md` — Rule 13, section SD-02 (mandatory scenario categories and TPP ordering)\n\n**Required inputs from the user:**\n- The system specification file (original spec)\n- The Epic file (with story index and rules table) — generated by `x-epic-create` skill\n\n## Workflow\n\n### Step P1 — Detect Worktree Context (EPIC-0049 \u002F RULE-001)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P1-Worktree-Detect`\n\nInvoke `x-manage-worktrees` in detect-context mode to record whether the current checkout is already inside an epic worktree (`STORY_OWNS_WORKTREE=false`, `EPIC_WORKTREE_DETECTED=true|false`). Result is advisory only — `x-internal-ensure-epic-branch` (Step P2) makes the authoritative decision.\n\n    Skill(skill: \"x-manage-worktrees\", args: \"detect-context\")\n\nContinue on any detect-context failure (fail-open, RULE-006) — log a WARNING and proceed to Step P2.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P1-Worktree-Detect ok`\n\n### Step P2 — Ensure `epic\u002F\u003CID>` Branch (EPIC-0049 \u002F RULE-001)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P2-Epic-Branch-Ensure`\n\nResolve the effective epic ID by reading the `**ID:**` header of the supplied `\u003CEPIC_FILE>` (e.g., `EPIC-0049` → `0049`). This is the authoritative source — do NOT scan `plans\u002F` folders here.\n\nInvoke `x-internal-ensure-epic-branch` so the canonical `epic\u002F\u003CID>` branch exists locally AND on origin (idempotent). The skill is a no-op when the current checkout is already on `epic\u002F\u003CID>` or a worktree rooted at that branch.\n\n    Skill(skill: \"x-internal-ensure-epic-branch\", args: \"--epic-id \u003CXXXX>\")\n\nOn failure (non-zero exit), abort with `EPIC_BRANCH_ENSURE_FAILED` — a clean audit trail cannot be produced without the canonical branch.\n\nWhen `--no-commit` is set (orchestrator mode), skip this step — the parent owns branch lifecycle.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P2-Epic-Branch-Ensure ok`\n\n### Step 1 — Read the Epic and Spec\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-1-Context-Gathering`\n\nRead the source inputs completely.\n\n- **Epic mode (default):** read both the Epic and Spec. From the Epic, extract:\n- The story index (IDs, titles, dependencies)\n- The rules table (RULE-001..N) — stories reference these by ID\n- The DoD (copied into each story for quick reference)\n\n- **Feature mode (`--from-feature`):** read the Feature artifact and target `--epic-id`. In this mode, derive stories from the feature use cases, render inherited RNFs into `## 2. RNFs Herdadas`, and intentionally omit `## 2. Persona & Cenário`, `## 4. AC (...)`, and `## 8. Decision Rationale`.\n\nFrom the upstream source, understand the technical context: journeys, data contracts, protocol mappings, state machines, error codes, and metrics.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-1-Context-Gathering ok`\n\n### Step 2 — Generate Each Story\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-2-Generation-Loop`\n\nFor each story in the Epic's index, create a file following `_TEMPLATE-STORY.md`. Process\nstories in dependency order (foundations first, then core, then extensions).\n\n**v2 sections (default — EPIC-0070):**\n1. **Visão**: User story format with measurable outcome\n2. **Persona & Cenário**: Specific role and trigger context (not \"o sistema\")\n3. **Entrega de Valor**: Falsifiable value proposition + measurable metric + business impact\n4. **AC (Gherkin — 4 categorias mandatórias)**: Degenerate, Happy, Error\u002FBoundary, Performance\u002FSLA, Security\u002FAuth\n5. **Contratos**: Typed request\u002Fresponse; no `Object`\u002F`Map\u003CString, Any>`; event schemas when applicable\n6. **Tasks**: Formal task decomposition (TASK-XXXX-YYYY-NNN, testability patterns, LOC bounds)\n7. **Dependências**: Blocked By \u002F Blocks cross-references consistent with epic index\n8. **Decision Rationale**: 4-line micro-template (`**Decisão:** \u002F **Motivo:** \u002F **Alternativa descartada:** \u002F **Consequência:**`)\n9. **Refinement Verdict**: `Status: TBD`, all dimensions unchecked\n\n**Story header (mandatory):**\nEvery generated story MUST include at the top:\n```markdown\n**Status:** Pendente\n**Refinement Verdict:** TBD\n```\n\nWhen `--legacy-template-v1` is set, use v1 structure instead and emit the deprecation warning (see Prerequisites).\n\n#### 2.1 — Dependencias\n\n| Blocked By | Blocks |\n| :--- | :--- |\n| Stories this one depends on | Stories that depend on this one |\n\nMust be consistent with the Epic's index. Cross-check: if story-0001-0003 lists story-0001-0002 as\nblocker, then story-0001-0002 must list story-0001-0003 in its Blocks column.\n\n#### 2.2 — Regras Transversais Aplicaveis\n\nReference only the rules from the Epic that impact this specific story. Omit rules\nirrelevant to this story's scope.\n\n#### 2.3 — Descricao\n\nStart with user story format: \"Como **\u003CPersona>**, eu quero \u003Ccapability>, garantindo que \u003Coutcome>.\"\n\nFollow with 2-3 paragraphs of technical context: why this story exists, how it fits in the\nepic, what architectural patterns it establishes or reuses. Include specific protocol details,\ncomponent names, and design decisions from the spec.\n\nAdd numbered subsections (3.1, 3.2, ...) for each distinct technical requirement. Be specific:\nprotocol details, framing formats, concurrency requirements, timeout values — everything a\ndeveloper needs.\n\n#### 2.4 — Entrega de Valor (Section 3.5 — Mandatory)\n\nEvery story MUST contain a Section 3.5 with exactly 3 bullets articulating measurable business\nvalue. This is the most important section for stakeholder communication. It answers: \"What does\nthe business gain when this story is done?\"\n\n**Structure (exactly 3 bullets, all mandatory):**\n- **Valor Principal:** A single sentence — the measurable business outcome\n- **Metrica de Sucesso:** How to verify value was delivered (quantitative when possible)\n- **Impacto no Negocio:** Direct impact on users\u002Fstakeholders\n\n**Rules (Non-Negotiable):**\n- Value MUST be from the business\u002Fuser perspective, NOT technical\n- FORBIDDEN: \"Migrar classes A, B, C para Java\" (technical task, no business value)\n- CORRECT: \"Endpoint de pagamento com credito disponivel em Java, permitindo desligamento do servico legado .NET\"\n- FORBIDDEN: \"Implementar repositorio de dados\" (infrastructure detail)\n- CORRECT: \"Persistencia de transacoes garantida com integridade referencial, habilitando auditoria\"\n- FORBIDDEN: \"Codigo funciona\" (non-measurable)\n- CORRECT: \"100% dos endpoints respondem em \u003C 200ms p95, validado por teste de carga\"\n- FORBIDDEN: \"Melhorar o sistema\" (vague)\n- CORRECT: \"Reducao de 30% no tempo de onboarding de novos desenvolvedores\"\n- Layer 0 (Foundation) stories express enablement value: \"Infraestrutura de banco pronta, desbloqueando N historias de dominio\"\n- Layer 4 (Cross-cutting) stories express risk reduction: \"Cobertura de testes >= 95%, reduzindo risco de regressao em deploys futuros\"\n\n**Anti-Patterns for Value Articulation:**\n\n| Anti-Pattern | Example | Why It Fails |\n|:---|:---|:---|\n| Technical-only language | \"Implementar repositorio\" | No business value expressed |\n| Non-measurable metric | \"Codigo funciona\" | Cannot be objectively verified |\n| Vague impact | \"Melhorar o sistema\" | No quantifiable improvement |\n\nA story missing Section 3.5 or with any bullet containing purely technical language without\nbusiness value MUST be rejected by the quality gate and refined before saving.\n\n#### 2.5 — Definicoes de Qualidade Locais\n\n**DoR Local**: Specific preconditions for this story. Use checkboxes `- [ ]`.\nExamples: \"Porta TCP definida\", \"Schema da tabela X criado\", \"Decisao sobre Y tomada\".\n\n**DoD Local**: Specific acceptance criteria for this story. Use checkboxes.\nExamples: \"Servidor TCP aceitando conexoes\", \"Handler X funcional\", \"Teste de carga validado\".\n\n**DoD Global**: Copy from the Epic verbatim. This is for quick reference during code review.\n\n#### 2.6 — Contratos de Dados (Data Contract)\n\nThis is the most critical section. Data contracts must be copy-paste precise.\nRich data contracts eliminate ambiguity by providing explicit types, validations,\nexamples, and error codes for every endpoint.\n\n##### 2.6.1 — Request Table\n\nFor REST-based stories, use the expanded Request format:\n\n| Campo | Tipo | M\u002FO | Validacoes | Exemplo |\n| :--- | :--- | :--- | :--- | :--- |\n| `field_name` | `UUID` \u002F `BigDecimal` \u002F `String(255)` \u002F `Integer` \u002F `List\u003CString>` | M ou O | min\u002Fmax, regex, enum values | valor concreto |\n\nFor protocol-based stories (binary protocols, gRPC, etc.), use the format:\n\n| Campo | Formato | Request | Response | Origem \u002F Regra |\n| :--- | :--- | :--- | :--- | :--- |\n| `field_name` | type format | M\u002FO\u002F- | M\u002FO\u002F- | Generate\u002FEcho\u002FDerive — description |\n\n##### 2.6.2 — Response Table\n\n| Campo | Tipo | Sempre presente | Descricao |\n| :--- | :--- | :--- | :--- |\n| `field_name` | `UUID` \u002F `String` \u002F `BigDecimal` | Sim ou Nao | descricao do campo |\n\n##### 2.6.3 — Error Codes Mapeados\n\nEvery endpoint MUST declare its error codes following RFC 7807 (RULE-006 — Problem Details for HTTP APIs):\n\n| HTTP Status | Error Code | Condicao | Mensagem (RFC 7807) |\n| :--- | :--- | :--- | :--- |\n| `400` | `INVALID_FIELD` | Campo obrigatorio ausente ou formato invalido | `{\"type\":\"...\",\"title\":\"Bad Request\",\"status\":400,\"detail\":\"...\"}` |\n| `404` | `NOT_FOUND` | Recurso nao encontrado | `{\"type\":\"...\",\"title\":\"Not Found\",\"status\":404,\"detail\":\"...\"}` |\n| `409` | `CONFLICT` | Violacao de regra de negocio | `{\"type\":\"...\",\"title\":\"Conflict\",\"status\":409,\"detail\":\"...\"}` |\n| `422` | `UNPROCESSABLE` | Validacao de dominio falhou | `{\"type\":\"...\",\"title\":\"Unprocessable Entity\",\"status\":422,\"detail\":\"...\"}` |\n\nError codes follow RFC 7807 format with fields: `type`, `title`, `status`, `detail`, and `instance`.\n\n##### 2.6.4 — Event Schema (event-driven stories)\n\nFor stories with `eventDriven: true`, include the Event Schema section:\n\n| Campo | Tipo | Obrigatorio | Descricao |\n| :--- | :--- | :--- | :--- |\n| `eventType` | `String` | Sim | Tipo do evento (e.g., `OrderCreated`, `PaymentProcessed`) |\n| `eventVersion` | `String` | Sim | Versao do schema do evento (e.g., `1.0.0`) |\n| `timestamp` | `Instant` | Sim | Momento da emissao do evento (ISO-8601 UTC) |\n| `correlationId` | `UUID` | Sim | ID de correlacao para rastreamento |\n| `payload` | `Object` | Sim | Payload do evento (schema especifico do dominio) |\n\n**Event versioning notes:**\n- **Backward compatibility:** New fields MUST be optional; existing fields MUST NOT change type\n- **Schema evolution strategy:** Use additive-only changes; breaking changes require new event type\n- **Deprecation policy:** Deprecated event versions MUST be supported for at least 2 release cycles\n\n##### Data Contract Precision Rules\n\n- Field names must match the spec exactly (same casing, same naming)\n- Types must be explicit with format: `UUID`, `BigDecimal`, `String(255)`, `Integer`, `List\u003CString>`, etc.\n- M\u002FO flags must reflect the actual contract, not guesses\n- Derivation rules must explain exactly how values are computed\n- Fields without a declared type MUST emit a warning: \"field type is required for rich contracts\"\n- Stories without endpoints MUST include a note: \"Nenhum endpoint declarado nesta story\"\n\n#### 2.7 — Diagramas\n\nCreate Mermaid sequence diagrams showing the complete flow for this story's main operation.\nUse the actual component names from the spec (not generic \"Service A\", \"Service B\").\n\nInclude:\n- The trigger (client request, Kafka event, timer)\n- Validation steps\n- Business logic (decision engine, routing)\n- Persistence (DB writes, cache updates)\n- Async operations (Kafka publish, logging)\n- Response construction\n- Error paths (at least one error scenario)\n\n##### Diagram Requirement Matrix\n\n| Story Type | Sequence Diagram | Deployment Diagram | Activity Diagram |\n|:---|:---|:---|:---|\n| Request-Response flow (REST, gRPC, TCP) | **MANDATORY** | — | Recommended if 3+ branches |\n| Event-driven flow (producer-broker-consumer) | **MANDATORY** | — | Recommended if 3+ branches |\n| Infrastructure \u002F deployment change | — | **MANDATORY** | — |\n| Complex business logic (3+ decision branches) | Recommended | — | **MANDATORY** |\n| Documentation \u002F configuration only | Not required | Not required | Not required |\n| Refactoring (no behavior change) | Recommended | — | — |\n\nRules:\n- A story involving data flow between 2+ components MUST include a sequence diagram.\n- A story altering infrastructure MUST include a deployment diagram.\n- A story with no data flow and no infrastructure change MAY omit diagrams but should note \"Diagram not required for this story type.\"\n\n##### Inter-Layer Sequence Diagram Template\n\nUse this template as the starting point for stories involving request-response flows:\n\n```mermaid\nsequenceDiagram\n    participant Client as Client\n    participant Inbound as Inbound Adapter\u003Cbr\u002F>(REST\u002FgRPC\u002FCLI)\n    participant App as Application\u003Cbr\u002F>(Use Case)\n    participant Domain as Domain\u003Cbr\u002F>(Engine\u002FModel)\n    participant Outbound as Outbound Adapter\u003Cbr\u002F>(DB\u002FAPI\u002FQueue)\n\n    Client->>Inbound: Request (DTO)\n    Inbound->>Inbound: Validate & Map DTO→Command\n    Inbound->>App: Execute(Command)\n    App->>Domain: Process(Entity)\n    Domain->>Domain: Apply business rules\n    Domain-->>App: Result\n    App->>Outbound: Persist\u002FSend\n    Outbound-->>App: Confirmation\n    App-->>Inbound: Response\n    Inbound-->>Client: Response (DTO)\n\n    alt Validation Error\n        Inbound-->>Client: 400 Bad Request\n    end\n\n    alt Domain Rule Violation\n        Domain-->>App: BusinessException\n        App-->>Inbound: Error Result\n        Inbound-->>Client: 422 Unprocessable Entity\n    end\n```\n\nParticipant naming rules:\n- Use actual component names from the spec (not generic \"Service A\").\n- Must show at least: trigger - validation - business logic - persistence - response.\n- Must include at least 1 error scenario with `alt` block.\n\n##### Diagram Validation Checklist\n\n- [ ] Participants use real component names (not \"Service A\", \"Service B\")\n- [ ] Diagram shows at least 3 architecture layers (e.g., Inbound - Application - Domain)\n- [ ] At least 1 error path is shown using `alt` block\n- [ ] All data transformations are visible (DTO-Command, Entity-Domain)\n- [ ] Async operations (if any) are distinguished from sync calls\n- [ ] Response construction path is complete (from domain result back to client)\n\n#### 2.8 — Criterios de Aceite (Gherkin)\n\nWrite Gherkin scenarios in Portuguese (DADO\u002FQUANDO\u002FENTAO\u002FE\u002FMAS).\n\n**Mandatory scenario categories (TPP order):**\n1. **Degenerate cases** (first): null input, empty collection, zero value, missing required field — at least 1 scenario\n2. **Happy path**: Main success flow with concrete values — at least 1 scenario\n3. **Error paths**: Each documented error type must have a corresponding scenario with expected error code\u002Fmessage — at least 1 per error type\n4. **Boundary values**: Triplet pattern for each bounded input — (at-minimum, at-maximum, past-maximum) — at least 1 triplet\n5. **Complex edge cases** (if applicable): Combinations, race conditions, state transitions\n\n**Minimum floor:** 4 scenarios per story (degenerate + happy + error + boundary\u002Fedge). If fewer than 4, add scenarios from under-represented categories or emit a warning.\n\n**TPP ordering rationale:** Scenarios ordered from simplest (degenerate\u002Fnull guards) to most complex (edge cases) to match the natural TDD red-green-refactor cycle. Degenerate cases MUST appear before happy paths.\n\n**Boundary value triplet pattern:**\nWhen a story involves bounded inputs (numeric ranges, string lengths, collection sizes), generate three scenarios per bound:\n- At-minimum (e.g., value = 1 for range [1, 100])\n- At-maximum (e.g., value = 100)\n- Past-maximum (e.g., value = 101)\nIf the story has no naturally bounded inputs, boundary scenarios may be omitted but the 4-scenario minimum must still be met.\n\n**Quality rules for Gherkin:**\n- Use concrete values, not abstractions (\"valor de R$ 100,50\" not \"um valor qualquer\")\n- Each scenario should be independently testable\n- Avoid overlapping scenarios — each tests a distinct behavior\n- Include field-level assertions (\"o campo DE 39 deve ser '00'\")\n\n#### 2.9 — Formal Task Decomposition (Section 8)\n\nSection 8 decomposes each story into formal, testable tasks with unique IDs, testability\npatterns, and size constraints. Each task is the atomic unit of delivery — one PR per task.\n\n##### 2.9.1 — Task ID Format\n\nEvery task receives a unique ID in the format `TASK-XXXX-YYYY-NNN`:\n- `XXXX` — Epic number (4 digits, zero-padded)\n- `YYYY` — Story number (4 digits, zero-padded)\n- `NNN` — Sequential task number within the story (3 digits, starting at 001)\n\nExample: `TASK-0029-0013-001`, `TASK-0029-0013-002`, ...\n\n##### 2.9.2 — Task Table Format\n\nSection 8 MUST contain a table with these columns:\n\n| ID | Descricao | Camada | Dependencias | Tag | Padrao de Testabilidade | Estimativa LOC |\n| :--- | :--- | :--- | :--- | :--- | :--- | :--- |\n| `TASK-XXXX-YYYY-001` | Concise task description | domain | — | [Dev] | Domain+UnitTest | 80 |\n| `TASK-XXXX-YYYY-002` | Concise task description | port | TASK-XXXX-YYYY-001 | [Dev] | Port+Adapter+IT | 60 |\n| `TASK-XXXX-YYYY-003` | Concise task description | test | TASK-XXXX-YYYY-002 | [Test] | — | 100 |\n\nEach row represents one atomic task. Use checkboxes `- [ ]` for tracking after the table.\n\n##### 2.9.3 — Valid Testability Patterns\n\nEvery `[Dev]` task MUST follow one of these 6 valid testability patterns:\n\n| Pattern | Component | Expected Test |\n| :--- | :--- | :--- |\n| Domain+UnitTest | Entity, Value Object, Engine | Unit test of business logic |\n| Port+Adapter+IT | Interface + Implementation | Integration test with real dependency |\n| UseCase+AT | Application use case | Acceptance test end-to-end |\n| Endpoint+APITest | Controller\u002FResource | HTTP test with status\u002Fbody\u002Ferrors |\n| Migration+Smoke | Schema migration | Smoke test of connectivity |\n| Config+VerificationTest | Configuration | Verification test of loading |\n\n`[Test]` tasks in Layer 4 (cross-cutting) are exempt from this requirement.\n`[Doc]` tasks do not require a testability pattern.\n\n##### 2.9.4 — Anti-Patterns (Rejected)\n\nThe following task decomposition patterns are anti-patterns and MUST be detected and\nrejected during generation. When detected, merge or reformulate the task.\n\n| Anti-Pattern | Detection Rule | Remediation |\n| :--- | :--- | :--- |\n| Interface-only | Task creates a port\u002Finterface without adapter | Merge with adapter task to form Port+Adapter+IT |\n| DTO-only | Task creates DTO without endpoint or service usage | Merge with endpoint\u002Fservice task |\n| Test-only (outside Layer 4) | Task creates test without production code | Merge with corresponding [Dev] task (TDD pair) |\n| Config-only without test | Task creates configuration without verification | Add Config+VerificationTest pattern |\n\nWhen an anti-pattern is detected, log: `\"Anti-pattern detected: \u003Ctype> task reformulated\"`\n\n##### 2.9.5 — Sizing Constraints\n\n| Constraint | Value | Action When Violated |\n| :--- | :--- | :--- |\n| Minimum tasks per story | 3 | Decompose existing tasks further |\n| Maximum tasks per story | 8 | Merge related tasks |\n| Minimum LOC per task | 20 | Merge with adjacent task in same layer |\n| Maximum LOC per task | 300 | Split into 2+ tasks |\n| Recommended LOC per task | 50-150 | Ideal range, no action needed |\n\n**Merge rules:**\n- Tasks below 20 LOC MUST be merged with an adjacent task in the same layer\n- After merging, the resulting task MUST still follow a valid testability pattern\n- If merging would exceed 300 LOC, split differently\n\n**Split rules:**\n- Tasks above 300 LOC MUST be split into 2 or more tasks\n- Each resulting task MUST follow a valid testability pattern\n- Each resulting task MUST have 20-300 LOC\n\n**Story rejection:**\n- A story with fewer than 3 tasks after all merge\u002Fsplit operations MUST be rejected\n  with message: `\"Minimum 3 tasks required, found N\"`\n- A story with more than 8 tasks after all merge\u002Fsplit operations MUST have tasks\n  merged until the count is within range\n\n##### 2.9.6 — Mandatory Test Task\n\nEvery story MUST include at least one of these test-tagged tasks:\n- `[Test] Smoke\u002FE2E: \u003Cteste automatizado validando criterio de aceite principal de ponta a ponta>`\n- `[Test] Integracao: \u003Cteste de integracao validando fluxo completo>`\n\nA story without ANY automated end-to-end validation task is INCOMPLETE and must not be saved.\n\n##### 2.9.7 — Task Tags\n\n- `[Dev]` — Implementation tasks (handler, service, repository, migration)\n- `[Test]` — Test tasks (unit, integration, E2E, performance)\n- `[Doc]` — Documentation tasks (diagrams, wiki, API docs)\n\n### Step 3 — Optional Jira Integration (per story)\n\nAfter generating each story's markdown content but before saving, optionally create the\nstory in Jira.\n\n#### 3.1 — Cascaded from Orchestrator\n\nIf a `jiraContext` was provided by the orchestrator (`x-epic-decompose`) with\n`jiraContext.enabled == true` and `jiraContext.cascadeToStories == true`:\n\nFor each story (no additional user prompting needed):\n1. Call `mcp__atlassian__createJiraIssue` to create a Story issue:\n   - `cloudId`: `jiraContext.cloudId`\n   - `projectKey`: `jiraContext.projectKey`\n   - `issueTypeName`: \"Story\"\n   - `summary`: the story title\n   - `description`: the user story text from Section 3 (the \"Como **Persona**...\" paragraph)\n   - `contentFormat`: \"markdown\"\n   - `parent` (optional): `jiraContext.epicIssueKey` — include only if `jiraContext.epicIssueKey` is present; omit entirely when absent (e.g., epic creation failed in Phase B) to avoid MCP errors and maintain non-blocking behavior\n   - `additional_fields`: `{ \"labels\": [{ \"name\": \"generated-by-ia-dev-env\" }, { \"name\": \"story-XXXX-YYYY\" }] }` (where `story-XXXX-YYYY` is the local story ID for bidirectional sync)\n2. Capture the returned Jira issue key\n3. Replace `\u003CCHAVE-JIRA>` in the story markdown with the actual key\n4. Store the mapping `{ storyId -> jiraKey }` for later dependency linking\n\nIf creation fails for a story: log a warning, set `\u003CCHAVE-JIRA>` to `—`, continue\nwith remaining stories.\n\n#### 3.2 — Standalone Invocation (EPIC-0042)\n\nIf no `jiraContext` was provided (skill invoked directly, not via orchestrator):\n\n1. Check if `mcp__atlassian__createJiraIssue` is available. If not available, skip Jira\n   integration entirely — replace all `\u003CCHAVE-JIRA>` with `—`.\n\n2. **Roteamento por flag (EPIC-0042):**\n\n   - Se `--no-jira` estiver presente: pular a integracao com Jira completamente.\n     Substituir todos os `\u003CCHAVE-JIRA>` por `—`. Log:\n     `\"Jira integration skipped (--no-jira, EPIC-0042)\"`. Pular para o Step 4.\n\n   - Se `--jira \u003CPROJECT_KEY>` estiver presente: usar a chave de projeto fornecida\n     diretamente. Pular AskUserQuestion. Descobrir o `cloudId` chamando\n     `mcp__atlassian__getAccessibleAtlassianResources`. Usar o `id` do primeiro site\n     disponivel como `cloudId`. Se a chamada falhar ou nao retornar sites, alertar o\n     usuario e pular a integracao com Jira (substituir todos os `\u003CCHAVE-JIRA>` por `—`).\n     Caso contrario, prosseguir para criar as historias no Jira (step 3d abaixo, usando\n     a chave de projeto fornecida pela flag). Log:\n     `\"Jira integration via --jira flag: project {PROJECT_KEY} (EPIC-0042)\"`\n\n   - Se nenhuma flag estiver presente: prosseguir para o step 3 (prompt interativo\n     compativel com a versao anterior).\n\n3. Use `AskUserQuestion`:\n   ```\n   question: \"Deseja criar as historias no Jira?\"\n   header: \"Jira\"\n   options:\n     - label: \"Sim, criar no Jira\"\n       description: \"Criar cada historia como issue no Jira via MCP\"\n     - label: \"Nao, apenas markdown\"\n       description: \"Gerar apenas os arquivos markdown sem integracao com Jira\"\n   multiSelect: false\n   ```\n\n3a. If \"Sim\":\n   a. Ask for the Jira project key\n   b. Discover the `cloudId` by calling `mcp__atlassian__getAccessibleAtlassianResources`.\n      Use the first available site's `id` as the `cloudId`. If the call fails or returns\n      no sites, warn the user and skip Jira integration (replace all `\u003CCHAVE-JIRA>` with `—`).\n   c. Ask if there is a parent epic in Jira:\n      ```\n      question: \"Existe um epico pai no Jira para vincular as historias? Se sim, informe a chave (ex: PROJ-123). Caso nao exista, deixe em branco ou responda 'Nao'.\"\n      header: \"Epic Link\"\n      ```\n      If the user informs a non-empty value different from \"Nao\", use it as the `parent`.\n      If the answer is empty or \"Nao\", create the stories without a parent link.\n   d. For each story, call `mcp__atlassian__createJiraIssue`:\n      - `cloudId`: the discovered `cloudId`\n      - `projectKey`: the user-provided project key\n      - `issueTypeName`: \"Story\"\n      - `summary`: the story title\n      - `description`: the user story text from Section 3\n      - `contentFormat`: \"markdown\"\n      - `parent` (optional): the epic key from step c, if provided\n      - `additional_fields`: `{ \"labels\": [{ \"name\": \"generated-by-ia-dev-env\" }, { \"name\": \"story-XXXX-YYYY\" }] }` (where `story-XXXX-YYYY` is the local story ID for bidirectional sync)\n\n3b. If \"Nao\": replace all `\u003CCHAVE-JIRA>` with `—` and continue\n\n#### 3.3 — Jira Dependency Linking (second pass)\n\nAfter ALL stories are created and have Jira keys, perform a second pass to create\ndependency links in Jira:\n\nFor each story's \"Blocked By\" list:\n- If the blocking story has a Jira key, call `mcp__atlassian__createIssueLink`:\n  - `cloudId`: the discovered `cloudId` (or `jiraContext.cloudId`)\n  - `type`: \"Blocks\"\n  - `inwardIssue`: the blocker's Jira key (the issue that blocks)\n  - `outwardIssue`: the current story's Jira key (the issue that is blocked)\n- If linking fails: log a warning, continue\n\nThis step is best-effort. Report: \"N dependency links criados no Jira\"\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-2-Generation-Loop ok`\n\n### Step 4 — Quality Gate Validation (pre-write check)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-3-Validation`\n\nBefore writing any story file to disk, run a quality gate evaluation on the generated\nmarkdown content. This step ensures that low-quality stories do not reach the backlog\nwithout refinement.\n\n#### 4.1 — Quality Gate Flag\n\n| Flag | Type | Default | Range | Description |\n|:---|:---|:---|:---|:---|\n| `--quality-threshold` | int | 70 | 0-100 | Minimum score required for a story to be saved |\n\n- Value `0` disables the quality gate entirely (all stories pass)\n- Value `100` requires a perfect score\n\n#### 4.2 — Scoring Dimensions\n\nEvaluate each story against these dimensions (each scored 0-100, then weighted):\n\n| Dimension | Weight | What to Check |\n|:---|:---|:---|\n| Gherkin completeness | 20% | Minimum 4 scenarios, TPP ordering, degenerate cases present, concrete values (not abstractions) |\n| Data contract precision | 20% | All fields typed, M\u002FO flags present, validation rules declared, error codes mapped (RFC 7807) |\n| Task testability | 20% | All [Dev] tasks follow one of 6 valid testability patterns; no anti-patterns (interface-only, DTO-only, test-only outside Layer 4, config-only without test) |\n| Task independence | 10% | Tasks can be implemented and tested independently; circular dependencies between tasks are forbidden; each task produces a verifiable artifact |\n| Dependency consistency | 10% | Blocked By\u002FBlocks cross-references match the Epic index bidirectionally |\n| Diagram coverage | 10% | Sequence diagram present for data-flow stories, deployment diagram for infra stories |\n| Value articulation | 5% | Section 3.5 present with exactly 3 bullets (Valor Principal, Metrica de Sucesso, Impacto no Negocio) using business-perspective language (not technical tasks) |\n| Sub-task completeness | 5% | At least one `[Test]` task, task count between 3-8, all tasks within 20-300 LOC range |\n\n#### 4.3 — Evaluation Flow\n\nFor each generated story (after content generation, before file write):\n\n1. Compute the weighted score across all dimensions\n2. Compare against the `--quality-threshold` (default: 70)\n3. If `score >= threshold`: proceed to file write\n4. If `score \u003C threshold`: enter refinement loop\n\n#### 4.4 — Automatic Refinement Loop\n\nWhen a story fails the quality gate:\n\n1. Display the full quality report with score breakdown and specific action items per dimension\n2. Display: `\"Score N\u002F100 below threshold T. Refining scenarios before proceeding.\"`\n3. Attempt automatic refinement based on the action items:\n   - Add missing degenerate Gherkin scenarios if absent\n   - Add field types to data contract entries missing types\n   - Add boundary value triplets for bounded inputs\n   - Add missing error code mappings\n   - Fix dependency cross-references\n   - Reformulate tasks with anti-patterns (merge interface-only with adapter, etc.)\n   - Merge tasks below 20 LOC with adjacent tasks in same layer\n   - Split tasks above 300 LOC into smaller tasks\n   - Add Section 3.5 if missing, replace technical language with business value\n4. Re-evaluate the refined story\n5. If `score >= threshold`: save the file and report `\"Story refined: oldScore -> newScore (attempt N)\"`\n6. If still below threshold after attempt 1: repeat refinement (attempt 2)\n7. If still below after 2 attempts: display `\"Score still N\u002F100 after 2 refinements. Manual intervention needed.\"` and do NOT save the file\n\nMaximum automatic refinement attempts: **2**\n\n#### 4.5 — Quality Report Format\n\nWhen displaying a quality gate report (on rejection or after refinement), use this format:\n\n```\nQuality Gate Report — story-XXXX-YYYY\nScore: N\u002F100 (threshold: T)\n\n  Gherkin completeness:     NN\u002F100 (weight 20%)\n    - [ACTION] Add degenerate scenario for null input\n    - [ACTION] Reorder scenarios: degenerate before happy path\n  Data contract precision:  NN\u002F100 (weight 20%)\n    - [ACTION] Field 'amount' missing type declaration\n    - [OK] Error codes mapped for all endpoints\n  Task testability:         NN\u002F100 (weight 20%)\n    - [ACTION] TASK-0029-0013-002 uses anti-pattern: interface-only\n    - [OK] 5 of 6 tasks follow valid testability patterns\n  Task independence:        NN\u002F100 (weight 10%)\n    - [OK] No circular dependencies between tasks\n    - [ACTION] TASK-0029-0013-003 cannot be tested without TASK-0029-0013-005\n  Dependency consistency:   NN\u002F100 (weight 10%)\n    - [OK] All cross-references valid\n  Diagram coverage:         NN\u002F100 (weight 10%)\n    - [ACTION] Missing sequence diagram for REST flow\n  Value articulation:       NN\u002F100 (weight 5%)\n    - [OK] Section 3.5 present with 3 business-value bullets\n  Sub-task completeness:    NN\u002F100 (weight 5%)\n    - [OK] 5 tasks within 3-8 range, all within 20-300 LOC\n\nAction items: K issue(s) to resolve\n```\n\n### Step 5 — Save and Report\n\nSave each story as `story-XXXX-YYYY.md` in the same directory as the Epic (inside `ai\u002Fepics\u002Fepic-XXXX\u002F`).\nThe XXXX is the epic number (extracted from the Epic file) and YYYY is the story sequence (from the Epic's index).\nReport: total stories generated, dependency graph summary, any inconsistencies found.\n\nIf Jira integration was active, also report:\n- Stories created in Jira: N of M\n- Dependency links created: K\n- Failures: list any failed items\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-3-Validation ok`\n\n### Step P4 — Commit Planning Artifacts (EPIC-0049 \u002F RULE-007)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P4-Planning-Commit`\n\nIf `--dry-run` or `--no-commit` is set, log `\"dry-run, skipping commit\"` (dry-run) or `\"orchestrated mode, skipping commit\"` (no-commit) and skip this step entirely.\n\nOtherwise, delegate the commit to `x-commit-planning` so the newly written `ai\u002Fepics\u002Fepic-XXXX\u002Fstory-XXXX-YYYY.md` files are versioned on the canonical `epic\u002F\u003CID>` branch without triggering the code pre-commit chain (format \u002F lint \u002F compile):\n\n    Skill(skill: \"x-commit-planning\",\n          args: \"--scope docs --story-id \u003CXXXX-YYYY> --paths ai\u002Fepics\u002Fepic-\u003CXXXX>\u002Fstory-\u003CXXXX-YYYY>.md --subject \\\"add user story\\\"\")\n\nWhen multiple stories are generated in one invocation, batch them into a single commit by passing all paths at once (comma- or space-separated per `x-commit-planning` contract). Subject becomes `\"add N user stories\"`.\n\nIdempotency: re-executing the skill with identical inputs produces `commitSha=null` (silent no-op). The contract is enforced by `x-commit-planning` itself.\n\nOn `COMMIT_FAILED` (exit 4 from `x-commit-planning`), abort the workflow with the same error code so operators receive a single, unambiguous signal.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P4-Planning-Commit ok`\n\n### Step P5 — Push to Origin (optional, EPIC-0049)\n\n\u003C!-- TELEMETRY: phase.start -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh start x-story-create Phase-P5-Push`\n\nIf `--dry-run` or `--no-commit` is set, log `\"dry-run, skipping push\"` \u002F `\"orchestrated mode, skipping push\"` and skip.\n\nDelegate the push to `x-push-branch` so the canonical `epic\u002F\u003CID>` branch is synchronized with origin:\n\n    Skill(skill: \"x-push-branch\", args: \"--branch epic\u002F\u003CXXXX>\")\n\nOn push failure (remote rejection, no connectivity), log a WARNING and continue — the local commit is preserved; the operator can re-run Step P5 or `git push` manually. Do NOT abort.\n\n\u003C!-- TELEMETRY: phase.end -->\nBash command: `$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Ftelemetry-phase.sh end x-story-create Phase-P5-Push ok`\n\n## Sizing Heuristics\n\n**Too big** (split it):\n- More than 2 endpoints in one story\n- More than 1 protocol flow (e.g., X200 + X420)\n- More than 8 Gherkin scenarios\n- More than 10 sub-tasks\n\n**Too small** (merge it):\n- No testable endpoint or flow\n- Less than 4 Gherkin scenarios\n- Could be a sub-task of another story\n\n**Just right**:\n- 1 clear capability, 4-8 Gherkin scenarios, 4-8 sub-tasks\n- Produces testable artifacts (endpoint, handler, migration)\n\n## Error Handling\n\n| Scenario | Action |\n|----------|--------|\n| Template file missing | Abort with message: \"Template _TEMPLATE-STORY.md not found\" |\n| Epic file missing or unparseable | Abort with message: \"Epic file not found or invalid format\" |\n| Spec file missing | Abort with message: \"Specification file not found\" |\n| Circular dependency detected | Warn and list the cycle; proceed with best-effort ordering |\n| Quality gate failure after 2 retries | Skip story, report: \"Manual intervention needed\" |\n| Jira MCP unavailable | Replace `\u003CCHAVE-JIRA>` with `—`, continue without Jira |\n| Jira issue creation fails | Log warning, set `\u003CCHAVE-JIRA>` to `—`, continue with next story |\n| `x-internal-ensure-epic-branch` fails (Step P2) | Abort with `EPIC_BRANCH_ENSURE_FAILED`; canonical branch is required for versioning |\n| `x-commit-planning` exit 4 (Step P4) | Abort with `COMMIT_FAILED`; story file(s) already written but not versioned |\n| `x-commit-planning` exit 0 + `noOp=true` (Step P4) | Silent no-op — re-execution idempotency confirmed; continue to Step P5 |\n| `x-push-branch` fails (Step P5) | WARN only; local commit preserved; operator re-runs manually |\n| `--dry-run` set | Steps P4 and P5 become no-ops with log line `\"dry-run, skipping commit\"` \u002F `\"dry-run, skipping push\"` |\n| `--no-commit` set | Steps P2, P4 and P5 become no-ops — parent orchestrator owns branch + commit lifecycle |\n\n## Common Mistakes\n\n- **Vague data contracts**: \"Enviar dados do cartao\" is useless. The contract must list every field with type, format, and mandatory flag\n- **Abstract Gherkin**: \"DADO que o sistema esta funcionando\" tests nothing. Use concrete preconditions\n- **Missing error scenarios**: Every story should have at least 2 error Gherkin scenarios\n- **Inconsistent dependencies**: If story-0001-0003 says \"Blocked By: story-0001-0002\" but story-0001-0002 does not list story-0001-0003 in Blocks, there is a bug\n- **Copy-paste from spec without adaptation**: The spec describes the system. The story describes the work. Reframe from \"the system does X\" to \"implement X so that Y\"\n- **Missing degenerate cases**: Every story must test null\u002Fempty\u002Fzero inputs. If the story has parameters, there must be at least one degenerate scenario\n- **Boundary values without triplet**: A single \"big number\" test is insufficient. Use the triplet pattern: at-min, at-max, past-max\n- **Happy-path-first ordering**: Degenerate cases must appear before happy paths (TPP ordering). Reorder if needed\n- **Under-counting scenarios**: The minimum is 4 scenarios per story. If only happy + 1 error exist, add degenerate and boundary scenarios\n\n## Integration Notes\n\n| Skill | Relationship | Context |\n|-------|-------------|---------|\n| x-epic-create | produces | Produces the Epic file read by this skill |\n| x-epic-decompose | called-by | Orchestrator invokes x-story-create in Phase C |\n| x-epic-map | reads | Implementation Map reads generated story files |\n| x-create-jira-stories | calls | Creates Jira issues from generated story files |\n| x-manage-worktrees | calls (Step P1) | Detect-context (EPIC-0049 \u002F RULE-001) |\n| x-internal-ensure-epic-branch | calls (Step P2) | Ensure `epic\u002F\u003CID>` exists locally + origin (EPIC-0049 \u002F RULE-001) |\n| x-commit-planning | calls (Step P4) | Batch-commit story file(s) without code pre-commit chain (EPIC-0049 \u002F RULE-007) |\n| x-push-branch | calls (Step P5) | Push canonical epic branch to origin (optional) |\n| story-planning | reads | Reads decomposition guide and Gherkin rules |\n\n## Knowledge Pack References\n\n| Knowledge Pack | Usage |\n|----------------|-------|\n| story-planning | Decomposition philosophy, sizing heuristics, TPP ordering |\n\n## Examples\n\n```\n# Default — v2 template (EPIC-0070 default)\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md\")\n\n# With quality threshold override\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --quality-threshold 80\")\n\n# Legacy v1 template during deprecation window (Rule 19)\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --legacy-template-v1\")\n# → Emits: WARN [legacy-template] --legacy-template-v1 is DEPRECATED...\n\n# Orchestrator mode — parent handles branch + commit\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --no-commit\")\n\n# With Jira integration\nSkill(skill: \"x-internal-create-story\", args: \"specs\u002Fmy-spec.md ai\u002Fepics\u002Fepic-0072\u002Fepic-0072.md --jira PROJ\")\n```\n",{"name":5,"model":24,"visibility":25,"description":7,"allowed-tools":26,"context-budget":27,"user-invocable":20,"requires-capabilities":28},"sonnet","internal","Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, Skill","heavy",[],"main","952a630c6f38d193a349d86fa18db1de8843e837","src\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-event-driven\u002F.claude\u002Fskills\u002Fx-internal-create-story",1,"https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment","https:\u002F\u002Fgithub.com\u002Freview-bench","https:\u002F\u002Freview-bench.ai","An open benchmark for AI code review.","2026-10-27 06:56:37",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-create-story",{"tool":44,"command":45},"bunx","bunx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-create-story",{"tool":47,"command":48},"pnpm","pnpm dlx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-create-story","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-event-driven\u002F.claude\u002Fskills\u002Fx-internal-create-story\u002FSKILL.md",true,[52],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"README.md","REFERENCE","参考文档",1992,"https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-event-driven\u002F.claude\u002Fskills\u002Fx-internal-create-story\u002FREADME.md",[59,66,73,80,87,94],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M757M8J48TQ1Y3X25GSJBXAS","x-parallel-eval","Detects and classifies file-collision risks between work units (tasks, stories, or epic phases) before parallel execution. Reads ## File Footprint blocks produced by x-task-plan \u002F x-story-plan, applies the parallelism-heuristics knowledge pack (hard \u002F regen \u002F soft categories + hotspot overrides), and emits a collision matrix + serialization recommendation in Markdown (default) or JSON.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fx-parallel-eval\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M757M57XMR9546S69466HDWT","parallelism-heuristics","Canonical catalog of file-collision heuristics for parallel task, story, and epic execution. Defines the File Footprint block format, the three Conflict Categories (hard \u002F regen \u002F soft), a hotspot list of high-contention paths, and the degrade-with-warning policy. Consumed by x-task-plan, x-story-plan, x-epic-map, x-parallel-eval, and x-dev-*-implement.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fparallelism-heuristics\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M757M11SZ8P1VCQABT08QVYA","x-watch-pr-ci","Polls a PR's CI checks and Copilot review status, blocking until checks complete or timeout. Returns one of 8 stable exit codes (SUCCESS=0, CI_PENDING_PROCEED=10, CI_FAILED=20, TIMEOUT=30, PR_ALREADY_MERGED=40, NO_CI_CONFIGURED=50, PR_CLOSED=60, PR_NOT_FOUND=70). Writes a versioned state-file for session resume.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-watch-pr-ci\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M757KW53K8KFPGADFB4PH949","x-validate-docs","Documentation freshness gate: validates 6 dimensions (readme, api-specs, grpc-proto, adr, skill-docs, system-architecture) against code changes in a PR. Stack-aware — only validates targets declared\u002Fauto-detected from ProjectConfig.documentation.targets. Returns exit non-zero on staleness; produces structured report.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-validate-docs\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M757KQZHSA10MKC0CR571D60","x-update-system-architecture","Incrementally updates docs\u002Farchitecture\u002Fsystem.md after an epic completes. Appends new entries to the Decision Log (§11) using x-internal-write-report --append (dedup by ## ID: marker) and surgically inserts component\u002Fintegration changes into sections 1-10 via Edit. Idempotent: re-running with the same epic produces a byte-identical system.md.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-update-system-architecture\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M757KKBT5Q1SVF8DMJBVF46M","x-update-architecture","Incrementally updates the service architecture document with changes from architecture plans. Adds new components, integrations, flows, and ADR references without rewriting existing content. Use after implementation to keep architecture documentation current.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-update-architecture\u002FSKILL.md",[],[]]