Sdd knowledge base
agent skills for spec-driver development and compounding engineering
npx -y skills add leoheart0125/sdd-skills --skill sdd-knowledge-baseAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
The 'Brain' of the project: manages state (Context), accumulates knowledge (Patterns + Lessons), and evolves rules.
SKILL.md
11.0 KB, as published. Nobody here has run it
SDD Knowledge Base
This skill is the central nervous system of the SDD framework. It goes beyond simple state persistence ("Context Management") to enable true Compounding Engineering through knowledge accumulation.
Core Responsibilities
- State Management: Persist the current snapshot of the project design (
context.json). - Pattern Library: Store and retrieve reusable design/implementation patterns by tags.
- Lessons Learned: Record "what went wrong" and "what to avoid" to prevent repeated mistakes.
- Rule Evolution: Automatically update
project_rules.mdbased on observed conventions and repeated lessons.
Commands
/sdd-save(Internal/Auto): Persist currentcontext.jsonand generatesummary.md./sdd-load: Restore context from disk./sdd-learn: Extract a "Lesson Learned" from the current conversation/incident.- Usage:
/sdd-learn "<what went wrong and what to do instead>"
- Usage:
/sdd-pattern-save: Save a reusable pattern from the current design.- Usage:
/sdd-pattern-save "<descriptive pattern name>"
- Usage:
/sdd-rule-update: Propose an update toproject_rules.md./sdd-knowledge-reindex: Rebuildindex.jsonby scanning all pattern/lesson files (use only if index is corrupt or out of sync).
Data Structures
0. Knowledge Index (.sdd/knowledge/index.json) — CRITICAL
The index is a lightweight manifest of all patterns and lessons. All other skills MUST read only this file first, then selectively load only the matching entries. This prevents full-scanning the knowledge directory and keeps context clean.
{
"patterns": {
"<pattern_id>": {
"tags": ["<domain>", "<technology>", "<concept>"],
"summary": "One-line description for quick relevance check",
"file": "patterns/<pattern_id>.json"
}
},
"lessons": {
"<lesson_id>": {
"tags": ["<domain>", "<concept>"],
"trigger": "<phase>-<domain>",
"summary": "One-line description for quick relevance check",
"file": "lessons/<lesson_id>.json"
}
}
}
Index Sync Rules:
- Every
/sdd-pattern-saveand/sdd-learncall MUST updateindex.jsonatomically (add the new entry). - Every deletion of a pattern/lesson MUST remove its entry from
index.json. /sdd-initMUST create an empty index:{ "patterns": {}, "lessons": {} }.- If
index.jsonis missing or corrupt, rebuild it by scanning all files inpatterns/andlessons/(fallback only).
Lookup Protocol (used by all other skills):
- Read
.sdd/knowledge/index.json(small, typically < 50 lines). - Filter entries by matching
tagsagainst the current feature's domain keywords. - For lessons, also match
triggeragainst the current phase (e.g.,"designing-*","planning-*","implementing-*","guard-check-*"). - Load ONLY the matched files (typically 0–5 files instead of all).
- If no matches, proceed without loading any knowledge files.
1. Patterns (.sdd/knowledge/patterns/)
Reusable JSON templates for Architecture or Code. See templates/pattern.json for the canonical template.
JSON Writing Rule: When generating any JSON artifact, all string values MUST have special characters properly escaped (\", \\, \n, \t, control chars). Verify JSON validity before writing to disk.
id: Unique ID — descriptive, kebab-casename: Human-readable name describing the patterntags: Cross-feature retrieval tags — domain keywords, technologies, conceptsproblem: When to use this pattern — the problem it solvessolution: The verified design/code approachexample: Optional code snippet, reference, or implementation note
Tag-based retrieval: When sdd-task-planner or sdd-design-engine searches for patterns, they match by tags rather than feature IDs. This enables patterns from one feature to be discoverable when building similar features in the same domain.
2. Lessons (.sdd/knowledge/lessons/)
See templates/lesson.json for the canonical template.
id: Unique ID — descriptive, kebab-casetags: Cross-feature retrieval tags — domain keywords, technologies, conceptstrigger: When to recall this lesson —<phase>-<domain>format (e.g.,"designing-<domain>","implementing-<domain>","guard-check-code")context: What happened — the gap between expectation and realityadvice: The specific guidance — actionable and concrete
3. State (.sdd/context/context.json)
The source of truth for the current project state.
{
"project_name": "...",
"current_stage": "design",
"current_feature": "<feature-id>",
"completed_features": ["<past-feature-1>"],
"active_patterns": ["<matched-pattern-id>"],
"applied_lessons": ["<applied-lesson-id>"]
}
Lesson Recording: When and Where
Core Principle
Lessons come from gaps — the gap between expectation and reality. No gap, no lesson needed.
Triggers by Phase
Design Phase — When specs are corrected
- User points out missing or misunderstood requirements
- Guardrail detects ambiguity or contradiction
- Architecture choice is rejected by user
Plan Phase — When plans are adjusted
- Task granularity adjusted by user (too coarse or too fine)
- Task order rearranged
- Conflict found between
project_rulesand generated plan
Implementation Phase — Two sub-triggers
a) During implementation (obstacles encountered):
- Spec missing a field, triggering
/sdd-spec-update - Framework or tool behavior differs from expectation
- Third-party service has undocumented limitations
b) After implementation (/sdd-impl-finish):
- Read
.sdd/logs/session.mdfor the full cross-session implementation history (this is the primary source for lesson extraction — without it, lessons from previous sessions are lost) - Issues found and fixed during guardrail checks
- Root causes of spec drift
- Any "I wish I had known..." insights
Guardrail Phase (Cross-cutting)
Every guardrail fail → fix → pass cycle is a lesson.
Recording Principles
| Principle | Description |
|---|---|
| Correction = Record | Whenever agent output is rejected by user or guardrail and corrected, that's a lesson |
| Surprise = Record | Unexpected behavior from frameworks, tools, platforms, or third-party services |
| Repetition = Upgrade | If the same lesson triggers twice, promote it to a project_rule via /sdd-rule-update |
| Don't record smooth sailing | When everything works as expected, no lesson is needed — avoid noise |
Knowledge Triage (MANDATORY before saving)
Every time new patterns or lessons are drafted (during /sdd-impl-finish, /sdd-learn, or /sdd-pattern-save), apply the following triage before writing to disk:
Step 1: Dedup — Merge similar entries
- Read
.sdd/knowledge/index.json. - For each draft, check if an existing entry has ≥50% tag overlap AND covers the same semantic advice/solution.
- If a near-duplicate exists:
- Merge: Update the existing entry to incorporate the new insight (broader tags, refined advice). Do NOT create a second entry.
- Update
index.jsonaccordingly (tags may expand, summary may update).
- If no duplicate, proceed to Step 2.
Step 2: Specificity Check — Filter out overly general entries
Classify each draft into one of three levels:
| Level | Definition | Action |
|---|---|---|
| Project-wide | Applies to ALL features regardless of domain (e.g., naming conventions, coding standards) | Promote to project_rules.md via /sdd-rule-update. Do NOT save as a lesson/pattern. |
| Domain-specific | Applies to a category of features sharing a domain or technology | Save as pattern/lesson with appropriate domain tags. |
| Feature-specific | Applies only to this exact feature and its specific implementation details | Skip — this is spec detail, not reusable knowledge. Archive naturally with the feature in .sdd/features/. |
Step 3: Present triage results to user
Show a summary table before saving:
| # | Type | Title | Action | Reason |
|---|---------|------------------------------|------------------|---------------------------------|
| 1 | Pattern | Reusable scaffold for X | MERGE into P-003 | 80% overlap with existing |
| 2 | Lesson | Project-wide naming rule | PROMOTE to rules | Project-wide, not feature-bound |
| 3 | Lesson | Framework limitation in Y | SAVE (new) | Domain-specific, reusable |
| 4 | Pattern | Feature-specific config | SKIP | Feature-specific detail |
User confirms, edits, or overrides each action before execution.
Step 4: Execute and Update Index (CRITICAL)
After user confirms, execute each action AND update .sdd/knowledge/index.json atomically:
| Action | File Operation | Index Operation |
|---|---|---|
| SAVE | Write new file to patterns/ or lessons/ | Add new entry to index.json with tags, summary, file (and trigger for lessons) |
| MERGE | Update existing file in-place | Update existing entry in index.json (tags may expand, summary may change) |
| PROMOTE | Append to project_rules.md | No index change (not a pattern/lesson) |
| SKIP | No file written | No index change |
[!CAUTION] If you write a pattern/lesson file but do NOT update
index.json, the knowledge is invisible to all other skills. The index is the only lookup mechanism.
Session Log as Cross-Session Memory
During implementation, all events (task completions, user corrections, spec drift, guardrail failures) are appended to .sdd/logs/session.md. This file persists across agent sessions and is the primary input for knowledge extraction at /sdd-impl-finish. After extraction, the log is cleared.
Event-Driven, Not Phase-Driven
Lesson writing is not bound to a single fixed command. Instead, every stage's guardrail failure and user correction should trigger /sdd-learn. The mechanism is event-driven: the lesson is recorded at the moment the gap is detected.
Auto-Evolution Logic
When /sdd-rule-update is triggered (often by sdd-implementer noticing a recurring manual fix, or by the Repetition = Upgrade principle):
- Analyze the proposed rule.
- Check for conflicts with existing rules.
- Append to
project_rules.mdunder "Evolved Conventions".
Integration
- Called by:
sdd-design-engine(to save state, to learn from corrections),sdd-implementer(to learn lessons),sdd-guardrails(to learn from failures). - Consulted by:
sdd-task-planner(to find patterns by tags),sdd-guardrails(to enforce lessons),sdd-design-engine(to suggest patterns).