| name | automating-self-improvement |
| description | Meta-skill that automates the 10-step improvement cycle - detects patterns, generates skills, creates commands, and triggers documentation. Use when user invokes /auto-improve or says detect inefficiency. |
| status | Active |
| version | 2.0.0 |
| triggers | /auto-improve, /audit-efficiency, detect inefficiency, generate skill |
Self-Improvement Engine (Meta-Skill)
Purpose: Automate the recursive feedback loop that makes Claude Code self-optimizing.
Reference: See reference.md for full scripts, examples, and metrics.
Core Principle
Claude Code sessions are ephemeral, but patterns are eternal.
This meta-skill closes the loop:
Experience inefficiency → Detect pattern → Codify solution → Automate future → Document
The 10-Step Recursive Cycle
Plan → Correct → Execute → Test → Fix → Create Skill → Create Command →
Add to CLAUDE.md → Write Medium Article → [REPEAT with meta-improvements]
Commands
| Command | Purpose |
|---|---|
/auto-improve |
Run full cycle (detect → generate → optimize) |
/detect-inefficiency |
Scan history for patterns |
/generate-skill <pattern> |
Create skill from detected pattern |
/audit-efficiency |
Score session against @rules/efficiency-rules.md |
Architecture
6 Modules
| Module | Purpose |
|---|---|
| Pattern Detection | Mine history.jsonl for recurring inefficiencies |
| Skill Generation | Auto-create SKILL.md from detected patterns |
| Command Creation | Register slash commands for new skills |
| CLAUDE.md Integration | Auto-update Skills System section |
| Documentation Pipeline | Trigger Medium article generation |
| Efficiency Audit | Real-time scoring using @rules/efficiency-rules.md |
Pattern Detection
Temporal Analysis Protocol
CRITICAL: Always use timestamp-based filtering, NOT arbitrary line counts.
history.jsonlformat:{"timestamp": 1762421400000, ...}(epoch ms)- HEAD = oldest entries, TAIL = newest entries
- NEVER use
tail -n 500for time-based analysis
Core Inefficiency Signatures
| Pattern | Threshold | Severity | Suggested Skill |
|---|---|---|---|
| repeated-file-reads | 3 | major | file-caching |
| temp-script-creation | 2 | major | direct-implementation |
| dependency-folder-read | 1 | critical | path-exclusion-enforcer |
| cli-command-chains | 3 | minor | command-aliasing |
| context-loss | 2 | minor | enhanced-memory |
Scoring
- Critical: 10 points
- Major: 5 points
- Minor: 3 points
- Trigger skill generation: Score >= 10
Skill Generation
Template-Based Process
- Load
~/.claude/templates/skills/SKILL.template.md - Extract context from detected pattern occurrences
- Fill placeholders (skill_name, purpose, triggers, examples)
- Validate (YAML frontmatter, no unfilled placeholders)
- Save to
~/.claude/skills/<skill-name>/SKILL.md - Update CLAUDE.md Skills System section
Efficiency Audit
Process
- Load @rules/efficiency-rules.md
- Scan session's tool usage
- Count violations by category
- Calculate score:
(major * 10) + (minor * 3) - Generate report with specific violations + remediation
Grade Scale
| Score | Grade |
|---|---|
| 0 | Perfect ✅ |
| 1-6 | Good 👍 |
| 7-15 | Needs Improvement ⚠️ |
| 16+ | Critical 🚨 |
Workflow Summary
/detect-inefficiency
- Calculate time window (default: last 4 hours)
- Filter history.jsonl by timestamp
- Run pattern matching against all signatures
- Score and rank by severity
- Present report with recommendations
/generate-skill
- Validate pattern exists in patterns.json
- Extract examples from history
- Fill template with context
- Validate generated skill
- Save and register
- Update CLAUDE.md
- Offer next steps (review, test, document, commit)
/auto-improve (Full Cycle)
- Detect inefficiencies
- Select highest priority pattern
- Generate skill
- Audit improvement
- Document (trigger Medium article)
- Commit (with user approval)
- Recurse (check if meta-skill can improve itself)
Integration Points
| Skill | Usage |
|---|---|
chat-history-search |
Mine history for patterns |
medium-article-writer |
Auto-trigger article after skill creation |
pr-automation |
Create PR for new skills |
@rules/efficiency-rules.md |
Score sessions |
Anti-Patterns
Don't
- ❌ Generate skills for one-off issues (need 3+ occurrences)
- ❌ Over-automate (some manual decisions are good)
- ❌ Skip validation (always review auto-generated skills)
- ❌ Ignore false positives (intentional repetition exists)
- ❌ Create duplicate skills (enhance existing instead)
Do
- ✅ Validate patterns before generating skills
- ✅ Test generated skills in real usage
- ✅ Track metrics to measure improvement
- ✅ Iterate on meta-skill itself (recursion!)
- ✅ Maintain human-in-the-loop for critical decisions
Token Budget
| Component | Tokens |
|---|---|
| Pattern detection | ~500 |
| Skill generation | ~800 |
| CLAUDE.md update | ~200 |
| Article generation | ~2000 |
| Audit | ~500 |
| Total per cycle | ~4000 |
Optimisations
- Stream history.jsonl with
tail -n 1000 - Parallel pattern matching
- Template caching
- Lazy article generation
- Incremental CLAUDE.md updates
Recursive Self-Improvement
The Ultimate Goal
Meta-skill improves meta-skill improves meta-skill → ∞
Safety Gates
- Human Approval - All self-modifications require user confirmation
- Rollback Mechanism - Git-track all changes
- Version Locking - Test before production
- Similarity Check - Prevent duplicates
Convergence Condition
Zero patterns detected for 10 consecutive sessions = local optimum reached.
Implementation
Fully operational via ~/.claude/optim.sh:
./optim.sh detect # Pattern detection (timeout: 180000)
./optim.sh generate # Skill generation
./optim.sh optimize # Meta-optimization (recursion!)
./optim.sh cycle # Full cycle (timeout: 600000)
Architecture
- Layer 0: Utilities (logging, validation, JSON)
- Layer 1: Pattern Detection (scan, match, score)
- Layer 2: Skill Generation (template fill, validate)
- Layer 3: Meta-Optimization (THE RECURSION)
- Layer 4: Orchestration (command routing)
Reference Material
For detailed implementations, see reference.md:
- Full detection/generation/audit scripts
- Example outputs for each workflow
- Metrics tracking schema
- Recursion protocol with examples
- Full changelog
Skill Status: ✅ Active (Meta-Skill) Maintainer: LC Scheepers Last Updated: 2025-11-06 Recursion Depth: 0 (increments as meta-skill improves itself)
⛓⟿∞