Loading...
Loading...
Extracts key learnings from conversations, debugging sessions, and failed attempts. Use at session end or after solving complex problems to capture insights. Stores discoveries in memory (via amplihack.memory.discoveries), suggests PATTERNS.md updates, and recommends new agent creation. Ensures knowledge persists across sessions via Kuzu memory backend.
npx skill4agent add rysweet/amplihack knowledge-extractor## [Brief Title] (YYYY-MM-DD)
### Issue
What problem or challenge was encountered?
### Root Cause
Why did this happen? What was the underlying issue?
### Solution
How was it resolved? Include code examples if relevant.
### Key Learnings
What insights were gained? What should be remembered?
### Prevention
How can this be avoided in the future?## Pattern: [Name]
### Challenge
What problem does this pattern solve?
### Solution
How does the pattern work? Include code/examples.
### Key Points
- Main insight 1
- Main insight 2
- When to use / when not to use
### When to Use
Specific scenarios where this pattern applies.
### Real Impact
Where has this pattern been used successfully?
### Related Patterns
Links to similar or complementary patterns.## Recommended New Agent: [domain]-[specialty]
### Problem
What repeated workflow would this agent handle?
### Scope
What's in scope | What's explicitly out of scope
### Inputs
What information does the agent need?
### Process
Step-by-step workflow the agent follows
### Outputs
What does the agent produce?
### Value
How much time/effort does this save?
### Integration
Where in the workflow does this fit?1. What was the original problem/request?
2. What approaches were tried?
3. Which attempts failed and why?
4. What succeeded and why?
5. What was learned in the process?
6. What surprised you?
7. What took longer than expected?
8. What would have helped?1. Have I seen this problem before? (→ DISCOVERIES)
2. Is this a generalizable solution? (→ PATTERNS)
3. Would this be worth automating? (→ AGENT)
4. What was the root cause? (Why, not just what)
5. What should others know about this?
6. What should be remembered to avoid repetition?Memory → Store discovery using store_discovery() from amplihack.memory.discoveries
PATTERNS.md → New pattern in appropriate section
Agent → Create in .claude/agents/amplihack/specialized/[ ] Entry is specific, not generic
[ ] Entry follows template format
[ ] Examples/code provided
[ ] Quality sufficient for reuse
[ ] Grammar and clarity checked
[ ] Related items cross-referencedUser: Extract what we learned from debugging the pre-commit issue.
Claude:
1. Analyzes conversation showing:
- Initial problem: hooks appeared to run but didn't modify files
- False leads: blamed merge conflicts, tool versions
- Root cause found: Hooks couldn't write to files due to cloud sync lock
- Solution: Added exponential backoff retry logic
- Time to discover: 45 minutes
2. Creates DISCOVERIES.md entry:
- Issue: Pre-commit hooks silently failing
- Root Cause: Cloud sync (OneDrive) file locks
- Solution: Exponential backoff retry (0.1s, 0.2s, 0.4s...)
- Key Learning: Cloud sync issues silent - need defensive coding
- Prevention: Add retry logic for file I/O, test with cloud storage
3. Offers to also:
- Add pattern for "Resilient File I/O" to PATTERNS.md
- Suggest new agent for cloud-sync issue detectionUser: Extract the pattern we discovered for building regeneratable modules.
Claude:
1. Analyzes implementation showing:
- Clear __all__ exports defining public interface
- Self-contained module structure
- Type-hinted functions with docstrings
- Comprehensive test coverage
- Working examples
2. Creates PATTERNS.md entry:
- Pattern: Module Regeneration Structure
- Challenge: Modules become tightly coupled, hard to regenerate
- Solution: Brick & studs design with __all__ public API
- Key Points: Clear contracts, single responsibility, testable behavior
- When to Use: Any utility module, anything that might be regenerated
- Real Impact: Enables AI to rebuild modules without breaking system
3. Cross-references:
- Relates to "Bricks & Studs Module Design"
- Enables "Builder Agent Workflow"User: We keep using the same CI debugging process. Should we automate it?
Claude:
1. Analyzes past sessions:
- Session 1: 45 minutes CI debugging (version mismatch issue)
- Session 2: 30 minutes CI debugging (pre-commit hook issue)
- Session 3: 25 minutes CI debugging (merge conflict issue)
- Pattern: Same 5-step process each time
2. Recommends new agent:
- Name: ci-diagnostic-workflow
- Problem: Each CI failure requires manual diagnosis, takes 30-45 min
- Scope: Diagnoses CI failures, suggests fixes (doesn't auto-fix)
- Process:
1. Check environment (Python version, tool versions)
2. Analyze CI logs for error patterns
3. Detect common issues (conflicts, missing deps)
4. Suggest solutions
5. Coordinate parallel diagnostic agents
- Value: Reduce diagnosis time from 45 min → 15 min
3. Proposes creating:
- .claude/agents/amplihack/ci-diagnostic-workflow.md
- Can delegate to: fix-agent for implementationUser: Extract everything we learned from deciding on the memory architecture.
Claude:
1. Session involved:
- 2 failed approaches (too complex, wrong threat model)
- 1 successful approach (simple, fits threat model)
- Discovery of meta-pattern for architecture decisions
2. Creates THREE extractions:
DISCOVERIES.md:
- Issue: Pattern Applicability Analysis
- Root Cause: Importing patterns without validating threat match
- Solution: Five-phase applicability analysis framework
- Learning: Threat model match is critical first check
PATTERNS.md:
- New Pattern: Threat Model Precision Principle
- Challenge: Fault tolerance mechanisms mismatch problem space
- Solution: Validate threat model before adopting patterns
- When: Before adopting any "best practice" from different domain
Recommended Agent:
- Name: pattern-applicability-analyzer
- Automate: Quick assessment of pattern applicability
- Value: Prevent adopting wrong patterns earlystore_discovery()get_recent_discoveries()BAD: "Learned that good error handling is important"
GOOD: "Discovered cloud sync issues cause silent file I/O failures - need exponential backoff retry"BAD: "CI failed, fixed it"
GOOD: "CI failed because version mismatch (local 3.12 vs CI 3.11) - fixed by updating pyproject.toml version constraint"BAD: "This was complicated"
GOOD: "Multi-layer sanitization at every data transformation prevents credential leakage"BAD: "Always use caching everywhere"
GOOD: "Use smart caching with lifecycle management for expensive operations where results may become stale"BAD: "Create agent for task that happens once per quarter"
GOOD: "Create agent for CI debugging workflow that happens 2-3x per week and takes 30-45 minutes"Extract what we discovered/learned from this session.
Focus on: root causes, unexpected behaviors, solutions that worked.
Update DISCOVERIES.md appropriately.What patterns should we capture for future reuse?
These should be proven solutions that apply to multiple situations.
Update PATTERNS.md appropriately.Should we create a new agent to automate any repeated workflows?
Check if any workflow has been done 2+ times and takes 30+ minutes.
Recommend creation with scope and value calculation.Perform complete knowledge extraction on this session.
Extract: discoveries, patterns, and agent creation recommendations.
Verify quality and update all three knowledge bases.~/.amplihack/.claude/context/DISCOVERIES.md