borghei/self-improving-agent
> Patterns for AI agents that learn from their own execution, detect failure modes, and improve autonomously. Use when building agents that get better over time, managing auto- memory, or designing self-correcting feedback loops.
npx skills add https://github.com/borghei/Claude-Skills --skill self-improving-agent
Architectural patterns for AI agents that get better with use. Most agents are stateless -- they repeat mistakes because they cannot learn from their own execution. This skill closes that gap with patterns for feedback capture, memory curation, skill extraction, and regression detection. Key insight: auto-memory captures everything, but curation turns noise into knowledge.
Before capturing or promoting learnings, confirm these inputs. If any is unknown or vague, ASK — do not assume:
MEMORY.md, and rules dir to operate on (the subject the tools read and write)--min-occurrences; decides what is kept vs discarded)Stop rule: ask only the 2-3 that most change the output. If the user says "just draft it," proceed and list your assumptions at the top of the artifact.
Compound sub-skill architecture — each file in skills/ handles one step of the improvement loop:
| Sub-Skill | File | Purpose |
|-----------|------|---------|
| Remember | skills/remember.md | Capture errors and learnings from current session |
| Extract | skills/extract.md | Extract reusable patterns from completed work |
| Promote | skills/promote.md | Graduate proven patterns to permanent rules |
| Review | skills/review.md | Audit memory health, prune stale entries |
| Status | skills/status.md | Dashboard showing memory state and learning progress |
Flow: Remember → Extract → Promote → Review, with Status providing visibility back into the cycle.
| Tool | Purpose | Command |
|------|---------|---------|
| pattern_extractor.py | Extract reusable patterns from session logs | python scripts/pattern_extractor.py --input sessions.jsonl --min-occurrences 3 |
| memory_health_checker.py | Audit memory for line counts, stale, and promotable entries | python scripts/memory_health_checker.py --memory ./MEMORY.md --rules ./.claude/rules/ |
| rule_promoter.py | Validate and apply promotions from memory to rules | python scripts/rule_promoter.py --memory ./MEMORY.md --list-candidates |
| feedback_analyzer.py | Analyze feedback logs for success rates and opportunities | python scripts/feedback_analyzer.py analyze |
| regression_detector.py | Compare baseline vs current performance metrics | python scripts/regression_detector.py compare |
| rule_manager.py | Manage a learned rules knowledge base with CRUD | python scripts/rule_manager.py list |
Load the reference that matches the task — keep this file lean and pull detail on demand:
This skill covers:
This skill does NOT cover:
agent-workflow-designer and agent-protocol.prompt-engineer-toolkit.observability-designer.agent-designer.| Skill | Integration | Data Flow |
|-------|-------------|-----------|
| context-engine | Controls what the agent sees per session; this skill decides what is worth remembering long-term | Promoted rules and curated memory feed context retrieval; context relevance metrics flow back for regression tracking |
| agent-designer | Defines the agent's architecture and capabilities; this skill layers learning infrastructure on top | Architecture constraints inform possible feedback loops; extracted skills feed back as new capabilities |
| prompt-engineer-toolkit | Prompts degrade as codebases evolve; this skill detects prompt regression via outcome tracking | Performance metrics flag underperforming prompts; prompt updates feed back as CLAUDE.md rule changes |
| observability-designer | Provides system-level metrics; this skill provides agent-behavior-level metrics | System telemetry enriches regression diagnosis; agent metrics export to observability dashboards |
| tech-debt-tracker | Stale rules and bloated memory are technical debt this can surface alongside code debt | Memory health metrics feed debt scoring; debt prioritization informs which stale rules to retire |
| agent-workflow-designer | Multi-step workflows benefit from per-step feedback capture and cross-workflow pattern extraction | Per-step outcome data flows into feedback loops; extracted optimizations update workflow definitions |
Take borghei/self-improving-agent from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.