Repository navigation
[Feature]: Stop grep-based spec alignment, structured IDs + context packs #4164
Description
Problem Statement
I'm frustrated when a product change (especially a UI change) has to be folded into an existing feature. Agents find related work by grepping similar wording in spec.md, plan.md, and tasks.md. After a reword “charge on Pay” vs “show a confirm modal” the live AC/FR is often not retrieved, so another /speckit.specify pass or a manual edit adds a new requirement instead of updating the existing one.
The result is two live lines for the same behavior, or two live lines that contradict each other. /speckit.analyze is supposed to catch duplicates and conflicts, but it only reports what the model loaded. If the related line was never in context, the report is clean. I end up rerunning analyze over and over; it is not a reliable alignment step.
There is no script-owned inventory of live IDs (FR-, US/AC, T-xxx) that specify, analyze, and implement all share. Commands dump whole Markdown files (wasted tokens) and still miss the one line that mattered. I need a way to keep the spec set unambiguous no silent duplicates, no contradictory live requirements without another round of hope-and-grep.
Proposed Solution
Keep spec.md / plan.md / tasks.md as the human artifacts. Add a script-owned live inventory so specify, analyze, and implement stop grepping prose to decide what exists.
-
Structured sidecar for tasks (and later spec/plan records)
Alongside tasks.md, write tasks.yaml (YAML on disk, JSON on stdout). Each task is a record: id, status, story, files, covers: [US1/AC2, FR-007]. A Python script is the only mutator: parse Markdown once, then list / get / mark-done / coverage. Agents do not regex checkboxes. -
Complete live inventory, every command
The script emits every live FR- / AC / SC / T- for the current feature. That list is the source of “what exists.” Specify consults it before adding a requirement. Analyze builds its report from it. Implement loads one task plus the records it covers. No command should discover the spec by grepping similar text. -
Context pack instead of whole files
specify context --task T014 (or equivalent) prints a small JSON pack: that task, the live ACs/FRs it cites, matching plan bullets, and optional research hits. /speckit.implement and /speckit.analyze drive from the pack/inventory, not from dumping three Markdown files. That removes the missed-line failure and cuts tokens. -
Local, per-feature recall only (optional second phase)
If an ID link is missing, a local embedding index under specs//.index/ can pair paraphrases (“confirm modal” <-> live “charge on Pay”). Not a global or hosted vector store. Default retrieval excludes obsolete lines so old UI copy cannot be treated as live. Embeddings improve recall; they are not the source of truth. -
Alignment is classify-on-write, not another analyze loop
Before adding a requirement, resolve against the full live set (IDs, then local similarity):
- already true on a live line -> skip (duplicate)
- same behavior, new words -> edit that ID
- disagrees with a live line -> conflict; do not add a second live FR
- genuinely new -> one new ID, set covers on tasks
/speckit.analyze then reports coverage holes, unpaired IDs, and remaining high-score pairs over that structure. It should be a single deterministic pass, not a hunt that has to be rerun until the model gets lucky.
Phase 1 (core-shaped): parser + tasks.yaml + covers + context pack.
Phase 2 (opt-in): local per-feature index for paraphrase pairs.
Alternatives Considered
No response
Component
Other
AI Agent (if applicable)
None
Use Cases
No response
Acceptance Criteria
No response
Additional Context
No response
Activity
github-actions commentedon Aug 19, 2026
Feature assessment — structured-ids-context-packs · Stage 1/5: Intake
Idea Intake: Stop grep-based spec alignment, structured IDs + context packs
Idea (as captured)
Restated
The current Spec Kit spec-alignment workflow relies on agents grepping prose in three Markdown files, which silently misses renamed or paraphrased requirements and creates duplicate or contradictory live lines. The idea is to replace that grep-based discovery with a script-owned structured inventory of requirement and task IDs, plus a focused "context pack" command, so every SDD command operates on the full live set rather than a partial token-budget slice.
Origin & Context
First-Glance Unknowns
github-actions commentedon Aug 19, 2026
Feature assessment — structured-ids-context-packs · Stage 2/5: Research
Idea Research: Stop grep-based spec alignment, structured IDs + context packs
Users & Demand
Prior Art
templates/commands/analyze.md): The current/speckit.analyzealready extracts a "requirements inventory" (FR-/SC- IDs) and builds a coverage mapping per run. However, this inventory is ephemeral — reconstructed from markdown each time — rather than a persistent shared artifact. This confirms the ID-based approach is already partially acknowledged, but no cross-command persistence exists. — [source: codebase read] (confidence: high, cited)templates/commands/tasks.md): Tasks use T001/T002 sequential IDs and[US1]story labels. There is nocovers:field or tasks.yaml sidecar in the current schema. — [source: codebase read] (confidence: high, cited)templates/spec-template.md): FRs already carry structured IDs in specs; they are just not shared across commands via a script-owned persistent store. — [source: codebase read] (confidence: high, cited)scripts/bash/check-prerequisites.sh, codebase read] (confidence: high, cited)Market & Context
/speckit.analyzerepeatedly and hoping the model loads the right context window; manually editing spec.md to remove duplicates; staying disciplined about not rewording requirements (fragile). — [source: issue [Feature]: Stop grep-based spec alignment, structured IDs + context packs #4164] (confidence: high, cited)/speckit.implementmay build against the wrong or stale requirement; trust in the SDD pipeline erodes. — [source: issue [Feature]: Stop grep-based spec alignment, structured IDs + context packs #4164, codebase analysis] (confidence: high, cited)Data & Constraints
templates/commands/implement.md,templates/commands/analyze.md] (confidence: high, cited)scripts/python/) alongside bash/PowerShell; this is consistent with existing architecture. — [source:scripts/python/, codebase read] (confidence: high, cited)Evidence Against the Idea
Gaps & Open Questions
Sources
templates/commands/analyze.md,templates/commands/tasks.md,templates/commands/implement.md,templates/spec-template.md,scripts/bash/check-prerequisites.sh,src/specify_cli/(local repo, no URL fetch)github-actions commentedon Aug 19, 2026
Feature assessment — structured-ids-context-packs · Stage 3/5: Problem
Problem Definition: Stop grep-based spec alignment, structured IDs + context packs
Problem Statement
When a Spec Kit user refines or renames a requirement mid-feature (a common occurrence in UI-heavy product work), the SDD pipeline's grep-based context loading silently misses the renamed line, causing agents to add a second live requirement instead of updating the existing one — producing duplicate or contradictory specifications that the current
/speckit.analyzecommand cannot reliably detect because it only reports on what it happened to load.Affected Users & Stakeholders
/speckit.analyzerepeatedly without a reliable result.Goals
Non-Goals
Success Metrics
/speckit.analyzereliably detects all coverage gaps and conflicts (no need to rerun; deterministic output on unchanged artifacts).Cost of Inaction
Without this, spec quality degrades silently whenever requirements are reworded — a routine event in UI/product development. Agents build against stale or contradictory requirements; the output of
/speckit.analyzebecomes unreliable; developers lose trust in the SDD pipeline and fall back to manual spec hygiene, which is the exact workflow Spec Kit is meant to replace.Open Questions
github-actions commentedon Aug 19, 2026
Feature assessment — structured-ids-context-packs · Stage 4/5: Concept
Concept: Stop grep-based spec alignment, structured IDs + context packs
Options
Option A — Lightweight: Shared ID list in tasks.md
## Live IDssection) listing all live FR-/AC-/T- IDs. The check-prerequisites script extracts this list and passes it to commands via JSON output. Commands consult the extracted list before adding requirements. No new file format; no new command.covers:field (linking tasks to FRs) still has no home.Option B — Persistent ID index + classify-on-write (recommended)
tasks.json— a machine-readable record of all live T-IDs with their status, associated story IDs, andcoverslinks to FR-/AC- IDs. The check-prerequisites script is extended to emit the live ID inventory. A newspecify context --task T014command returns a focused JSON pack: the task record, the FRs/ACs it covers, and matching plan bullets. Before any command adds a requirement, it calls the inventory query to classify the new requirement as duplicate/paraphrase/conflict/new. tasks.md remains the primary human-readable artifact; tasks.json is a derived index rebuilt when tasks.md changes (regenerate-on-read).Option C — Full structured inventory + local embeddings (Phase 1 + Phase 2 together)
specs/<feature>/.index/for paraphrase-pair recall. The embedding index bridges the "confirm modal" ↔ "charge on Pay" gap that string matching misses. Embeddings are generated locally (no cloud); obsolete lines are excluded.Recommendation
Option B — Persistent ID index + classify-on-write — addresses the core failure mode within a medium appetite, consistent with Spec Kit's existing Python script architecture. Phase 2 embeddings (Option C) should remain opt-in and are appropriately deferred until Phase 1 proves out the inventory approach.
The key design decision that must be resolved before specification: how tasks.json is kept in sync with tasks.md when a human edits tasks.md directly. Recommend a regenerate-on-read strategy (tasks.json is rebuilt from tasks.md whenever check-prerequisites runs) to eliminate the sync gap without requiring humans to use a script as the only editor.
Out of Scope (for the recommended option)
Assumptions to Validate
covers:field to the tasks.md task format is acceptable to existing Spec Kit users and backward-compatible with projects that omit it.specify contextcommand can be delivered as an additional Spec Kit skill/command without requiring a CLI version bump.github-actions commentedon Aug 19, 2026
Feature assessment — structured-ids-context-packs · Stage 5/5: Decision — verdict needs-clarification
Decision: Stop grep-based spec alignment, structured IDs + context packs
Scorecard
Verdict & Rationale
needs-clarification — The problem is real and the concept is credible, but the evidence strength is weak (single user report; no usage data, support ticket volume, or broader demand signal). Per the pipeline's downgrade rule, weak evidence strength blocks a
goverdict regardless of other scores.Additionally, several design decisions that
/speckit.specifywould need to act on remain unresolved: the tasks.md ↔ tasks.json sync strategy (regenerate-on-read is assumed but not validated), the scope of command changes for Phase 1, and the API shape of thespecify contextcommand. These are resolvable questions, not blockers in principle — but they should be answered before specification can produce a reliable spec.This is a promising, internally-consistent idea that deserves a
goonce the evidence base is strengthened and the open design questions are answered.If needs-clarification
specify contextcommand — new CLI subcommand, new agent skill, or both?]covers:intended as a new required field in tasks.md task lines, or optional/additive?]Yash-Chindam commentedon Aug 19, 2026
I would like to explore a focused contribution for this issue, but the proposed scope is fairly broad. I suggest starting with the smallest Phase 1 slice: a backward-compatible, script-generated requirements/task inventory and a narrow context-pack interface, leaving embeddings and broader command rewrites out of scope.
Before implementing, could a maintainer confirm the preferred Phase 1 boundary, migration behavior for existing projects without the sidecar, and whether this direction is wanted? If approved, I would be happy to prepare the design and implementation and be assigned to the issue.
Disclosure: I used ChatGPT to review the repository guidance and draft this comment.
mnriem commentedon Aug 19, 2026
After a careful review by myself, this doesn't need to go into core as proposed — the whole of Phase 1 can be delivered as an installable, opt-in bundle with zero core changes, which is also the right way to build the adoption signal the assessment flagged as missing.
Concretely, I'd suggest a paired extension + preset:
Extension (
speckit-inventory) — the read-only primitive:scripts/inventory extractor that regenerates every liveFR-/NFR-/SC-/T-ID from the existingspec.md/tasks.mdon each run and prints JSON. Purely additive, no sidecar, no mutation — so thetasks.yaml↔tasks.mdsync problem simply doesn't arise (nothing is a second source of truth).speckit.inv.contextcommand that returns a focused context pack (a task plus the requirement IDs it covers) instead of whole-file dumps.before_specify/before_analyzehooks.Preset (
inventory-alignment) — wires the primitive into the core flow via template overrides (presets sit above extensions in the resolution stack):wrapoverride ofspeckit.specify/speckit.analyze(using the{CORE_TEMPLATE}placeholder) that prepends a "load inventory, then classify each requirement as already-true / edit-existing / conflict / genuinely-new" pre-pass, then falls through to the original command body.appendoverride oftasks-templateadding the optionalcovers:field.Please keep embeddings out (that was the large/opt-in Phase 2). This combination gives essentially all of Phase 1 without a core PR, and if it gets real usage we can revisit promoting the inventory primitive into core.
One genuine gap worth noting:
preset.yml'srequires:only declaresspeckit_version, so there's no formal "requires extension X" dependency to guarantee the extension is installed alongside the preset. That's a small, separable core enhancement I'd track on its own issue rather than block this on.We would love to see a PR that will list the community extension and community preset that would support this.
Disclosure: this comment was prepared with GitHub Copilot (model: Claude Opus 4.8) acting on my behalf.
community: add speckit-inventory extension and inventory-alignment pr…