Continuous Learning Skill
Automatically improve Claude Code's capabilities by identifying and preserving useful patterns from sessions.
Core Concept
Every session is a learning opportunity. This skill extracts reusable patterns and saves them as skills for future sessions.
What Gets Learned
Pattern Categories
| Category | Description | Example |
|---|---|---|
| Error Resolution | Solutions to specific errors | "Module not found" → check tsconfig paths |
| User Corrections | Insights from user feedback | "Always use absolute imports in this project" |
| Workarounds | Framework/library limitations | "Next.js 15 requires 'use client' for useState" |
| Debugging Techniques | Effective problem-solving | "Check network tab for API issues first" |
| Project Conventions | Session-specific standards | "Use Zustand for global state" |
What NOT to Learn
- •Simple typos (one-time fixes)
- •Project-specific secrets or credentials
- •Temporary workarounds that will be removed
- •Personal preferences that vary by project
How It Works
Session End Analysis
The continuous-learning.sh hook runs at session end:
Session ends
↓
Hook analyzes session patterns
↓
Detects learnable content
↓
Creates learning prompt
↓
Skills saved to ~/.claude/skills/learned/
Pattern Detection
The hook looks for signals:
- •Error resolutions - Commits with "fix", "error", "bug"
- •Workarounds - Code comments with "workaround", "HACK", "TODO"
- •New patterns - Multiple new files created
- •User corrections - (Requires Claude analysis)
Creating Learned Skills
Automatic (via Hook)
When patterns are detected, a prompt file is created:
~/.claude/skills/learned/.pending_[timestamp].txt
Review and convert to a skill if valuable.
Manual
Create a skill file directly:
---
name: nextjs-15-server-actions
learned_from: my-app
date: 2026-01-22
---
# Next.js 15 Server Actions Pattern
## Context
Learned while building authentication in my-app.
## Pattern
Server actions in Next.js 15 require specific setup:
1. Create in separate file with 'use server' directive
2. Import in client component
3. Handle errors with try/catch
4. Return typed responses
## Example
\`\`\`typescript
// app/actions/auth.ts
'use server'
import { z } from 'zod'
const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(8)
})
export async function login(formData: FormData) {
const parsed = loginSchema.safeParse({
email: formData.get('email'),
password: formData.get('password')
})
if (!parsed.success) {
return { error: parsed.error.message, success: false }
}
// ... auth logic
return { data: user, success: true }
}
\`\`\`
## When to Use
- Building forms with server-side validation
- Actions that modify database state
- Authentication flows
Skill Storage
Location
~/.claude/skills/learned/ ├── nextjs-15-server-actions.md ├── zustand-async-patterns.md ├── vitest-mocking-strategies.md └── .pending_20260122_103000.txt # Awaiting review
Skill Format
--- name: skill-name # Unique identifier learned_from: project-name # Source project date: YYYY-MM-DD # When learned tags: [tag1, tag2] # Optional categorization --- # Title ## Context [When and why this was learned] ## Pattern [The actual technique/pattern] ## Example [Code example if applicable] ## When to Use [Activation criteria]
Using Learned Skills
At Session Start
The session-start.sh hook lists available skills:
[Memory] 3 learned skill(s) available from previous sessions [Memory] - nextjs-15-server-actions [Memory] - zustand-async-patterns [Memory] - vitest-mocking-strategies
Explicit Reference
Ask Claude to apply a learned skill:
Use the zustand-async-patterns skill for this state management
Automatic Activation
Skills with clear triggers activate automatically when relevant context appears.
Skill Lifecycle
Creation
- •Session produces valuable pattern
- •Hook detects pattern signals
- •Prompt file created for review
- •Convert to skill if valuable
Refinement
- •Use skill in new context
- •Note improvements needed
- •Update skill with better examples
- •Add edge cases discovered
Retirement
- •Pattern becomes obsolete (framework update)
- •Better pattern discovered
- •Move to archive or delete
Best Practices
For High-Quality Skills
- •Be specific - "Zustand async patterns" not "state management"
- •Include context - When and why this matters
- •Provide examples - Working code, not just descriptions
- •Note limitations - When this doesn't apply
For Effective Learning
- •Review pending skills - Don't let prompts pile up
- •Merge similar skills - Combine related patterns
- •Update outdated skills - Frameworks evolve
- •Prune unused skills - Quality over quantity
Integration
With Memory Persistence
- •Sessions save learning opportunities
- •Skills persist across sessions
- •Project context informs relevance
With Strategic Compaction
- •Compact after learning sessions
- •Skills summarize key patterns
- •Context preserved in skills
With Verification Loop
- •Verify learned patterns work
- •Update skills with test results
- •Document edge cases found
Circuit Breaker Pattern
The learning hook implements a circuit breaker to prevent stuck states and wasteful processing:
Detection Triggers
| Condition | Threshold | Action |
|---|---|---|
| No file changes | 3 loops | Skip learning extraction |
| Identical errors | 5 occurrences | Mark session as stuck |
| Declining output | >70% reduction | Suggest session reset |
| Session too short | <10 messages | Skip analysis entirely |
Recovery Actions
# When stuck state detected: 1. Log the stuck condition 2. Skip learning extraction for this session 3. Suggest user intervention or session restart 4. Preserve partial learnings if any
Manual Reset
# Reset circuit breaker state rm ~/.claude/.learning_state # Force learning extraction despite circuit breaker FORCE_LEARNING=1 claude
Configuration
In continuous-learning.sh:
MIN_MESSAGES=10 # Minimum session length for analysis STUCK_THRESHOLD=5 # Identical errors before marking stuck OUTPUT_DECLINE_THRESHOLD=0.7 # 70% decline triggers warning
Disable for Session:
export SKIP_LEARNING_HOOK=1
Example Workflow
1. Work on feature, encounter and solve tricky issue 2. Session ends, hook detects error-resolution pattern 3. Prompt file created: .pending_20260122_103000.txt 4. Review prompt, decide pattern is valuable 5. Create skill: ~/.claude/skills/learned/api-retry-pattern.md 6. Next session: skill loaded and available 7. Similar problem arises: skill provides solution 8. Refine skill with new edge case
Remember
- •Every session teaches something - Be attentive to patterns
- •Quality over quantity - Few good skills > many mediocre ones
- •Skills compound - Today's learning speeds up tomorrow's work
- •Review regularly - Keep skills current and relevant