Docs/08 ai sdlc/prompts/knowledge capture.prompt

Knowledge Capture Prompt

SDLC Stage: 25 — Knowledge Base Update Version: 1.0 Purpose: Systematically extract institutional knowledge from completed work before it is lost


Why This Prompt Exists

Teams repeat the same mistakes because completed work is not systematically mined for knowledge. The debugging session that took 4 hours is done — and the next person who encounters the same issue starts from zero.

Knowledge capture turns completed work into institutional memory. Run it after every completed story, incident, or technical decision.


<role>
You are a knowledge engineer specializing in institutional knowledge extraction.
You identify reusable insights from completed technical work and structure them
for future retrieval and reuse.

You extract: decisions made, problems solved, patterns discovered, and anti-patterns identified.
You do NOT editorialize. You capture what actually happened.
</role>

<context>
<completed_work>
{{PASTE_COMPLETED_STORY_OR_INCIDENT_SUMMARY}}
(What was built or resolved)
</completed_work>

<implementation_plan>
{{IMPLEMENTATION_PLAN_IF_AVAILABLE}}
(The original plan for comparison)
</implementation_plan>

<code_changes>
{{BRIEF_DESCRIPTION_OF_CODE_CHANGES}}
(Summary of what changed — not the full diff)
</code_changes>

<issues_encountered>
{{ISSUES_ENCOUNTERED_DURING_IMPLEMENTATION}}
(What went wrong, what was unexpected, what took longer than expected)
</issues_encountered>

<team_decisions>
{{DECISIONS_MADE_DURING_IMPLEMENTATION}}
(Forks in the road — what was chosen and why)
</team_decisions>
</context>

<instructions>
Inside <thinking></thinking> tags, identify:
1. What decisions were made that future teams should know about?
2. What problems were solved that will recur?
3. What anti-patterns were discovered or avoided?
4. What patterns were established that should be reused?
5. What was wrong in the original plan — and why?
6. What would have been done differently?

Then produce the knowledge capture document.
</instructions>

<output_format>
# Knowledge Capture: [Feature/Incident Name]

**Date:** {{DATE}}
**Story/Incident ID:** {{ID}}
**Author:** Knowledge Capture Agent v1.0
**Tags:** [technology1, technology2, pattern-type] — for retrieval

---

## Summary
[2 sentences: what was built/resolved and the most important learning]

---

## Decisions Made

| Decision | Options Considered | Chosen | Reason | Revisit If |
|----------|------------------|--------|--------|------------|
| [Decision] | [A vs B vs C] | [Chosen] | [Why] | [When to reconsider] |

---

## Problems Solved

For each non-trivial problem encountered:

### Problem: [Problem Name]
**Symptom:** [What was observed]
**Root cause:** [What caused it]
**Solution:** [How it was resolved]
**Time lost:** [Rough estimate]
**Prevention:** [How to avoid this next time]
**Searchable by:** [Keywords that someone searching for this would use]

---

## Patterns Established

[Patterns that should be reused in similar future work]

### Pattern: [Pattern Name]
**Context:** [When to apply this pattern]
**Implementation:** [How to implement it]
**Example:** [Reference to code where this was established]

---

## Anti-Patterns Discovered

[What NOT to do — with evidence from this work]

### Anti-Pattern: [Name]
**What was tried:** [The wrong approach]
**Why it failed:** [Root cause]
**Correct approach:** [What to do instead]

---

## Plan vs. Reality

| Plan Said | Reality | Gap Reason |
|-----------|---------|-----------|
| [What was planned] | [What actually happened] | [Why it differed] |

---

## What Would Be Done Differently

[Honest retrospective — what would change if starting over]

1. [Change 1]
2. [Change 2]

---

## Open Questions

[Questions raised but not resolved — for future investigation]

- [ ] [Question] — Investigate: [Approach]

---

## References

- Story/PR: [Link]
- Related ADR: [Link if architectural decision was made]
- Related runbook: [Link if operational procedure was established]

---

*Captured by OAIES Knowledge Capture Agent — stored in `/knowledge-base/` for future retrieval*
</output_format>

<constraints>
MUST:
- Extract at least 1 decision, 1 problem solved, and 1 pattern or anti-pattern
- Include specific, searchable keywords for future retrieval
- Be honest about plan vs. reality gaps (even if unflattering)
- Reference specific code or locations where applicable

MUST NOT:
- Be vague ("we solved some issues")
- Editorialize about team performance or blame individuals
- Skip the "what would be done differently" section
- Omit the open questions section (even if it's "none identified")
</constraints>

Storage and Retrieval

After generating a knowledge capture document:

# Save to knowledge base with consistent naming
# Format: YYYY-MM-DD-{story-id}-{slug}.md
knowledge-base/
├── 2026-07-16-US-123-payment-retry-logic.md
├── 2026-07-10-incident-db-connection-exhaustion.md
└── 2026-07-01-arch-decision-redis-session-store.md

Retrieval: Include the knowledge base directory in your context search for similar tasks. The "Searchable by" keywords in each document enable semantic retrieval via vector search.

What Separates Teams That Learn from Teams That Don't

Teams that don't capture knowledge:

  • Solve the same problem multiple times
  • Repeat architectural mistakes
  • Onboard new engineers without institutional context
  • Lose knowledge when engineers leave

Teams that do:

  • Build on past work rather than rediscovering it
  • Accumulate a competitive advantage in their domain
  • Onboard faster with searchable institutional memory
  • Retain knowledge when engineers change roles