Spec Memory Index
Use this skill to turn one-off discoveries into durable project memory and to retrieve that memory when a later task would benefit from it.
This skill is about memory with reuse value, not generic note taking. Capture decisions, setup knowledge, root causes, fix patterns, and constraints in a form that future planning and correction work can actually use.
Bundled resources
references/template.md defines the canonical Markdown entry shape, YAML frontmatter, category field, and trigger tag fields.
scripts/index.py provides deterministic add, best-match search, audit, and rebuild commands for Markdown knowledge bases.
Prefer the script for creating, searching, auditing, and rebuilding the index when the local environment can run Python. If the script cannot run, follow the same template manually and explain why the deterministic helper was not used.
Repository preference override
Before retrieving or saving memory, look for a SPEC.md in the target repository root.
If it exists, treat it as the repository-specific preference layer for:
- the knowledge-base location
- capture categories and storage expectations
- environment and configuration gotchas that are worth remembering
- cross-skill workflow conventions
If it is missing, use the built-in defaults for this skill series instead of blocking on the missing file.
If it is partial, use the fields it defines and fall back to defaults for the rest.
Built-in defaults
When no repository root SPEC.md is available, use these defaults:
- knowledge-base root:
docs/knowledge-base/
- knowledge-base index:
docs/knowledge-base/index.md
- entry template:
references/template.md
- indexing helper:
scripts/index.py
Search aliases
The search helper ships with no built-in synonym table so it stays project-neutral. Search-term synonyms are a repository-specific concern, so they live with the knowledge base rather than in the script.
To widen retrieval with project vocabulary, add an optional search-aliases.json in the knowledge-base root. Map each canonical term to a list of synonyms; when a query hits any of a group's terms, the search expands to include the rest. Terms may be in any language.
{
"auth": ["authentication", "login", "session", "token", "登录", "鉴权"],
"http-404": ["404", "not-found", "route-missing", "找不到"]
}
If the file is absent or malformed, search runs without alias expansion instead of failing.
Core responsibilities
- Save durable knowledge in a normalized, retrieval-friendly form.
- Retrieve relevant past knowledge using concrete keywords and context clues.
- Investigate, update, and reorganize existing knowledge-base entries when memory quality matters.
- Reduce repeated debugging and repeated planning by surfacing what is already known.
- Feed high-value context back into
spec-plan and spec-crlp.
Operating modes
Choose one mode from the user's intent:
- Retrieve mode: Use when the user wants to know whether the project already has related decisions, root causes, setup notes, or fix patterns.
- Capture mode: Use when the user wants to save a new reusable finding, decision, setup rule, or root cause.
- Investigate mode: Use when the user wants to inspect, audit, clean up, reorganize, update, deduplicate, or validate existing knowledge-base entries.
If the user asks to "整理", "调查", "audit", "clean up", "review existing knowledge", "update old notes", "merge duplicates", or "fix tags", use investigate mode.
What belongs in the index
- Architecture or product decisions and the reason behind them.
- Requirement constraints and non-obvious boundaries.
- Setup steps, environment prerequisites, and configuration gotchas.
- Confirmed root causes and the fixes that resolved them.
- Reusable implementation patterns, migration rules, or troubleshooting heuristics.
- Known pitfalls, edge cases, and lessons learned from previous work.
Entry categories
Use one primary category per entry:
decision: durable architecture, product, workflow, or tooling decision
constraint: requirement boundary or non-obvious long-term limitation
setup: environment, dependency, installation, or configuration prerequisite
root-cause: confirmed cause of an observed failure
fix-pattern: reusable correction strategy for a recurring class of bugs
implementation-pattern: reusable implementation approach
pitfall: known trap, anti-pattern, or edge case to avoid
validation: lint, test, build, CI, or verification rule
If an entry seems to fit multiple categories, choose the category that best explains why future work should retrieve it.
Trigger tags
Trigger tags are retrieval hooks, not documentation prose.
Build tags from signals that future users, logs, or code searches are likely to contain:
type:<category>
phase:planning, phase:correction, phase:setup, or phase:retrieval
domain:<area>
component:<component-name>
framework:<framework-name>
tool:<tool-name>
symptom:<observed-behavior>
error:<normalized-error-name>
file:<normalized-file-name>
env:<environment-name>
Prefer lowercase, hyphenated tags. Keep them specific enough to retrieve the entry later, but avoid one-off tags that no future query is likely to use.
What does not belong in the index
- Raw chatter with no future reuse value.
- Large unstructured logs when a concise summary would do.
- Temporary guesses that have not been validated.
- Duplicate entries that say the same thing in different words.
Retrieval workflow
- Identify what question you are trying to answer.
- Build search terms from the problem domain, component name, symptom, tool, environment, and error wording.
- Use
scripts/index.py search against the knowledge-base root when Python is available.
- If the script is unavailable, retrieve the most relevant matches manually from the location defined in the repository root
SPEC.md when present, otherwise use the built-in default location.
- Rank them by closeness to the current task.
- Return concise takeaways, why they matter, and what action they suggest.
- If nothing relevant is found, say so plainly instead of pretending there is memory that does not exist.
Use scripts/index.py search --explain when the reason for a match matters. The search helper uses weighted best-match scoring across trigger tags, titles, frontmatter fields, summaries, Applies When, root-cause sections, resolutions, and validation text. Treat search results as candidates to inspect, not as proof.
Capture workflow
- Decide whether the new information is likely to help with future work.
- Choose exactly one primary category.
- Generate trigger tags from phase, domain, component, tool, framework, symptom, error, file, and environment signals.
- Normalize the content using
references/template.md.
- Use
scripts/index.py add when Python is available so the entry and index are updated deterministically. The helper automatically adds the type:<category> trigger tag if it is missing.
- Preserve the context that explains when the entry applies.
- Include the evidence, resolution, or decision rationale.
- Avoid creating a second entry when an update to an existing one would be cleaner.
Investigate workflow
Use this workflow when maintaining an existing knowledge base:
- Resolve the knowledge-base root from the repository root
SPEC.md when present, otherwise use the built-in default location.
- Read
index.md and scan all memory entries under the knowledge-base root.
- Check for broken index links, entries missing from the index, duplicate or overlapping entries, weak trigger tags, missing metadata, stale setup notes, conflicting rules, and entries without validation context.
- Group findings by action: keep, update, merge, split, archive, or needs human review.
- Prefer safe updates first: add missing trigger tags, fix category metadata, improve summaries, fill
Applies When, and add validation context.
- Ask before destructive changes such as deleting entries, overwriting substantial content, or merging entries where information could be lost.
- Run
scripts/index.py audit when Python is available to get a deterministic structural report.
- After manual edits, run
scripts/index.py rebuild when Python is available.
- Produce an investigation report summarizing what changed, what was left untouched, and what still needs review.
Investigation checks
Check each entry for:
- exactly one primary
type
- meaningful
trigger_tags
- a clear
Summary
- an
Applies When section that explains retrieval conditions
- a
Decision Or Root Cause section with validated knowledge, not speculation
- a
Resolution Or Rule section that is actionable
- a
Validation section that explains how the knowledge was confirmed or should be checked
- related files or systems when they help future retrieval
Check the index for:
- links to missing files
- entries that exist on disk but are missing from
index.md
- duplicate titles or near-duplicate summaries
- categories that are too broad or inconsistent
- stale entries that should be updated or archived
Preferred investigation report shape
Prefer this structure after investigating existing memory:
# Knowledge Base Investigation
## Scope
## Summary
## Entries Reviewed
## Changes Applied
## Recommended Updates
## Duplicates Or Conflicts
## Broken Or Missing Index Links
## Needs Human Review
## Rebuild Status
Preferred entry shape
Prefer the bundled references/template.md when saving or presenting memory. The entry should include this shape:
# Memory Entry
## Title
## Context
## Applies When
## Decision Or Root Cause
## Resolution Or Rule
## Validation
## Tags
## Related Files Or Systems
Preferred retrieval shape
Prefer a structure like this when returning matches:
# Relevant Memory
## Match
## Why It Matters
## Key Takeaway
## Recommended Next Step
Storage guidance
Use the storage location defined in the repository root SPEC.md when present.
If no repository root SPEC.md is available, default to docs/knowledge-base/ and docs/knowledge-base/index.md.
When adding or changing entries, use scripts/index.py rebuild after manual edits to keep index.md synchronized.
If the default storage location is clearly unsuitable for the task or the repository is read-only, present the normalized memory entry in the response and explain that persistent storage could not be updated.
Handoffs
- Accept decisions, assumptions, and constraints from
spec-plan when they are worth preserving.
- Accept confirmed root causes, setup fixes, and troubleshooting patterns from
spec-crlp.
- Return relevant memory to
spec-plan when planning a new task with similar constraints.
- Return relevant memory to
spec-crlp when debugging a failure that resembles a known issue.
- Recommend creating or updating a repository root
SPEC.md when repeated memory entries reveal a repository-specific convention that should become explicit.
Example requests
- "Save this root cause so we do not lose it after this session."
- "Have we solved something like this migration issue before?"
- "Index the setup steps and env gotchas from today's work so future tasks can retrieve them."
- "Audit the knowledge base and fix weak trigger tags."
- "Merge duplicate root-cause entries and rebuild the index."
- "Investigate existing setup notes and mark anything stale."
1---2name: spec-index3description: Capture and retrieve durable project memory for spec-driven engineering, including decisions, constraints, setup steps, root causes, fixes, patterns, and reusable snippets through lightweight local indexing and keyword retrieval. Use this whenever the user wants to save knowledge for later, look up prior solutions, avoid re-solving the same problem, onboard future work, or feed historical context into planning and correction loops.4---56# Spec Memory Index78Use this skill to turn one-off discoveries into durable project memory and to retrieve that memory when a later task would benefit from it.910This skill is about memory with reuse value, not generic note taking. Capture decisions, setup knowledge, root causes, fix patterns, and constraints in a form that future planning and correction work can actually use.1112## Bundled resources1314- `references/template.md` defines the canonical Markdown entry shape, YAML frontmatter, category field, and trigger tag fields.15- `scripts/index.py` provides deterministic `add`, best-match `search`, `audit`, and `rebuild` commands for Markdown knowledge bases.1617Prefer the script for creating, searching, auditing, and rebuilding the index when the local environment can run Python. If the script cannot run, follow the same template manually and explain why the deterministic helper was not used.1819## Repository preference override2021Before retrieving or saving memory, look for a `SPEC.md` in the target repository root.2223If it exists, treat it as the repository-specific preference layer for:2425- the knowledge-base location26- capture categories and storage expectations27- environment and configuration gotchas that are worth remembering28- cross-skill workflow conventions2930If it is missing, use the built-in defaults for this skill series instead of blocking on the missing file.3132If it is partial, use the fields it defines and fall back to defaults for the rest.3334## Built-in defaults3536When no repository root `SPEC.md` is available, use these defaults:3738- knowledge-base root: `docs/knowledge-base/`39- knowledge-base index: `docs/knowledge-base/index.md`40- entry template: `references/template.md`41- indexing helper: `scripts/index.py`4243## Search aliases4445The search helper ships with no built-in synonym table so it stays project-neutral. Search-term synonyms are a repository-specific concern, so they live with the knowledge base rather than in the script.4647To widen retrieval with project vocabulary, add an optional `search-aliases.json` in the knowledge-base root. Map each canonical term to a list of synonyms; when a query hits any of a group's terms, the search expands to include the rest. Terms may be in any language.4849```json50{51 "auth": ["authentication", "login", "session", "token", "登录", "鉴权"],52 "http-404": ["404", "not-found", "route-missing", "找不到"]53}54```5556If the file is absent or malformed, search runs without alias expansion instead of failing.5758## Core responsibilities5960- Save durable knowledge in a normalized, retrieval-friendly form.61- Retrieve relevant past knowledge using concrete keywords and context clues.62- Investigate, update, and reorganize existing knowledge-base entries when memory quality matters.63- Reduce repeated debugging and repeated planning by surfacing what is already known.64- Feed high-value context back into `spec-plan` and `spec-crlp`.6566## Operating modes6768Choose one mode from the user's intent:6970- Retrieve mode: Use when the user wants to know whether the project already has related decisions, root causes, setup notes, or fix patterns.71- Capture mode: Use when the user wants to save a new reusable finding, decision, setup rule, or root cause.72- Investigate mode: Use when the user wants to inspect, audit, clean up, reorganize, update, deduplicate, or validate existing knowledge-base entries.7374If the user asks to "整理", "调查", "audit", "clean up", "review existing knowledge", "update old notes", "merge duplicates", or "fix tags", use investigate mode.7576## What belongs in the index7778- Architecture or product decisions and the reason behind them.79- Requirement constraints and non-obvious boundaries.80- Setup steps, environment prerequisites, and configuration gotchas.81- Confirmed root causes and the fixes that resolved them.82- Reusable implementation patterns, migration rules, or troubleshooting heuristics.83- Known pitfalls, edge cases, and lessons learned from previous work.8485## Entry categories8687Use one primary category per entry:8889- `decision`: durable architecture, product, workflow, or tooling decision90- `constraint`: requirement boundary or non-obvious long-term limitation91- `setup`: environment, dependency, installation, or configuration prerequisite92- `root-cause`: confirmed cause of an observed failure93- `fix-pattern`: reusable correction strategy for a recurring class of bugs94- `implementation-pattern`: reusable implementation approach95- `pitfall`: known trap, anti-pattern, or edge case to avoid96- `validation`: lint, test, build, CI, or verification rule9798If an entry seems to fit multiple categories, choose the category that best explains why future work should retrieve it.99100## Trigger tags101102Trigger tags are retrieval hooks, not documentation prose.103104Build tags from signals that future users, logs, or code searches are likely to contain:105106- `type:<category>`107- `phase:planning`, `phase:correction`, `phase:setup`, or `phase:retrieval`108- `domain:<area>`109- `component:<component-name>`110- `framework:<framework-name>`111- `tool:<tool-name>`112- `symptom:<observed-behavior>`113- `error:<normalized-error-name>`114- `file:<normalized-file-name>`115- `env:<environment-name>`116117Prefer lowercase, hyphenated tags. Keep them specific enough to retrieve the entry later, but avoid one-off tags that no future query is likely to use.118119## What does not belong in the index120121- Raw chatter with no future reuse value.122- Large unstructured logs when a concise summary would do.123- Temporary guesses that have not been validated.124- Duplicate entries that say the same thing in different words.125126## Retrieval workflow1271281. Identify what question you are trying to answer.1292. Build search terms from the problem domain, component name, symptom, tool, environment, and error wording.1303. Use `scripts/index.py search` against the knowledge-base root when Python is available.1314. If the script is unavailable, retrieve the most relevant matches manually from the location defined in the repository root `SPEC.md` when present, otherwise use the built-in default location.1325. Rank them by closeness to the current task.1336. Return concise takeaways, why they matter, and what action they suggest.1347. If nothing relevant is found, say so plainly instead of pretending there is memory that does not exist.135136Use `scripts/index.py search --explain` when the reason for a match matters. The search helper uses weighted best-match scoring across trigger tags, titles, frontmatter fields, summaries, `Applies When`, root-cause sections, resolutions, and validation text. Treat search results as candidates to inspect, not as proof.137138## Capture workflow1391401. Decide whether the new information is likely to help with future work.1412. Choose exactly one primary category.1423. Generate trigger tags from phase, domain, component, tool, framework, symptom, error, file, and environment signals.1434. Normalize the content using `references/template.md`.1445. Use `scripts/index.py add` when Python is available so the entry and index are updated deterministically. The helper automatically adds the `type:<category>` trigger tag if it is missing.1456. Preserve the context that explains when the entry applies.1467. Include the evidence, resolution, or decision rationale.1478. Avoid creating a second entry when an update to an existing one would be cleaner.148149## Investigate workflow150151Use this workflow when maintaining an existing knowledge base:1521531. Resolve the knowledge-base root from the repository root `SPEC.md` when present, otherwise use the built-in default location.1542. Read `index.md` and scan all memory entries under the knowledge-base root.1553. Check for broken index links, entries missing from the index, duplicate or overlapping entries, weak trigger tags, missing metadata, stale setup notes, conflicting rules, and entries without validation context.1564. Group findings by action: keep, update, merge, split, archive, or needs human review.1575. Prefer safe updates first: add missing trigger tags, fix category metadata, improve summaries, fill `Applies When`, and add validation context.1586. Ask before destructive changes such as deleting entries, overwriting substantial content, or merging entries where information could be lost.1597. Run `scripts/index.py audit` when Python is available to get a deterministic structural report.1608. After manual edits, run `scripts/index.py rebuild` when Python is available.1619. Produce an investigation report summarizing what changed, what was left untouched, and what still needs review.162163## Investigation checks164165Check each entry for:166167- exactly one primary `type`168- meaningful `trigger_tags`169- a clear `Summary`170- an `Applies When` section that explains retrieval conditions171- a `Decision Or Root Cause` section with validated knowledge, not speculation172- a `Resolution Or Rule` section that is actionable173- a `Validation` section that explains how the knowledge was confirmed or should be checked174- related files or systems when they help future retrieval175176Check the index for:177178- links to missing files179- entries that exist on disk but are missing from `index.md`180- duplicate titles or near-duplicate summaries181- categories that are too broad or inconsistent182- stale entries that should be updated or archived183184## Preferred investigation report shape185186Prefer this structure after investigating existing memory:187188```markdown189# Knowledge Base Investigation190## Scope191## Summary192## Entries Reviewed193## Changes Applied194## Recommended Updates195## Duplicates Or Conflicts196## Broken Or Missing Index Links197## Needs Human Review198## Rebuild Status199```200201## Preferred entry shape202203Prefer the bundled `references/template.md` when saving or presenting memory. The entry should include this shape:204205```markdown206# Memory Entry207## Title208## Context209## Applies When210## Decision Or Root Cause211## Resolution Or Rule212## Validation213## Tags214## Related Files Or Systems215```216217## Preferred retrieval shape218219Prefer a structure like this when returning matches:220221```markdown222# Relevant Memory223## Match224## Why It Matters225## Key Takeaway226## Recommended Next Step227```228229## Storage guidance230231Use the storage location defined in the repository root `SPEC.md` when present.232233If no repository root `SPEC.md` is available, default to `docs/knowledge-base/` and `docs/knowledge-base/index.md`.234235When adding or changing entries, use `scripts/index.py rebuild` after manual edits to keep `index.md` synchronized.236237If the default storage location is clearly unsuitable for the task or the repository is read-only, present the normalized memory entry in the response and explain that persistent storage could not be updated.238239## Handoffs240241- Accept decisions, assumptions, and constraints from `spec-plan` when they are worth preserving.242- Accept confirmed root causes, setup fixes, and troubleshooting patterns from `spec-crlp`.243- Return relevant memory to `spec-plan` when planning a new task with similar constraints.244- Return relevant memory to `spec-crlp` when debugging a failure that resembles a known issue.245- Recommend creating or updating a repository root `SPEC.md` when repeated memory entries reveal a repository-specific convention that should become explicit.246247## Example requests248249- "Save this root cause so we do not lose it after this session."250- "Have we solved something like this migration issue before?"251- "Index the setup steps and env gotchas from today's work so future tasks can retrieve them."252- "Audit the knowledge base and fix weak trigger tags."253- "Merge duplicate root-cause entries and rebuild the index."254- "Investigate existing setup notes and mark anything stale."