一键导入
continuous-learning
Automatically extract reusable patterns from Claude Code sessions and evolve them into learned skills, instincts, and custom instructions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automatically extract reusable patterns from Claude Code sessions and evolve them into learned skills, instincts, and custom instructions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | continuous-learning |
| version | 2.0.0 |
| description | Automatically extract reusable patterns from Claude Code sessions and evolve them into learned skills, instincts, and custom instructions. |
| triggers | ["session end","/learn command","pattern detection threshold met"] |
Automatically evaluate Claude Code sessions, extract reusable patterns, and evolve them into actionable knowledge that improves future interactions.
This skill transforms your Claude Code sessions into a self-improving knowledge base. Rather than losing valuable insights when a session ends, it captures patterns, corrections, and solutions, then organizes them for future use.
Session Activity
│
▼
┌─────────────────┐
│ Observation │ ← Hooks capture all tool use and corrections
│ Layer │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Analysis │ ← Background agent identifies patterns
│ Engine │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Instinct │ ← Atomic behaviors with confidence scores
│ Store │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Evolution │ ← Cluster instincts into skills/instructions
│ Pipeline │
└─────────────────┘
Hooks provide 100% reliable observation of session activity:
| Hook Type | Captures |
|---|---|
PreToolUse | Intent before tool execution |
PostToolUse | Results and any failures |
Stop | Full session context at end |
The system identifies these pattern types:
| Pattern | Description | Example |
|---|---|---|
error_resolution | How specific errors were solved | "ECONNREFUSED on port 3000 → check if server running" |
user_corrections | When user corrects Claude's approach | "Don't use semicolons in this codebase" |
workarounds | Solutions for framework quirks | "Next.js 14: use 'use client' for useState" |
debugging_techniques | Effective debugging methods | "Add console.log before async boundaries" |
project_conventions | Project-specific patterns | "This repo uses kebab-case for file names" |
tool_preferences | Preferred tools/approaches | "User prefers ripgrep over grep" |
Patterns are stored as instincts: atomic behavioral units with metadata:
{
"id": "inst_a1b2c3",
"trigger": "when encountering CORS error in fetch",
"behavior": "check if backend has cors middleware enabled",
"confidence": 0.7,
"domain": ["debugging", "api"],
"source_sessions": ["session_123", "session_456"],
"created_at": "2025-02-10T14:30:00Z",
"last_validated": "2025-02-11T09:15:00Z"
}
Confidence Scoring:
High-confidence instincts (0.7+) evolve into higher-order constructs:
Instincts (0.7+)
│
├──► Skill Files (3+ related instincts)
│ └── ~/.claude/skills/learned/debugging-react.md
│
├──► Custom Instructions (behavioral patterns)
│ └── Added to CLAUDE.md or settings
│
└──► Agent Templates (complex workflows)
└── Reusable multi-step procedures
Create ~/.claude/continuous-learning/config.json:
{
"observation": {
"hooks_enabled": true,
"min_session_messages": 8,
"capture_tool_failures": true,
"capture_user_edits": true
},
"analysis": {
"background_model": "haiku",
"extraction_threshold": "medium",
"domains": [
"code-style",
"testing",
"git",
"debugging",
"api",
"database",
"deployment"
]
},
"instincts": {
"initial_confidence": 0.5,
"evolution_threshold": 0.7,
"decay_rate": 0.05,
"archive_threshold": 0.3,
"max_instincts": 500
},
"evolution": {
"auto_approve": false,
"cluster_min_instincts": 3,
"skill_output_path": "~/.claude/skills/learned/",
"instruction_output_path": "~/.claude/instructions/"
},
"ignore_patterns": [
"simple_typos",
"one_time_fixes",
"external_api_outages",
"rate_limit_errors"
]
}
Add to ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/continuous-learning/observe.sh pre $TOOL_NAME"
}]
}],
"PostToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/continuous-learning/observe.sh post $TOOL_NAME $EXIT_CODE"
}]
}],
"Stop": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/continuous-learning/analyze-session.sh"
}]
}]
}
}
~/.claude/continuous-learning/
├── config.json
├── observe.sh
├── analyze-session.sh
├── instincts/
│ ├── active/
│ │ └── inst_*.json
│ └── archived/
├── sessions/
│ └── session_*.log
└── exports/
└── instincts-export.json
observe.sh - Captures tool events:
#!/bin/bash
# Lightweight event capture - runs on every tool use
EVENT_TYPE=$1
TOOL_NAME=$2
EXIT_CODE=$3
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "{\"type\":\"$EVENT_TYPE\",\"tool\":\"$TOOL_NAME\",\"exit\":\"$EXIT_CODE\",\"ts\":\"$TIMESTAMP\"}" \
>> "$HOME/.claude/continuous-learning/sessions/current.log"
analyze-session.sh - Runs at session end:
#!/bin/bash
# Full analysis at session end - can be heavier
SESSION_LOG="$HOME/.claude/continuous-learning/sessions/current.log"
CONFIG="$HOME/.claude/continuous-learning/config.json"
# Check minimum session length
MSG_COUNT=$(wc -l < "$SESSION_LOG")
MIN_MSGS=$(jq -r '.observation.min_session_messages' "$CONFIG")
if [ "$MSG_COUNT" -lt "$MIN_MSGS" ]; then
exit 0
fi
# Trigger background analysis
# This calls Claude with Haiku to extract patterns
~/.claude/continuous-learning/extract-patterns.py "$SESSION_LOG" &
Use during a session to immediately capture a pattern:
/learn "pattern description"
Examples:
/learn "this project uses pnpm not npm"/learn "always run tests before committing"/learn "API responses need camelCase transformation"/instincts [domain]
Shows active instincts, optionally filtered by domain.
Share instincts between machines or team members:
/instincts export > my-instincts.json
/instincts import < team-instincts.json
Trigger: Claude encounters "Module not found: Can't resolve '@/components'"
Learned Instinct:
{
"trigger": "Module not found with @ alias",
"behavior": "Check tsconfig.json paths configuration and verify baseUrl is set correctly",
"confidence": 0.85,
"domain": ["debugging", "typescript"]
}
Session Event: User says "No, use the existing logger, don't create a new one"
Learned Instinct:
{
"trigger": "Need logging functionality",
"behavior": "Search for existing logger/logging utilities before creating new ones",
"confidence": 0.9,
"domain": ["code-style", "project_conventions"]
}
After 5+ related instincts about this project's conventions:
~/.claude/skills/learned/acme-project-conventions.md:
# ACME Project Conventions
## Logging
- Use existing `src/utils/logger.ts` for all logging
- Never instantiate new console.log patterns
## Imports
- Use @ alias for src/ directory
- Prefer named exports over default
## Testing
- Co-locate tests with source files (*.test.ts)
- Use vitest, not jest
| Component | Impact | Mitigation |
|---|---|---|
| PreToolUse hook | ~5ms per tool | Minimal logging only |
| PostToolUse hook | ~5ms per tool | Append-only file writes |
| Stop hook analysis | ~2-5s once | Background process, non-blocking |
| Instinct lookup | ~10ms | In-memory cache with domain indexing |
| Aspect | v1 (Original) | v2 (This Version) |
|---|---|---|
| Observation | Stop hook only (end of session) | Pre/Post hooks (100% coverage) |
| Granularity | Full skills | Atomic instincts that evolve |
| Confidence | None | 0.0-1.0 with decay/growth |
| Learning | Direct to skills | Instincts → Clusters → Skills |
| Sharing | Not supported | Export/Import instincts |
| Domains | Generic | Tagged by domain |
| Analysis | Main context | Background agent (Haiku) |
Instincts not being created:
min_session_messages threshold~/.claude/continuous-learning/sessions/ for logsToo many low-quality instincts:
extraction_threshold to "high"ignore_patternsinitial_confidence to require more validationInstincts not evolving to skills:
evolution_thresholdcluster_min_instincts related instincts exist/instincts evolve to manually trigger clusteringThis skill continuously improves Claude's effectiveness by learning from every session. The more you use it, the better it understands your preferences, project conventions, and effective problem-solving patterns.