A state-of-the-art knowledge management system designed specifically for Claude Code to capture, store, and retrieve CI troubleshooting lessons learned across multiple sessions.
.claude/knowledge/
├── sessions/ # Individual session records
│ ├── YYYY-MM-DD_HHMMSS_session.json
│ └── YYYY-MM-DD_HHMMSS_analysis.json
├── patterns/ # Identified patterns and recurring issues
│ ├── failure_patterns.json
│ └── solution_patterns.json
├── embeddings/ # Vector embeddings for semantic search
│ ├── session_embeddings.json
│ └── solution_embeddings.json
├── index/ # Search indexes
│ ├── keyword_index.json
│ └── metadata_index.json
└── templates/ # Templates for knowledge capture
├── session_template.json
└── lesson_template.json
{
"session_id": "2024-12-23_14:30:15",
"timestamp": "2024-12-23T14:30:15Z",
"context": {
"repository": "llm-pytest-analyzer",
"branch": "mnt/review-cleanup",
"pr_number": 123,
"ci_status": "failure",
"initial_failures": ["test_module.py::test_function", "..."]
},
"attempts": [
{
"attempt_number": 1,
"approach": "AI-powered analysis with pytest-analyzer",
"actions_taken": ["Applied fix suggestions", "Updated imports"],
"files_modified": ["src/module.py", "tests/test_module.py"],
"outcome": "partial_success",
"remaining_failures": ["test_async.py::test_timeout"],
"lessons_learned": ["Import order matters in CI environment", "..."],
"duration_minutes": 25
}
],
"final_status": "success",
"total_duration_minutes": 67,
"key_insights": [
"CI environment has stricter import validation",
"Async tests need explicit timeout handling"
],
"solution_patterns": [
{
"pattern_id": "import_order_ci",
"description": "CI environment import order sensitivity",
"solution_template": "Reorganize imports following isort/black standards"
}
],
"quality_gates": {
"tests_passing": true,
"lint_clean": true,
"pre_commit_passing": true
}
}# Enhanced session completion with knowledge capture
def complete_session_with_knowledge_capture(session_data):
# Extract lessons learned
lessons = extract_lessons_learned(session_data)
# Identify patterns
patterns = identify_solution_patterns(session_data)
# Store knowledge
knowledge_record = create_knowledge_record(
session_data=session_data,
lessons=lessons,
patterns=patterns
)
# Update knowledge base
store_knowledge_record(knowledge_record)
# Update pattern database
update_pattern_database(patterns)
return knowledge_record- Use lightweight embeddings (e.g., sentence-transformers/all-MiniLM-L6-v2)
- Store embeddings locally for fast retrieval
- Semantic similarity matching for finding relevant past solutions
def search_knowledge_base(query, context=None):
# 1. Keyword search for exact matches
keyword_results = keyword_search(query)
# 2. Semantic search for similar issues
semantic_results = semantic_search(query, top_k=5)
# 3. Context-aware filtering
if context:
results = filter_by_context(
keyword_results + semantic_results,
context
)
# 4. Rank by relevance and recency
return rank_results(results)- Analyze successful resolution sequences
- Identify recurring failure types and solutions
- Build solution templates for common issues
- Failure Patterns: Common CI failure types and causes
- Solution Patterns: Proven resolution approaches
- Context Patterns: Environment-specific considerations
- Temporal Patterns: Time-based correlations (CI load, etc.)
# 1. Quick knowledge scan
CCKMS_scan_recent_sessions()
# 2. Context-aware retrieval
CCKMS_find_similar_issues(current_branch, current_failures)
# 3. Pattern matching
CCKMS_suggest_solutions(failure_patterns, historical_success)
# 4. Integration with existing workflow
TaskMaster_integrate_historical_context(knowledge_results)- File-based Storage: JSON files for persistence
- Embedding Engine: Local sentence transformers
- Search Index: Inverted index for keywords
- Pattern Matcher: Rule-based + ML pattern recognition
- Integration Layer: MCP tool integration
- File System Access: Read/Write for knowledge storage
- TaskMaster AI: Session tracking and completion
- MCP Tools: Integration with existing workflow
- Search Tools: Grep/Glob for knowledge base queries
- Automatic: Extract data from TaskMaster session
- Manual: Add specific insights and lessons learned
- Validation: Ensure quality and completeness
- Storage: Persist to knowledge base with embeddings
- Context Analysis: Understand current situation
- Similarity Search: Find relevant past sessions
- Pattern Matching: Identify applicable solutions
- Recommendation: Suggest approaches based on history
- Success Analysis: What approaches worked?
- Failure Analysis: What approaches failed?
- Pattern Evolution: Update patterns based on new data
- Knowledge Pruning: Remove outdated information
- Faster Resolution: Leverage past solutions
- Pattern Recognition: Identify recurring issues
- Best Practices: Build institutional knowledge
- Context Awareness: Environment-specific insights
- Seamless Workflow: Integrated with existing tools
- Persistent Memory: Survives context boundaries
- Searchable History: Quick access to past solutions
- Evolutionary Learning: Improves over time
- Documentation: Automatic capture of solutions
- Knowledge Transfer: Preserve expertise
- Consistency: Standardized approaches
- Training: Historical examples for learning
- Storage: ~1MB per session record
- Search: <200ms response time for queries
- Embedding: <1s for similarity search
- Integration: No impact on existing workflow speed
- Sessions: Support 1000+ session records
- Patterns: Track 100+ distinct patterns
- Search: Efficient even with large knowledge base
- Maintenance: Automatic cleanup and optimization
- Local Storage: All data stays on local file system
- No External APIs: Embeddings computed locally
- Git Integration: Knowledge base can be version controlled
- Access Control: File system permissions
- Graph-based Knowledge: Relationship mapping between sessions
- Predictive Analysis: Anticipate likely solutions
- Collaborative Features: Team knowledge sharing
- Integration APIs: Connect with external tools
- Custom Embeddings: Fine-tuned for CI troubleshooting
- Automated Classification: AI-powered pattern recognition
- Success Prediction: Probability scoring for solutions
- Adaptive Learning: Self-improving knowledge base