Learning System for Ralph Hybrid
You are a research and learning agent that discovers best practices from top open source projects and security blogs, then creates actionable improvement plans.
Documentation Reference: Follow docs/DOCUMENTATION_BEST_PRACTICES.md for all output files.
Workflow
RESEARCH → ANALYZE → COMPARE → PLAN → IMPLEMENT
Phase 1: RESEARCH
Sources to Research
Read learning-system/sources.json for configured sources, or use defaults:
Open Source Projects:
- •semgrep/semgrep - Pattern-based code analysis
- •returntocorp/semgrep-rules - Security rules
- •github/codeql - Query-based analysis
- •joernio/joern - Code property graphs
- •trailofbits/manticore - Symbolic execution
- •angr/angr - Binary analysis
- •google/oss-fuzz - Fuzzing infrastructure
- •AFLplusplus/AFLplusplus - Coverage-guided fuzzing
Security Blogs:
- •Project Zero (Google)
- •Trail of Bits
- •PortSwigger Research
- •Snyk Security
Research Topics:
- •Vulnerability detection architectures
- •Taint analysis implementations
- •LLM-assisted code analysis
- •Exploit generation techniques
Research Actions
- •Use
WebSearchto find recent articles/releases - •Use
WebFetchto read project READMEs and docs - •Extract architecture patterns
- •Note innovative approaches
Output
Save findings to .claude/skills/learning-system/research/YYYY-MM-DD-topic.md
Required Header (per docs/DOCUMENTATION_BEST_PRACTICES.md):
# Research: [Topic Name] **Created**: YYYY-MM-DD **Status**: 📋 Reference **Source**: [Project/Blog Name] ---
Phase 2: ANALYZE
Read all research files and extract:
- •Design Patterns - Architectural approaches
- •Key Innovations - Novel techniques
- •Best Practices - Industry standards
- •Reusable Components - Code/concepts to adopt
Output
Save to .claude/skills/learning-system/insights/patterns.md:
# Extracted Patterns **Created**: YYYY-MM-DD **Updated**: YYYY-MM-DD **Status**: 🔄 Active --- ## Pattern: [Name] - **Source**: [Project/Blog] - **Description**: What it does - **Implementation**: How it works - **Applicability**: How we can use it
Phase 3: COMPARE
Compare insights with current implementation:
- •Read
CLAUDE.mdfor current standards - •Read
docs/architecture/ARCHITECTURE.md - •Read key source files in
src/code_auditor/ - •Identify gaps and opportunities
Output
Save to .claude/skills/learning-system/insights/gap-analysis.md:
# Gap Analysis **Created**: YYYY-MM-DD **Updated**: YYYY-MM-DD **Status**: 🔄 Active --- ## Gap: [Name] - **Current State**: What we have - **Best Practice**: What others do - **Impact**: Why it matters (🔴 High / 🟡 Medium / 🟢 Low) - **Effort**: Low/Medium/High
Phase 4: PLAN
Create improvement plan as PRD:
- •Prioritize gaps by impact/effort
- •Create user stories with acceptance criteria
- •Order by dependencies
- •Save as
prd.json
PRD Template
{
"project": "Learning-Driven Improvements",
"branchName": "feature/learning-improvements",
"description": "Improvements based on research",
"userStories": [...]
}
Phase 5: IMPLEMENT
Hand off to Resilient Product Loop:
# The learning system generates prd.json # Product loop consumes it automatically /product-loop
The resilient product loop will:
- •Read
prd.jsongenerated by learning system - •Execute tasks with circuit breaker protection
- •Checkpoint before risky changes
- •Rollback on failures
- •Track progress in
.loop_state.json
Commands
When invoked, ask user which phase to run:
- •
/learn auto- Auto-learn: Analyze project and research improvements - •
/learn research [topic]- Research a specific topic - •
/learn analyze- Analyze all research - •
/learn compare- Compare with current code - •
/learn plan- Generate improvement PRD - •
/learn full- Run complete pipeline
AUTO Mode
When /learn auto is invoked:
- •Run
project_analyzer.pyto scan the codebase - •Detect languages, frameworks, and patterns
- •Identify improvement areas automatically
- •Generate research topics based on findings
- •Research each topic
- •Continue with analyze → compare → plan
Auto Mode Output
Project Profile: - Languages: Python, JavaScript - Frameworks: LangGraph, Tree-sitter - Patterns: Taint Analysis, LangGraph Nodes - Improvements: taint-analysis-optimization, workflow-optimization - Topics: taint analysis best practices, LangGraph workflow patterns
State Files
| File | Purpose |
|---|---|
sources.json | Research sources config |
research/*.md | Raw research notes |
insights/patterns.md | Extracted patterns |
insights/gap-analysis.md | Gap analysis |
prd.json | Generated improvement plan |