[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M757BZP62PBN70FEFHM1EDZT":3,"skill-same:01M757BZP62PBN70FEFHM1EDZT":59},{"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":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M757BZP62PBN70FEFHM1EDZT","x-internal-write-story-report",null,"Generates the final consolidated story-completion report by reading ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json, collecting per-task status and commitSha, PR metadata (prNumber, prState), coverage delta, and review findings, then rendering the output via x-internal-write-report with _TEMPLATE-STORY-COMPLETION-REPORT.md to the caller-specified --output path. Eighth skill in the x-internal-* convention and the fifth under internal\u002Fplan\u002F (after x-internal-load-story-context, x-internal-build-story-plan, x-internal-verify-story, and x-internal-resume-story). Read-only against state; writes only to --output via x-internal-write-report.","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\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-internal-write-story-report\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: x-internal-write-story-report\ndescription: \"Generates the final consolidated story-completion report by reading ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json, collecting per-task status and commitSha, PR metadata (prNumber, prState), coverage delta, and review findings, then rendering the output via x-internal-write-report with _TEMPLATE-STORY-COMPLETION-REPORT.md to the caller-specified --output path. Eighth skill in the x-internal-* convention and the fifth under internal\u002Fplan\u002F (after x-internal-load-story-context, x-internal-build-story-plan, x-internal-verify-story, and x-internal-resume-story). Read-only against state; writes only to --output via x-internal-write-report.\"\nvisibility: internal\nuser-invocable: false\nallowed-tools: Bash, Skill\nargument-hint: \"--story-id \u003Cstory-XXXX-YYYY> --epic-id \u003CXXXX> --output \u003Cpath>\"\ncategory: internal-plan\ncontext-budget: heavy\nrequires-capabilities: []\n---\n\n## Global Output Policy\n\n- **Language**: English ONLY.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers and greetings to save tokens.\n\n> 🔒 **INTERNAL SKILL**\n> Esta skill é invocada apenas por outras skills (orquestradores).\n> NÃO é destinada a invocação direta pelo usuário.\n> Caller principal: x-implement-story (Phase 3 carve-out — final report).\n> Oitava skill da convenção `x-internal-*` (após x-internal-update-status\n> pilot 0049-0005, x-internal-write-report 0049-0006,\n> x-internal-normalize-args 0049-0007, x-internal-load-story-context\n> 0049-0011, x-internal-build-story-plan 0049-0012,\n> x-internal-verify-story 0049-0014, e x-internal-resume-story\n> 0049-0013). Quinta skill em `internal\u002Fplan\u002F`: o subdir `plan\u002F` agrupa\n> orquestração de planejamento e verificação da story; esta skill fecha\n> a quíntupla `load → build → verify → resume → report` com o report\n> final consolidado. Difere de `internal\u002Fops\u002F`, cujas sibling skills\n> mutam estado compartilhado (`execution-state`, append-markers); esta\n> skill é **single-writer** para o seu próprio `--output` e delega o\n> render a `x-internal-write-report`.\n\n# Skill: x-internal-write-story-report\n\n## Purpose\n\nCarve out the \"final story report\" block that `x-implement-story`\ncurrently inlines at the end of Phase 3 into a single,\nsingle-responsibility skill. The orchestrator passes three flags\n(`--story-id`, `--epic-id`, `--output`) and consumes a compact\n`{reportPath, summary}` envelope; the skill handles data collection,\ntemplate resolution, and rendering delegation.\n\nResponsibilities (single):\n\n1. Locate and read `ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json`; exit 1\n   (`STATE_NOT_FOUND`) when absent.\n2. Extract the story node (`.stories.\u003Cstory-id>`) and its tasks map.\n3. Compute the `summary` object:\n   - `tasksCount` — total number of tasks under `.stories.\u003Cid>.tasks`.\n   - `tasksDone` — count of tasks whose status matches the DONE\n     synonym set (see Step 2 below).\n   - `commitsCount` — count of distinct `commitSha` values observed\n     across all tasks (null and empty strings excluded).\n   - `prNumber` — the story-level PR number if present; otherwise\n     `null`.\n   - `prState` — normalised PR state (`MERGED`, `OPEN`, `CLOSED`);\n     `null` when no PR exists.\n   - `coverageLine` \u002F `coverageBranch` — percentages from\n     `.stories.\u003Cid>.verification.coverage` when that block exists;\n     `null` when the verification gate has not run.\n4. Build a structured JSON data payload containing the scalar summary\n   plus per-task arrays (`tasks`) and findings arrays (`findings`)\n   sourced from `.stories.\u003Cid>.reviews` when available.\n5. Resolve the template at\n   `.claude\u002Ftemplates\u002F_TEMPLATE-STORY-COMPLETION-REPORT.md`; exit 2\n   (`TEMPLATE_MISSING`) when absent.\n6. Invoke `Skill(skill: \"x-internal-write-report\", …)` with the\n   resolved template, the built payload, and the forwarded `--output`\n   path. On render success, forward `outputPath` to the caller.\n7. Emit the response envelope\n   `{reportPath, summary}` on stdout as a single JSON line.\n\nNon-responsibilities (explicit):\n\n- The skill does NOT mutate `execution-state.json`; it is read-only\n  against the state file (delegation to `x-internal-update-status\n  --read-only` is not required because a single best-effort read is\n  sufficient — downstream `x-internal-write-report` owns the atomic\n  write of the report file).\n- The skill does NOT run tests, coverage, or review dispatch — those\n  values must already be present in the state file (written by\n  `x-internal-verify-story`, `x-review-codebase`, and `x-review-pr`\n  upstream).\n- The skill does NOT create branches, PRs, or mutate git state.\n- The skill does NOT emit telemetry markers — the caller\n  (`x-implement-story` Phase 3) owns the phase boundary.\n- The skill does NOT implement its own render engine — it delegates\n  100% of placeholder substitution and `{{#each}}` expansion to\n  `x-internal-write-report`.\n\n## Convention Anchors (x-internal-*)\n\n| Aspect | Value | Rationale |\n| :--- | :--- | :--- |\n| Path | `internal\u002Fplan\u002Fx-internal-write-story-report\u002F` | `internal\u002F` prefix scopes visibility; `plan\u002F` co-locates with the other story-lifecycle carve-outs (`x-internal-load-story-context`, `x-internal-build-story-plan`, `x-internal-verify-story`, `x-internal-resume-story`) |\n| Frontmatter `visibility` | `internal` | Generator filters these from `\u002Fhelp` menu |\n| Frontmatter `user-invocable` | `false` | Declarative complement to `visibility: internal` |\n| Body marker | `> 🔒 **INTERNAL SKILL**` block as first non-frontmatter content | Visible to humans browsing the repo; no parsing required |\n| Allowed tools | `Bash, Skill` | `Bash` reads the state file and builds the JSON payload with `jq`; `Skill` dispatches `x-internal-write-report` for rendering. No direct `Write` \u002F `Edit` surface |\n| Naming | `x-internal-{subject}-{action}` | Mirrors Rule 04 skill taxonomy; `story-report` = subject+action |\n\nAudit rule: Rule 22 (Lifecycle Integrity) validates every skill under\n`internal\u002F**` satisfies all 6 anchors above. Violations fail\n`LifecycleIntegrityAuditTest`.\n\n## Triggers\n\nBare-slash form is intentionally omitted — this skill is never\ninvoked by a human typing `\u002Fx-internal-write-story-report` in chat. All\ninvocations follow Rule 13 INLINE-SKILL pattern from a calling\norchestrator:\n\n```markdown\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0001 --epic-id 0049 --output ai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\")\n```\n\n## Parameters\n\n| Parameter | Required | Default | Description |\n| :--- | :--- | :--- | :--- |\n| `--story-id \u003Cid>` | M | — | Story identifier (`story-XXXX-YYYY` canonical form; lowercase-normalised) |\n| `--epic-id \u003Cid>` | M | — | 4-digit epic identifier (`XXXX`) — used to resolve `ai\u002Fepics\u002Fepic-XXXX\u002F` (zero-padded) |\n| `--output \u003Cpath>` | M | — | Target path for the rendered report; forwarded verbatim to `x-internal-write-report --output` |\n\nAll three flags support both `--key value` and `--key=value` forms.\nUnknown or missing required flags exit with `64` (sysexits\n`EX_USAGE`). `--story-id` is validated against\n`^story-[0-9]{4}-[0-9]{4}$`; `--epic-id` is zero-padded to 4 digits\nand validated against `^[0-9]{4}$`.\n\n## Response Contract\n\nOn success the skill writes a single-line JSON object to stdout:\n\n| Field | Type | Always Present | Description |\n| :--- | :--- | :--- | :--- |\n| `reportPath` | `String` | yes | Absolute path of the written report (echoed from `x-internal-write-report`) |\n| `summary` | `Object` | yes | Compact summary used by the orchestrator for final logging (see sub-schema below) |\n\n### `summary` sub-schema\n\n| Field | Type | Always Present | Description |\n| :--- | :--- | :--- | :--- |\n| `tasksCount` | `Integer` | yes | Total tasks under `.stories.\u003Cid>.tasks` (0 when map is empty) |\n| `tasksDone` | `Integer` | yes | Subset of `tasksCount` in the DONE synonym set |\n| `commitsCount` | `Integer` | yes | Count of distinct non-empty `commitSha` values across tasks |\n| `prNumber` | `Integer \\| Null` | yes | Story-level PR number; `null` when no PR exists |\n| `prState` | `String \\| Null` | yes | `MERGED`, `OPEN`, or `CLOSED`; `null` when `prNumber=null` |\n| `coverageLine` | `Number \\| Null` | yes | Line-coverage percentage; `null` when verification has not run |\n| `coverageBranch` | `Number \\| Null` | yes | Branch-coverage percentage; `null` when verification has not run |\n\n### Example envelope (happy path)\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":5,\"tasksDone\":5,\"commitsCount\":5,\"prNumber\":42,\"prState\":\"MERGED\",\"coverageLine\":96.4,\"coverageBranch\":92.1}}\n```\n\n### Example envelope (story without PR — boundary)\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":4,\"tasksDone\":2,\"commitsCount\":2,\"prNumber\":null,\"prState\":null,\"coverageLine\":null,\"coverageBranch\":null}}\n```\n\n## Exit Codes\n\n| Code | Name | Condition | Message Format |\n| :--- | :--- | :--- | :--- |\n| 0 | SUCCESS | Report rendered and response envelope emitted | — |\n| 1 | STATE_NOT_FOUND | `ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json` missing or unreadable | `State missing: ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json` |\n| 2 | TEMPLATE_MISSING | `.claude\u002Ftemplates\u002F_TEMPLATE-STORY-COMPLETION-REPORT.md` absent | `Template missing: _TEMPLATE-STORY-COMPLETION-REPORT.md` |\n| 64 | EX_USAGE | Unknown or malformed flag | `usage: --story-id \u003Cid> --epic-id \u003Cid> --output \u003Cpath>` |\n| 127 | DEPENDENCY_MISSING | `jq` absent on `PATH` | `dependency missing: jq` |\n\nRender-time failures (e.g., `UNRESOLVED_PLACEHOLDER`) propagate the\n`x-internal-write-report` exit code unchanged so the caller branches\non the original semantic. No envelope is emitted on any non-zero\nexit.\n\n## Workflow\n\n### Step 1 — Argument parsing and path resolution\n\nParse the three flags via a tight `while (($#)); case \"$1\" in …` loop\nto stay within the SkillSizeLinter 500-line budget without delegating\nto `x-internal-normalize-args` (peer skill; same rationale as\n`x-internal-resume-story` §1 of full-protocol).\n\n```bash\nepic_dir=\"ai\u002Fepics\u002Fepic-${epic_id}\"\nstate_file=\"${epic_dir}\u002Fexecution-state.json\"\ntemplate_name=\"_TEMPLATE-STORY-COMPLETION-REPORT.md\"\ntemplate_path=\"${CLAUDE_PROJECT_DIR}\u002F.claude\u002Ftemplates\u002F${template_name}\"\n```\n\nValidate `--output` is not empty and does not contain `..` above the\nproject root (Rule 06 path traversal guard). Reject unknown flags\nwith exit `64`.\n\n### Step 2 — Read execution-state.json (single best-effort read)\n\n```bash\nif [[ ! -r \"${state_file}\" ]]; then\n  echo \"State missing: ${state_file}\" >&2\n  exit 1\nfi\n```\n\nParse the story node:\n\n```bash\nstory_json=$(jq --arg sid \"${story_id}\" '.stories[$sid] \u002F\u002F null' \"${state_file}\")\nif [[ \"${story_json}\" == \"null\" ]]; then\n  echo \"Story ${story_id} not present in state file\" >&2\n  exit 1\nfi\n```\n\nA story absent from the state file degrades to exit 1 (same as\nmissing state) — consumers distinguish via the stderr message, not\nthe exit code.\n\n### Step 3 — Compute summary fields\n\nTasks classification uses the same DONE synonym set as\n`x-internal-resume-story` (see references §2):\n\n```text\nDONE synonyms: DONE, MERGED, COMPLETE, Concluída, Concluida, Done, Merged\n```\n\n```bash\ntasks_count=$(echo \"${story_json}\" | jq '.tasks \u002F\u002F {} | length')\ntasks_done=$(echo \"${story_json}\" | jq '\n  [ .tasks \u002F\u002F {} | to_entries[] |\n    select(.value.status as $s |\n      [\"DONE\",\"MERGED\",\"COMPLETE\",\"Concluída\",\"Concluida\",\"Done\",\"Merged\"] |\n      index($s)) ] | length')\ncommits_count=$(echo \"${story_json}\" | jq '\n  [ .tasks \u002F\u002F {} | to_entries[] | .value.commitSha |\n    select(. != null and . != \"\") ] | unique | length')\npr_number=$(echo \"${story_json}\" | jq '.pr.number \u002F\u002F null')\npr_state=$(echo \"${story_json}\" | jq '\n  if .pr.state then (.pr.state | ascii_upcase) else null end')\ncoverage_line=$(echo \"${story_json}\" | jq '.verification.coverage.line \u002F\u002F null')\ncoverage_branch=$(echo \"${story_json}\" | jq '.verification.coverage.branch \u002F\u002F null')\n```\n\n### Step 4 — Build the render payload\n\nAssemble the payload as a single `jq -n` expression so the\n`x-internal-write-report` invocation receives canonical JSON:\n\n```bash\ndata_json=$(jq -nc \\\n  --arg storyId \"${story_id}\" \\\n  --arg epicId \"${epic_id}\" \\\n  --argjson tasksCount \"${tasks_count}\" \\\n  --argjson tasksDone \"${tasks_done}\" \\\n  --argjson commitsCount \"${commits_count}\" \\\n  --argjson prNumber \"${pr_number}\" \\\n  --argjson prState \"$(jq -nc --arg s \"${pr_state}\" 'if $s==\"null\" or $s==\"\" then null else $s end')\" \\\n  --argjson coverageLine \"$95\" \\\n  --argjson coverageBranch \"$90\" \\\n  --argjson tasks \"$(echo \"${story_json}\" | jq '[.tasks \u002F\u002F {} | to_entries[] | {id: .key, status: .value.status, commitSha: (.value.commitSha \u002F\u002F null)}]')\" \\\n  --argjson findings \"$(echo \"${story_json}\" | jq '[.reviews.findings \u002F\u002F [] | .[] | {severity: .severity, title: .title, file: (.file \u002F\u002F null)}]')\" \\\n  '{storyId:$storyId, epicId:$epicId,\n    tasksCount:$tasksCount, tasksDone:$tasksDone,\n    commitsCount:$commitsCount,\n    prNumber:$prNumber, prState:$prState,\n    coverageLine:$coverageLine, coverageBranch:$coverageBranch,\n    tasks:$tasks, findings:$findings}')\n```\n\n### Step 5 — Template existence gate\n\n```bash\nif [[ ! -r \"${template_path}\" ]]; then\n  echo \"Template missing: ${template_name}\" >&2\n  exit 2\nfi\n```\n\nThe pre-check is intentionally local (not delegated to\n`x-internal-write-report`) so the orchestrator gets a distinct\n`TEMPLATE_MISSING` exit code (2) rather than the renderer's\n`TEMPLATE_NOT_FOUND` exit code (1 of that skill). This keeps the\ntwo skills' exit-code spaces non-overlapping.\n\n### Step 6 — Delegate to x-internal-write-report\n\n```markdown\nSkill(skill: \"x-internal-write-report\",\n      args: \"--template _TEMPLATE-STORY-COMPLETION-REPORT.md \\\n             --output ${output_path} \\\n             --data ${data_json}\")\n```\n\nThe renderer handles all placeholder substitution and `{{#each}}`\nloops. Its stdout is a single JSON line matching the\n`x-internal-write-report` response contract\n(`{outputPath, bytesWritten, placeholdersReplaced, entriesAppended}`);\nthis skill reads `outputPath` and discards the rest.\n\n### Step 7 — Emit response envelope\n\n```bash\njq -nc \\\n  --arg reportPath \"${report_path}\" \\\n  --argjson summary \"${summary_json}\" \\\n  '{reportPath:$reportPath, summary:$summary}'\n```\n\nExit 0.\n\n## Examples\n\n### Example 1 — Happy path: fully-done story with merged PR\n\nState snippet for `story-0049-0001`:\n\n```json\n{\n  \"stories\": {\n    \"story-0049-0001\": {\n      \"tasks\": {\n        \"TASK-0049-0001-001\": {\"status\":\"DONE\",\"commitSha\":\"abc123\"},\n        \"TASK-0049-0001-002\": {\"status\":\"DONE\",\"commitSha\":\"def456\"},\n        \"TASK-0049-0001-003\": {\"status\":\"DONE\",\"commitSha\":\"ghi789\"},\n        \"TASK-0049-0001-004\": {\"status\":\"DONE\",\"commitSha\":\"jkl012\"},\n        \"TASK-0049-0001-005\": {\"status\":\"DONE\",\"commitSha\":\"mno345\"}\n      },\n      \"pr\": {\"number\": 42, \"state\": \"MERGED\"},\n      \"verification\": {\"coverage\": {\"line\": 96.4, \"branch\": 92.1}},\n      \"reviews\": {\"findings\": []}\n    }\n  }\n}\n```\n\nInvocation:\n\n```markdown\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0001 --epic-id 0049 --output ai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\")\n```\n\nEnvelope:\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":5,\"tasksDone\":5,\"commitsCount\":5,\"prNumber\":42,\"prState\":\"MERGED\",\"coverageLine\":96.4,\"coverageBranch\":92.1}}\n```\n\nExit: 0.\n\n### Example 2 — Story in progress (3 DONE, 2 PENDING)\n\nThe report is still generated; `summary.tasksDone=3` while\n`summary.tasksCount=5`. The rendered report includes a per-task\nstatus table via the template's `{{#each tasks}}` block. Exit: 0.\n\n### Example 3 — Error: STATE_NOT_FOUND\n\n```bash\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0099 --epic-id 0099 --output \u002Ftmp\u002Fout.md\")\n```\n\nStderr:\n\n```\nState missing: ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json\n```\n\nExit: 1. No envelope emitted.\n\n### Example 4 — Error: TEMPLATE_MISSING\n\nThe state file exists but `_TEMPLATE-STORY-COMPLETION-REPORT.md` is\nnot present under `.claude\u002Ftemplates\u002F`. Stderr:\n\n```\nTemplate missing: _TEMPLATE-STORY-COMPLETION-REPORT.md\n```\n\nExit: 2.\n\n### Example 5 — Boundary: story without PR\n\nState snippet: `\"pr\"` key is absent or `null`.\n\nEnvelope:\n\n```json\n{\"reportPath\":\"…\",\"summary\":{\"tasksCount\":4,\"tasksDone\":2,\"commitsCount\":2,\"prNumber\":null,\"prState\":null,\"coverageLine\":null,\"coverageBranch\":null}}\n```\n\nThe rendered report omits the \"Pull Request\" section because the\ntemplate guards that block on `{{prNumber}}`. Exit: 0.\n\n## Outputs\n\n| Artifact | Path | Description |\n| :--- | :--- | :--- |\n| Rendered report | `\u003C--output>` | Markdown file written via `x-internal-write-report` (atomic tmp+rename) |\n| Response envelope | stdout | Single-line JSON (`reportPath` \u002F `summary`) |\n| Error diagnostic | stderr | Single line, non-empty only on exit ≠ 0 |\n\nNo file is created by this skill directly — every disk mutation is\ndelegated to `x-internal-write-report`, which provides the atomic\nwrite contract.\n\n## Error Handling\n\n| Scenario | Action |\n| :--- | :--- |\n| Missing required flag | Print `usage:` banner to stderr; exit 64 |\n| Unknown flag | Print `unknown flag \u003Cname>; usage:`; exit 64 |\n| `--output` empty or traversal-unsafe | Print `output path unsafe`; exit 64 |\n| `jq` absent on PATH | Print `dependency missing: jq`; exit 127 |\n| `execution-state.json` missing | Exit 1 (`STATE_NOT_FOUND`); no envelope |\n| Story node absent from state | Exit 1; stderr distinguishes via message |\n| `.tasks` key absent | Treat as empty map (`tasksCount=0`); exit 0 |\n| `.pr` key absent | Emit `prNumber=null, prState=null`; exit 0 |\n| `.verification.coverage` absent | Emit `coverageLine=null, coverageBranch=null`; exit 0 |\n| `.reviews.findings` absent | Emit `findings:[]`; exit 0 |\n| Template file absent | Exit 2 (`TEMPLATE_MISSING`); no envelope |\n| `x-internal-write-report` UNRESOLVED_PLACEHOLDER (exit 3) | Propagate exit code 3 unchanged; stderr already populated by renderer |\n| `x-internal-write-report` WRITE_FAILED (exit 4) | Propagate exit code 4 unchanged |\n\n## Performance Contract\n\n- Target: \u003C 500 ms end-to-end for a typical story (5–10 tasks) on a\n  laptop-class machine. Budget breakdown:\n  - Argument parse + state read: \u003C 50 ms\n  - Summary JSON computation (jq): \u003C 100 ms\n  - Payload assembly: \u003C 50 ms\n  - Template resolution: \u003C 10 ms\n  - `x-internal-write-report` invocation: ~200 ms (its own contract)\n  - Envelope emission: \u003C 10 ms\n- Memory bounded by state-file size + 2× payload size; the skill\n  never loads the rendered report into memory.\n- Idempotent under repeated invocations with identical state file\n  and `--output` path (the renderer's atomic tmp+rename contract).\n\n## Testing\n\nStory-0049-0015 ships the following acceptance test scenarios,\nmirroring Section 7 of the story file:\n\n1. **Happy path** — state with 5 DONE tasks and merged PR renders\n   the full report; `summary.tasksCount=5`, `summary.prState=MERGED`.\n2. **Story in progress** — 3 DONE + 2 PENDING renders a report with\n   per-task status; `summary.tasksDone=3`, `summary.tasksCount=5`.\n3. **Error — STATE_NOT_FOUND** — missing state file → exit 1, no\n   envelope, stderr matches.\n4. **Error — TEMPLATE_MISSING** — template absent → exit 2, no\n   envelope, stderr matches.\n5. **Boundary — story sem PR** — `.pr` absent → `prNumber=null`,\n   `prState=null`, rendered report omits the \"Pull Request\" section.\n\nGoldens live under\n`src\u002Ftest\u002Fresources\u002Fgolden\u002Finternal\u002Fplan\u002Fx-internal-write-story-report\u002F`\nand lock the SKILL.md rendering (per EPIC-0049 convention: generator\ncopies internal skills into `.claude\u002Fskills\u002F` flat layout but filters\nthem from `\u002Fhelp` — goldens validate the source, not the flattened\noutput).\n\nCoverage requirement: ≥ 95% line \u002F ≥ 90% branch across the invoking\nBash codepaths (DoD Global).\n\n## Generator Filter Contract\n\nThe `ia-dev-env` generator MUST exclude skills with\n`visibility: internal` from:\n\n1. The `.claude\u002FREADME.md` skill-inventory table.\n2. The `\u002Fhelp` menu listing surfaced by Claude Code.\n3. User-facing autocomplete in the chat input.\n\nInternal skills are still copied into `.claude\u002Fskills\u002F` (flat layout)\nso `Skill(skill: \"x-internal-write-story-report\")` invocations from other\nskills resolve correctly. The invariant: **user cannot see it;\norchestrators can invoke it.**\n\n## Telemetry\n\nInternal skills DO NOT emit `phase.start` \u002F `phase.end` markers —\ntelemetry is produced by the invoking orchestrator (the `phase`\nwrapping the orchestrator's own step — Phase 3 in this case — is\nthe correct aggregation boundary). Passive hooks still capture\n`tool.call` for the underlying `Bash` invocations (`jq`) and the\nnested `Skill(x-internal-write-report)` dispatch.\n\nReference: Rule 13 (Skill Invocation Protocol), Rule 22 (Lifecycle\nIntegrity Audit), ADR-0010 (Interactive Gates Convention — exempts\ninternal skills from the 3-option menu contract).\n\n## Integration Notes\n\n| Skill | Relationship | Context |\n| :--- | :--- | :--- |\n| `x-implement-story` | caller (primary) | Phase 3 final-report carve-out: orchestrator passes `--story-id --epic-id --output` and consumes `{reportPath, summary}` |\n| `x-internal-write-report` | downstream (delegated render) | Resolves `{{KEY}}` placeholders and `{{#each tasks}} \u002F {{#each findings}}` loops against the payload built in Step 4 |\n| `x-internal-update-status` | peer (read-only consumer) | Both read `execution-state.json`; this skill does NOT write to it |\n| `x-internal-verify-story` | upstream producer | Writes `.verification.coverage` consumed in Step 3 |\n| `x-internal-resume-story` | peer | Shares the DONE synonym set and task-classification logic; no runtime coupling |\n| `x-review-codebase` \u002F `x-review-pr` | upstream producers | Write `.reviews.findings` consumed in Step 4 |\n| `x-reconcile-status` | downstream reader | May read the rendered report for epic-wide status reconciliation (never mutates concurrently) |\n\nDownstream story that depends on this skill: story-0049-0019\n(orchestrator consumes the envelope and deletes the inline Phase 3\nfinal-report block).\n\nFull workflow detail (argument-parser rejection matrix, summary\ncomputation edge cases, render-payload schema contract with the\ntemplate, PR-state normalisation rules, performance profiling on\nlarge stories, and the forward-compatibility policy for new\n`summary` fields) lives in\n[`references\u002Ffull-protocol.md`](references\u002Ffull-protocol.md) per\nADR-0011.\n","## Global Output Policy\n\n- **Language**: English ONLY.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers and greetings to save tokens.\n\n> 🔒 **INTERNAL SKILL**\n> Esta skill é invocada apenas por outras skills (orquestradores).\n> NÃO é destinada a invocação direta pelo usuário.\n> Caller principal: x-implement-story (Phase 3 carve-out — final report).\n> Oitava skill da convenção `x-internal-*` (após x-internal-update-status\n> pilot 0049-0005, x-internal-write-report 0049-0006,\n> x-internal-normalize-args 0049-0007, x-internal-load-story-context\n> 0049-0011, x-internal-build-story-plan 0049-0012,\n> x-internal-verify-story 0049-0014, e x-internal-resume-story\n> 0049-0013). Quinta skill em `internal\u002Fplan\u002F`: o subdir `plan\u002F` agrupa\n> orquestração de planejamento e verificação da story; esta skill fecha\n> a quíntupla `load → build → verify → resume → report` com o report\n> final consolidado. Difere de `internal\u002Fops\u002F`, cujas sibling skills\n> mutam estado compartilhado (`execution-state`, append-markers); esta\n> skill é **single-writer** para o seu próprio `--output` e delega o\n> render a `x-internal-write-report`.\n\n# Skill: x-internal-write-story-report\n\n## Purpose\n\nCarve out the \"final story report\" block that `x-implement-story`\ncurrently inlines at the end of Phase 3 into a single,\nsingle-responsibility skill. The orchestrator passes three flags\n(`--story-id`, `--epic-id`, `--output`) and consumes a compact\n`{reportPath, summary}` envelope; the skill handles data collection,\ntemplate resolution, and rendering delegation.\n\nResponsibilities (single):\n\n1. Locate and read `ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json`; exit 1\n   (`STATE_NOT_FOUND`) when absent.\n2. Extract the story node (`.stories.\u003Cstory-id>`) and its tasks map.\n3. Compute the `summary` object:\n   - `tasksCount` — total number of tasks under `.stories.\u003Cid>.tasks`.\n   - `tasksDone` — count of tasks whose status matches the DONE\n     synonym set (see Step 2 below).\n   - `commitsCount` — count of distinct `commitSha` values observed\n     across all tasks (null and empty strings excluded).\n   - `prNumber` — the story-level PR number if present; otherwise\n     `null`.\n   - `prState` — normalised PR state (`MERGED`, `OPEN`, `CLOSED`);\n     `null` when no PR exists.\n   - `coverageLine` \u002F `coverageBranch` — percentages from\n     `.stories.\u003Cid>.verification.coverage` when that block exists;\n     `null` when the verification gate has not run.\n4. Build a structured JSON data payload containing the scalar summary\n   plus per-task arrays (`tasks`) and findings arrays (`findings`)\n   sourced from `.stories.\u003Cid>.reviews` when available.\n5. Resolve the template at\n   `.claude\u002Ftemplates\u002F_TEMPLATE-STORY-COMPLETION-REPORT.md`; exit 2\n   (`TEMPLATE_MISSING`) when absent.\n6. Invoke `Skill(skill: \"x-internal-write-report\", …)` with the\n   resolved template, the built payload, and the forwarded `--output`\n   path. On render success, forward `outputPath` to the caller.\n7. Emit the response envelope\n   `{reportPath, summary}` on stdout as a single JSON line.\n\nNon-responsibilities (explicit):\n\n- The skill does NOT mutate `execution-state.json`; it is read-only\n  against the state file (delegation to `x-internal-update-status\n  --read-only` is not required because a single best-effort read is\n  sufficient — downstream `x-internal-write-report` owns the atomic\n  write of the report file).\n- The skill does NOT run tests, coverage, or review dispatch — those\n  values must already be present in the state file (written by\n  `x-internal-verify-story`, `x-review-codebase`, and `x-review-pr`\n  upstream).\n- The skill does NOT create branches, PRs, or mutate git state.\n- The skill does NOT emit telemetry markers — the caller\n  (`x-implement-story` Phase 3) owns the phase boundary.\n- The skill does NOT implement its own render engine — it delegates\n  100% of placeholder substitution and `{{#each}}` expansion to\n  `x-internal-write-report`.\n\n## Convention Anchors (x-internal-*)\n\n| Aspect | Value | Rationale |\n| :--- | :--- | :--- |\n| Path | `internal\u002Fplan\u002Fx-internal-write-story-report\u002F` | `internal\u002F` prefix scopes visibility; `plan\u002F` co-locates with the other story-lifecycle carve-outs (`x-internal-load-story-context`, `x-internal-build-story-plan`, `x-internal-verify-story`, `x-internal-resume-story`) |\n| Frontmatter `visibility` | `internal` | Generator filters these from `\u002Fhelp` menu |\n| Frontmatter `user-invocable` | `false` | Declarative complement to `visibility: internal` |\n| Body marker | `> 🔒 **INTERNAL SKILL**` block as first non-frontmatter content | Visible to humans browsing the repo; no parsing required |\n| Allowed tools | `Bash, Skill` | `Bash` reads the state file and builds the JSON payload with `jq`; `Skill` dispatches `x-internal-write-report` for rendering. No direct `Write` \u002F `Edit` surface |\n| Naming | `x-internal-{subject}-{action}` | Mirrors Rule 04 skill taxonomy; `story-report` = subject+action |\n\nAudit rule: Rule 22 (Lifecycle Integrity) validates every skill under\n`internal\u002F**` satisfies all 6 anchors above. Violations fail\n`LifecycleIntegrityAuditTest`.\n\n## Triggers\n\nBare-slash form is intentionally omitted — this skill is never\ninvoked by a human typing `\u002Fx-internal-write-story-report` in chat. All\ninvocations follow Rule 13 INLINE-SKILL pattern from a calling\norchestrator:\n\n```markdown\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0001 --epic-id 0049 --output ai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\")\n```\n\n## Parameters\n\n| Parameter | Required | Default | Description |\n| :--- | :--- | :--- | :--- |\n| `--story-id \u003Cid>` | M | — | Story identifier (`story-XXXX-YYYY` canonical form; lowercase-normalised) |\n| `--epic-id \u003Cid>` | M | — | 4-digit epic identifier (`XXXX`) — used to resolve `ai\u002Fepics\u002Fepic-XXXX\u002F` (zero-padded) |\n| `--output \u003Cpath>` | M | — | Target path for the rendered report; forwarded verbatim to `x-internal-write-report --output` |\n\nAll three flags support both `--key value` and `--key=value` forms.\nUnknown or missing required flags exit with `64` (sysexits\n`EX_USAGE`). `--story-id` is validated against\n`^story-[0-9]{4}-[0-9]{4}$`; `--epic-id` is zero-padded to 4 digits\nand validated against `^[0-9]{4}$`.\n\n## Response Contract\n\nOn success the skill writes a single-line JSON object to stdout:\n\n| Field | Type | Always Present | Description |\n| :--- | :--- | :--- | :--- |\n| `reportPath` | `String` | yes | Absolute path of the written report (echoed from `x-internal-write-report`) |\n| `summary` | `Object` | yes | Compact summary used by the orchestrator for final logging (see sub-schema below) |\n\n### `summary` sub-schema\n\n| Field | Type | Always Present | Description |\n| :--- | :--- | :--- | :--- |\n| `tasksCount` | `Integer` | yes | Total tasks under `.stories.\u003Cid>.tasks` (0 when map is empty) |\n| `tasksDone` | `Integer` | yes | Subset of `tasksCount` in the DONE synonym set |\n| `commitsCount` | `Integer` | yes | Count of distinct non-empty `commitSha` values across tasks |\n| `prNumber` | `Integer \\| Null` | yes | Story-level PR number; `null` when no PR exists |\n| `prState` | `String \\| Null` | yes | `MERGED`, `OPEN`, or `CLOSED`; `null` when `prNumber=null` |\n| `coverageLine` | `Number \\| Null` | yes | Line-coverage percentage; `null` when verification has not run |\n| `coverageBranch` | `Number \\| Null` | yes | Branch-coverage percentage; `null` when verification has not run |\n\n### Example envelope (happy path)\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":5,\"tasksDone\":5,\"commitsCount\":5,\"prNumber\":42,\"prState\":\"MERGED\",\"coverageLine\":96.4,\"coverageBranch\":92.1}}\n```\n\n### Example envelope (story without PR — boundary)\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":4,\"tasksDone\":2,\"commitsCount\":2,\"prNumber\":null,\"prState\":null,\"coverageLine\":null,\"coverageBranch\":null}}\n```\n\n## Exit Codes\n\n| Code | Name | Condition | Message Format |\n| :--- | :--- | :--- | :--- |\n| 0 | SUCCESS | Report rendered and response envelope emitted | — |\n| 1 | STATE_NOT_FOUND | `ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json` missing or unreadable | `State missing: ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json` |\n| 2 | TEMPLATE_MISSING | `.claude\u002Ftemplates\u002F_TEMPLATE-STORY-COMPLETION-REPORT.md` absent | `Template missing: _TEMPLATE-STORY-COMPLETION-REPORT.md` |\n| 64 | EX_USAGE | Unknown or malformed flag | `usage: --story-id \u003Cid> --epic-id \u003Cid> --output \u003Cpath>` |\n| 127 | DEPENDENCY_MISSING | `jq` absent on `PATH` | `dependency missing: jq` |\n\nRender-time failures (e.g., `UNRESOLVED_PLACEHOLDER`) propagate the\n`x-internal-write-report` exit code unchanged so the caller branches\non the original semantic. No envelope is emitted on any non-zero\nexit.\n\n## Workflow\n\n### Step 1 — Argument parsing and path resolution\n\nParse the three flags via a tight `while (($#)); case \"$1\" in …` loop\nto stay within the SkillSizeLinter 500-line budget without delegating\nto `x-internal-normalize-args` (peer skill; same rationale as\n`x-internal-resume-story` §1 of full-protocol).\n\n```bash\nepic_dir=\"ai\u002Fepics\u002Fepic-${epic_id}\"\nstate_file=\"${epic_dir}\u002Fexecution-state.json\"\ntemplate_name=\"_TEMPLATE-STORY-COMPLETION-REPORT.md\"\ntemplate_path=\"${CLAUDE_PROJECT_DIR}\u002F.claude\u002Ftemplates\u002F${template_name}\"\n```\n\nValidate `--output` is not empty and does not contain `..` above the\nproject root (Rule 06 path traversal guard). Reject unknown flags\nwith exit `64`.\n\n### Step 2 — Read execution-state.json (single best-effort read)\n\n```bash\nif [[ ! -r \"${state_file}\" ]]; then\n  echo \"State missing: ${state_file}\" >&2\n  exit 1\nfi\n```\n\nParse the story node:\n\n```bash\nstory_json=$(jq --arg sid \"${story_id}\" '.stories[$sid] \u002F\u002F null' \"${state_file}\")\nif [[ \"${story_json}\" == \"null\" ]]; then\n  echo \"Story ${story_id} not present in state file\" >&2\n  exit 1\nfi\n```\n\nA story absent from the state file degrades to exit 1 (same as\nmissing state) — consumers distinguish via the stderr message, not\nthe exit code.\n\n### Step 3 — Compute summary fields\n\nTasks classification uses the same DONE synonym set as\n`x-internal-resume-story` (see references §2):\n\n```text\nDONE synonyms: DONE, MERGED, COMPLETE, Concluída, Concluida, Done, Merged\n```\n\n```bash\ntasks_count=$(echo \"${story_json}\" | jq '.tasks \u002F\u002F {} | length')\ntasks_done=$(echo \"${story_json}\" | jq '\n  [ .tasks \u002F\u002F {} | to_entries[] |\n    select(.value.status as $s |\n      [\"DONE\",\"MERGED\",\"COMPLETE\",\"Concluída\",\"Concluida\",\"Done\",\"Merged\"] |\n      index($s)) ] | length')\ncommits_count=$(echo \"${story_json}\" | jq '\n  [ .tasks \u002F\u002F {} | to_entries[] | .value.commitSha |\n    select(. != null and . != \"\") ] | unique | length')\npr_number=$(echo \"${story_json}\" | jq '.pr.number \u002F\u002F null')\npr_state=$(echo \"${story_json}\" | jq '\n  if .pr.state then (.pr.state | ascii_upcase) else null end')\ncoverage_line=$(echo \"${story_json}\" | jq '.verification.coverage.line \u002F\u002F null')\ncoverage_branch=$(echo \"${story_json}\" | jq '.verification.coverage.branch \u002F\u002F null')\n```\n\n### Step 4 — Build the render payload\n\nAssemble the payload as a single `jq -n` expression so the\n`x-internal-write-report` invocation receives canonical JSON:\n\n```bash\ndata_json=$(jq -nc \\\n  --arg storyId \"${story_id}\" \\\n  --arg epicId \"${epic_id}\" \\\n  --argjson tasksCount \"${tasks_count}\" \\\n  --argjson tasksDone \"${tasks_done}\" \\\n  --argjson commitsCount \"${commits_count}\" \\\n  --argjson prNumber \"${pr_number}\" \\\n  --argjson prState \"$(jq -nc --arg s \"${pr_state}\" 'if $s==\"null\" or $s==\"\" then null else $s end')\" \\\n  --argjson coverageLine \"$95\" \\\n  --argjson coverageBranch \"$90\" \\\n  --argjson tasks \"$(echo \"${story_json}\" | jq '[.tasks \u002F\u002F {} | to_entries[] | {id: .key, status: .value.status, commitSha: (.value.commitSha \u002F\u002F null)}]')\" \\\n  --argjson findings \"$(echo \"${story_json}\" | jq '[.reviews.findings \u002F\u002F [] | .[] | {severity: .severity, title: .title, file: (.file \u002F\u002F null)}]')\" \\\n  '{storyId:$storyId, epicId:$epicId,\n    tasksCount:$tasksCount, tasksDone:$tasksDone,\n    commitsCount:$commitsCount,\n    prNumber:$prNumber, prState:$prState,\n    coverageLine:$coverageLine, coverageBranch:$coverageBranch,\n    tasks:$tasks, findings:$findings}')\n```\n\n### Step 5 — Template existence gate\n\n```bash\nif [[ ! -r \"${template_path}\" ]]; then\n  echo \"Template missing: ${template_name}\" >&2\n  exit 2\nfi\n```\n\nThe pre-check is intentionally local (not delegated to\n`x-internal-write-report`) so the orchestrator gets a distinct\n`TEMPLATE_MISSING` exit code (2) rather than the renderer's\n`TEMPLATE_NOT_FOUND` exit code (1 of that skill). This keeps the\ntwo skills' exit-code spaces non-overlapping.\n\n### Step 6 — Delegate to x-internal-write-report\n\n```markdown\nSkill(skill: \"x-internal-write-report\",\n      args: \"--template _TEMPLATE-STORY-COMPLETION-REPORT.md \\\n             --output ${output_path} \\\n             --data ${data_json}\")\n```\n\nThe renderer handles all placeholder substitution and `{{#each}}`\nloops. Its stdout is a single JSON line matching the\n`x-internal-write-report` response contract\n(`{outputPath, bytesWritten, placeholdersReplaced, entriesAppended}`);\nthis skill reads `outputPath` and discards the rest.\n\n### Step 7 — Emit response envelope\n\n```bash\njq -nc \\\n  --arg reportPath \"${report_path}\" \\\n  --argjson summary \"${summary_json}\" \\\n  '{reportPath:$reportPath, summary:$summary}'\n```\n\nExit 0.\n\n## Examples\n\n### Example 1 — Happy path: fully-done story with merged PR\n\nState snippet for `story-0049-0001`:\n\n```json\n{\n  \"stories\": {\n    \"story-0049-0001\": {\n      \"tasks\": {\n        \"TASK-0049-0001-001\": {\"status\":\"DONE\",\"commitSha\":\"abc123\"},\n        \"TASK-0049-0001-002\": {\"status\":\"DONE\",\"commitSha\":\"def456\"},\n        \"TASK-0049-0001-003\": {\"status\":\"DONE\",\"commitSha\":\"ghi789\"},\n        \"TASK-0049-0001-004\": {\"status\":\"DONE\",\"commitSha\":\"jkl012\"},\n        \"TASK-0049-0001-005\": {\"status\":\"DONE\",\"commitSha\":\"mno345\"}\n      },\n      \"pr\": {\"number\": 42, \"state\": \"MERGED\"},\n      \"verification\": {\"coverage\": {\"line\": 96.4, \"branch\": 92.1}},\n      \"reviews\": {\"findings\": []}\n    }\n  }\n}\n```\n\nInvocation:\n\n```markdown\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0001 --epic-id 0049 --output ai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\")\n```\n\nEnvelope:\n\n```json\n{\"reportPath\":\"\u002Frepo\u002Fai\u002Fepics\u002Fepic-XXXX\u002Freports\u002Fstory-XXXX-YYYY-report.md\",\"summary\":{\"tasksCount\":5,\"tasksDone\":5,\"commitsCount\":5,\"prNumber\":42,\"prState\":\"MERGED\",\"coverageLine\":96.4,\"coverageBranch\":92.1}}\n```\n\nExit: 0.\n\n### Example 2 — Story in progress (3 DONE, 2 PENDING)\n\nThe report is still generated; `summary.tasksDone=3` while\n`summary.tasksCount=5`. The rendered report includes a per-task\nstatus table via the template's `{{#each tasks}}` block. Exit: 0.\n\n### Example 3 — Error: STATE_NOT_FOUND\n\n```bash\nSkill(skill: \"x-internal-write-story-report\",\n      args: \"--story-id story-0049-0099 --epic-id 0099 --output \u002Ftmp\u002Fout.md\")\n```\n\nStderr:\n\n```\nState missing: ai\u002Fepics\u002Fepic-XXXX\u002Fexecution-state.json\n```\n\nExit: 1. No envelope emitted.\n\n### Example 4 — Error: TEMPLATE_MISSING\n\nThe state file exists but `_TEMPLATE-STORY-COMPLETION-REPORT.md` is\nnot present under `.claude\u002Ftemplates\u002F`. Stderr:\n\n```\nTemplate missing: _TEMPLATE-STORY-COMPLETION-REPORT.md\n```\n\nExit: 2.\n\n### Example 5 — Boundary: story without PR\n\nState snippet: `\"pr\"` key is absent or `null`.\n\nEnvelope:\n\n```json\n{\"reportPath\":\"…\",\"summary\":{\"tasksCount\":4,\"tasksDone\":2,\"commitsCount\":2,\"prNumber\":null,\"prState\":null,\"coverageLine\":null,\"coverageBranch\":null}}\n```\n\nThe rendered report omits the \"Pull Request\" section because the\ntemplate guards that block on `{{prNumber}}`. Exit: 0.\n\n## Outputs\n\n| Artifact | Path | Description |\n| :--- | :--- | :--- |\n| Rendered report | `\u003C--output>` | Markdown file written via `x-internal-write-report` (atomic tmp+rename) |\n| Response envelope | stdout | Single-line JSON (`reportPath` \u002F `summary`) |\n| Error diagnostic | stderr | Single line, non-empty only on exit ≠ 0 |\n\nNo file is created by this skill directly — every disk mutation is\ndelegated to `x-internal-write-report`, which provides the atomic\nwrite contract.\n\n## Error Handling\n\n| Scenario | Action |\n| :--- | :--- |\n| Missing required flag | Print `usage:` banner to stderr; exit 64 |\n| Unknown flag | Print `unknown flag \u003Cname>; usage:`; exit 64 |\n| `--output` empty or traversal-unsafe | Print `output path unsafe`; exit 64 |\n| `jq` absent on PATH | Print `dependency missing: jq`; exit 127 |\n| `execution-state.json` missing | Exit 1 (`STATE_NOT_FOUND`); no envelope |\n| Story node absent from state | Exit 1; stderr distinguishes via message |\n| `.tasks` key absent | Treat as empty map (`tasksCount=0`); exit 0 |\n| `.pr` key absent | Emit `prNumber=null, prState=null`; exit 0 |\n| `.verification.coverage` absent | Emit `coverageLine=null, coverageBranch=null`; exit 0 |\n| `.reviews.findings` absent | Emit `findings:[]`; exit 0 |\n| Template file absent | Exit 2 (`TEMPLATE_MISSING`); no envelope |\n| `x-internal-write-report` UNRESOLVED_PLACEHOLDER (exit 3) | Propagate exit code 3 unchanged; stderr already populated by renderer |\n| `x-internal-write-report` WRITE_FAILED (exit 4) | Propagate exit code 4 unchanged |\n\n## Performance Contract\n\n- Target: \u003C 500 ms end-to-end for a typical story (5–10 tasks) on a\n  laptop-class machine. Budget breakdown:\n  - Argument parse + state read: \u003C 50 ms\n  - Summary JSON computation (jq): \u003C 100 ms\n  - Payload assembly: \u003C 50 ms\n  - Template resolution: \u003C 10 ms\n  - `x-internal-write-report` invocation: ~200 ms (its own contract)\n  - Envelope emission: \u003C 10 ms\n- Memory bounded by state-file size + 2× payload size; the skill\n  never loads the rendered report into memory.\n- Idempotent under repeated invocations with identical state file\n  and `--output` path (the renderer's atomic tmp+rename contract).\n\n## Testing\n\nStory-0049-0015 ships the following acceptance test scenarios,\nmirroring Section 7 of the story file:\n\n1. **Happy path** — state with 5 DONE tasks and merged PR renders\n   the full report; `summary.tasksCount=5`, `summary.prState=MERGED`.\n2. **Story in progress** — 3 DONE + 2 PENDING renders a report with\n   per-task status; `summary.tasksDone=3`, `summary.tasksCount=5`.\n3. **Error — STATE_NOT_FOUND** — missing state file → exit 1, no\n   envelope, stderr matches.\n4. **Error — TEMPLATE_MISSING** — template absent → exit 2, no\n   envelope, stderr matches.\n5. **Boundary — story sem PR** — `.pr` absent → `prNumber=null`,\n   `prState=null`, rendered report omits the \"Pull Request\" section.\n\nGoldens live under\n`src\u002Ftest\u002Fresources\u002Fgolden\u002Finternal\u002Fplan\u002Fx-internal-write-story-report\u002F`\nand lock the SKILL.md rendering (per EPIC-0049 convention: generator\ncopies internal skills into `.claude\u002Fskills\u002F` flat layout but filters\nthem from `\u002Fhelp` — goldens validate the source, not the flattened\noutput).\n\nCoverage requirement: ≥ 95% line \u002F ≥ 90% branch across the invoking\nBash codepaths (DoD Global).\n\n## Generator Filter Contract\n\nThe `ia-dev-env` generator MUST exclude skills with\n`visibility: internal` from:\n\n1. The `.claude\u002FREADME.md` skill-inventory table.\n2. The `\u002Fhelp` menu listing surfaced by Claude Code.\n3. User-facing autocomplete in the chat input.\n\nInternal skills are still copied into `.claude\u002Fskills\u002F` (flat layout)\nso `Skill(skill: \"x-internal-write-story-report\")` invocations from other\nskills resolve correctly. The invariant: **user cannot see it;\norchestrators can invoke it.**\n\n## Telemetry\n\nInternal skills DO NOT emit `phase.start` \u002F `phase.end` markers —\ntelemetry is produced by the invoking orchestrator (the `phase`\nwrapping the orchestrator's own step — Phase 3 in this case — is\nthe correct aggregation boundary). Passive hooks still capture\n`tool.call` for the underlying `Bash` invocations (`jq`) and the\nnested `Skill(x-internal-write-report)` dispatch.\n\nReference: Rule 13 (Skill Invocation Protocol), Rule 22 (Lifecycle\nIntegrity Audit), ADR-0010 (Interactive Gates Convention — exempts\ninternal skills from the 3-option menu contract).\n\n## Integration Notes\n\n| Skill | Relationship | Context |\n| :--- | :--- | :--- |\n| `x-implement-story` | caller (primary) | Phase 3 final-report carve-out: orchestrator passes `--story-id --epic-id --output` and consumes `{reportPath, summary}` |\n| `x-internal-write-report` | downstream (delegated render) | Resolves `{{KEY}}` placeholders and `{{#each tasks}} \u002F {{#each findings}}` loops against the payload built in Step 4 |\n| `x-internal-update-status` | peer (read-only consumer) | Both read `execution-state.json`; this skill does NOT write to it |\n| `x-internal-verify-story` | upstream producer | Writes `.verification.coverage` consumed in Step 3 |\n| `x-internal-resume-story` | peer | Shares the DONE synonym set and task-classification logic; no runtime coupling |\n| `x-review-codebase` \u002F `x-review-pr` | upstream producers | Write `.reviews.findings` consumed in Step 4 |\n| `x-reconcile-status` | downstream reader | May read the rendered report for epic-wide status reconciliation (never mutates concurrently) |\n\nDownstream story that depends on this skill: story-0049-0019\n(orchestrator consumes the envelope and deletes the inline Phase 3\nfinal-report block).\n\nFull workflow detail (argument-parser rejection matrix, summary\ncomputation edge cases, render-payload schema contract with the\ntemplate, PR-state normalisation rules, performance profiling on\nlarge stories, and the forward-compatibility policy for new\n`summary` fields) lives in\n[`references\u002Ffull-protocol.md`](references\u002Ffull-protocol.md) per\nADR-0011.\n",{"name":5,"category":24,"visibility":25,"description":7,"allowed-tools":26,"argument-hint":27,"context-budget":28,"user-invocable":20,"requires-capabilities":29},"internal-plan","internal","Bash, Skill","--story-id \u003Cstory-XXXX-YYYY> --epic-id \u003CXXXX> --output \u003Cpath>","heavy",[],"main","952a630c6f38d193a349d86fa18db1de8843e837","src\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-internal-write-story-report",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":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-write-story-report",{"tool":45,"command":46},"bunx","bunx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-write-story-report",{"tool":48,"command":49},"pnpm","pnpm dlx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-internal-write-story-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-internal-write-story-report\u002FSKILL.md",true,[53],{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Ffull-protocol.md","REFERENCE","参考文档",10402,"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-internal-write-story-report\u002Freferences\u002Ffull-protocol.md",[60,67,74,81,88,95],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"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":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"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":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"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":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"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":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"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":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"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",[],[]]