---
paths: ".claude/plans/**/*.md, devforgeai/specs/Stories/**/*.md"
---

# Plan Mode Story Creation Verification

**Purpose:** Ensure ground truth verification when creating stories from plan specifications

**Trigger:** Before creating ANY story file from plan specifications

**Reference:** RCA-028 (Manual Story Creation Ground Truth Validation Failure)

---

## Pre-Flight Verification

Before creating ANY story file from plan specifications, run the CLI gate that mechanizes the 3 verification checks:

```bash
devforgeai-validate verify-story-creation <STORY_FILE> --format=json
```

- **Exit 0** — all 3 checks passed; proceed to story creation.
- **Exit 1** — HALT. One or more checks failed. The CLI output identifies which:
    - `target_files_exist.missing_files` — files referenced in the Technical Specification YAML do not exist on disk.
    - `paths_valid.invalid_paths` — paths do not match any rule in `source-tree/governance.json`.
    - `referenced_deleted_files.referenced_deleted_files` — paths appear in `git status --porcelain` with delete markers.
- **Exit 2** — HALT. CLI invocation error (story file missing, malformed Tech Spec YAML, git unavailable, etc.). Investigate before retrying.

Do NOT walk the 3 checks manually — the CLI is canonical. The CLI extracts `components[*].file_path` from the `## Technical Specification` YAML block (the canonical structured-file-reference location per `validate-tech-spec`), filters template-placeholder paths, and runs all 3 checks in a single invocation.

If the CLI is unavailable (no `devforgeai-validate` on PATH), fall back to: open the story's Technical Specification YAML, enumerate `components[*].file_path`, manually `Read()` each, then check `git status` — this is the *fallback*, not the canonical path.

---

## Reference

- **RCA-028:** `devforgeai/RCA/RCA-028-manual-story-creation-ground-truth-validation-failure.md`
- **citation-requirements.md:** `.claude/rules/core/citation-requirements.md` (Read-Quote-Cite-Verify protocol)
- **source-tree/ artifact:** `devforgeai/specs/context/source-tree/` — query via `devforgeai-validate query-source-tree --validate-path` (canonical path validation)
- **create-story skill:** `.claude/skills/spec-driven-stories/SKILL.md` (Built-in validation)
- **Enforcement:** `devforgeai-validate verify-story-creation` — single-CLI gate that mechanizes the 3 pre-flight checks (extracts `file_path` from Technical Specification YAML, validates existence + source-tree governance + git-status). See ADR-094.

---

**Version:** 2.0 | **Created:** 2026-01-26 | **Updated:** 2026-05-23 (ADR-094 — CLI gate replaces manual 3-check algorithm) | **Source:** RCA-028 REC-2
