|
| 1 | +# spec-kit-spec-reference-loader |
| 2 | + |
| 3 | +A [Spec Kit](https://github.com/github/spec-kit) extension that reads the `## References` section from the current feature spec and loads the listed files into LLM context. Only fires on commands where the spec already exists. |
| 4 | + |
| 5 | +## Problem |
| 6 | + |
| 7 | +Feature specs often reference external documents — API references, integration guides, decision records — but spec-kit lifecycle commands don't automatically load those files. The LLM agent plans and implements without access to the reference material that the spec author intended to be consulted. |
| 8 | + |
| 9 | +## Solution |
| 10 | + |
| 11 | +The Spec Reference Loader extension parses the `## References` section of the current feature's `spec.md` and loads every listed file into context before lifecycle commands execute. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +# From release |
| 17 | +specify extension add spec-reference-loader --from \ |
| 18 | + https://github.com/KevinBrown5280/spec-kit-spec-reference-loader/archive/refs/tags/v1.0.0.zip |
| 19 | + |
| 20 | +# From main branch |
| 21 | +specify extension add spec-reference-loader --from \ |
| 22 | + https://github.com/KevinBrown5280/spec-kit-spec-reference-loader/archive/refs/heads/main.zip |
| 23 | + |
| 24 | +# Development mode (local clone) |
| 25 | +specify extension add --dev /path/to/spec-kit-spec-reference-loader |
| 26 | +``` |
| 27 | + |
| 28 | +## Commands |
| 29 | + |
| 30 | +| Command | Description | Modifies Files? | |
| 31 | +|---------|-------------|-----------------| |
| 32 | +| `speckit.spec-reference-loader.load` | Load reference docs listed in the feature spec's `## References` section | No — read-only | |
| 33 | + |
| 34 | +## How It Works |
| 35 | + |
| 36 | +1. **Find the spec**: Locates the feature spec at the path provided by the calling context (e.g., `specs/NNN-<feature>/spec.md`). If no spec exists yet, outputs a message and skips. |
| 37 | + |
| 38 | +2. **Parse references**: Reads the spec's `## References` section and extracts file paths from markdown list items: |
| 39 | + ```markdown |
| 40 | + ## References |
| 41 | + |
| 42 | + - docs/reference/api-reference.md |
| 43 | + - docs/reference/integration-guide.md |
| 44 | + ``` |
| 45 | + |
| 46 | +3. **Load each file**: For each file path found, reads the contents and outputs: |
| 47 | + ``` |
| 48 | + ## Reference: {filename} |
| 49 | +
|
| 50 | + {file contents} |
| 51 | + ``` |
| 52 | + |
| 53 | +4. **Summarize**: After all files, outputs: |
| 54 | + ``` |
| 55 | + Spec references loaded: {count} files |
| 56 | + ``` |
| 57 | + |
| 58 | +## Hooks |
| 59 | + |
| 60 | +The extension fires automatically before these lifecycle commands: |
| 61 | + |
| 62 | +| Hook | Command | Description | |
| 63 | +|------|---------|-------------| |
| 64 | +| `before_plan` | `speckit.spec-reference-loader.load` | Load references before planning | |
| 65 | +| `before_tasks` | `speckit.spec-reference-loader.load` | Load references before task generation | |
| 66 | +| `before_implement` | `speckit.spec-reference-loader.load` | Load references before implementation | |
| 67 | +| `before_clarify` | `speckit.spec-reference-loader.load` | Load references before clarification | |
| 68 | +| `before_checklist` | `speckit.spec-reference-loader.load` | Load references before checklist generation | |
| 69 | +| `before_analyze` | `speckit.spec-reference-loader.load` | Load references before analysis | |
| 70 | + |
| 71 | +**Does NOT fire on `before_specify`** — the spec doesn't exist yet at that point. A companion memory-loader extension can provide sufficient context for spec authoring. |
| 72 | + |
| 73 | +## Design Decisions |
| 74 | + |
| 75 | +- **Read-only** — never modifies any files |
| 76 | +- **Spec-gated** — only fires when a spec already exists; skips silently otherwise |
| 77 | +- **Complementary** — handles feature-specific references; pairs well with a memory-loader extension for project governance context |
| 78 | +- **Graceful degradation** — missing files or missing `## References` section are handled with warnings, not errors |
| 79 | + |
| 80 | +## Requirements |
| 81 | + |
| 82 | +- Spec Kit >= 0.6.0 |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +MIT |
0 commit comments