continuous-learning-agent
Self-improvement patterns for AI agents to learn from feedback, errors, and successful patterns across sessions
What this skill does
# Continuous Learning Agent
A meta-skill that enables AI agents to learn from experience and improve over time by separating journaled memory from policy changes that alter future behavior.
## Core Concept
Traditional agents reset completely between sessions. This skill treats memory and learning as related but distinct operations:
- **Journal / memory** records what happened, what was tried, and what evidence exists.
- **Learning / policy** changes what the agent will do next time for a recognizable event class.
Do not call a session log, decision journal, or context note "learning" unless it produces a policy delta, threshold revision, banned move, or acquired pattern that changes future behavior.
## Learning Mechanisms
Every learning loop has two layers:
1. **Journal layer**: episodic or semantic records used for auditability.
2. **Policy layer**: compact behavioral deltas used to improve performance on future tasks.
The journal layer is optional when an existing memory system already covers it. The policy layer is mandatory for this skill.
### 1. Error Pattern Recognition
After each error, first document the event if no existing memory system already captures it:
```markdown
## Error Log Entry
**Date**: 2026-01-30
**Context**: Implementing user authentication
**Error**: TypeError: Cannot read property 'id' of undefined
**Root Cause**: Missing null check before accessing user object
**Fix**: Added optional chaining: user?.id
**Pattern**: Always validate object existence before property access
**Prevention**: Add TypeScript strict null checks
```
Then extract the policy delta:
```markdown
## Policy Delta: [Short Title]
**Date**: 2026-01-30
**Event Class**: Accessing nested properties on possibly absent objects
**Prior Policy**: Read nested properties directly after optimistic object construction.
**Failure Mode**: Undefined objects caused runtime TypeErrors.
**Revised Policy**: Validate object existence or use typed optional access before nested reads.
**Trigger**: Any code path receiving user, API, database, or tool-returned objects.
**Propagation Target**: Project AGENTS.md, test helper, lint rule, or skill source.
**Verification**: Add or run a test that fails under the prior policy and passes under the revised policy.
```
### 2. Success Pattern Collection
After successful implementations, record both the reusable pattern and the policy form that lets future agents apply it without replaying the whole story:
```markdown
## Success Pattern
**Task**: Add pagination to API endpoint
**Approach**: Cursor-based pagination with encoded tokens
**Why It Worked**: Handles large datasets efficiently, stateless
**Reusable Pattern**:
- Use cursor tokens instead of offset/limit
- Encode cursor with base64
- Include hasNext/hasPrevious flags
- Return next/previous cursor in response
**Code Template**:
\`\`\`typescript
interface PaginatedResponse<T> {
data: T[];
cursor: {
next: string | null;
previous: string | null;
};
}
\`\`\`
```
```markdown
## Acquired Pattern
**Event Class**: API endpoints returning large ordered datasets
**Revised Policy**: Prefer cursor tokens over offset pagination unless the product explicitly needs random page access.
**Trigger**: New list endpoint over a growing table or external API collection.
**Verification**: Exercise first page, next page, empty page, and invalid cursor behavior.
```
### 3. Feedback Integration
Use the active project's policy surface when one exists. Examples:
- `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, or other runtime instruction files for enduring operating rules.
- `.claude/policy/`, `.codex/policy/`, `.agents/policy/`, or equivalent for local policy deltas.
- A governed memory or feedback-note repository when the user has established one.
Only create a local journal directory when there is no stronger existing memory surface:
```bash
mkdir -p .claude/journal .claude/policy/deltas
```
Store journal records and policy deltas separately:
```
.claude/journal/
patterns/
authentication.md
database-queries.md
error-handling.md
mistakes/
common-bugs.md
performance-issues.md
preferences/
code-style.md
testing-approach.md
naming-conventions.md
.claude/policy/
deltas/
2026-01-30-null-check-before-property-access.md
banned-moves.md
thresholds.md
acquired-patterns.md
```
### 4. Decision Journal
Before major decisions:
```markdown
## Decision: [Title]
**Context**: Current situation requiring decision
**Options Considered**:
1. Option A - Pros: X, Cons: Y
2. Option B - Pros: X, Cons: Y
3. Option C - Pros: X, Cons: Y
**Decision**: Chose Option B
**Reasoning**: Detailed explanation
**Expected Outcome**: What we expect to happen
**Actual Outcome**: (Fill after implementation)
**Policy Delta**: What future behavior changes because of this decision
```
## Learning Loops
### Daily Review Loop
At end of coding session:
```markdown
## Session Review - [Date]
**What Went Well**:
- Successfully implemented X
- Discovered pattern Y
- Improved performance of Z
**What Could Improve**:
- Spent too long debugging A
- Should have tested B earlier
- Missed edge case C
**Journal Notes**:
1. Notable event 1
2. Notable event 2
**Policy Deltas**:
1. Event class -> revised behavior
2. Event class -> revised threshold
**Action Items**:
- [ ] Apply policy delta to the correct instruction or policy file
- [ ] Verify the new behavior with a test, checklist, or next-session review
```
### Weekly Synthesis Loop
Every week, review and synthesize:
```bash
# Generate weekly summary
grep -h "^**Policy Deltas**" .claude/journal/daily/*.md -A 5 > weekly-policy-synthesis.md
```
```markdown
## Weekly Synthesis - Week of [Date]
**Emerging Policy Changes**:
- Pattern 1: Description
- Pattern 2: Description
**Recurring Issues**:
- Issue 1: Root cause analysis
- Issue 2: Root cause analysis
**Rules to Promote**:
- Rule 1: Target file and reason
- Rule 2: Target file and reason
**Next Week Focus**:
- Focus area 1
- Focus area 2
```
## Adaptive Strategies
### Context Awareness
Maintain context file:
```markdown
# Project Context
**Type**: Web application / API / CLI tool / Library
**Tech Stack**: Next.js, TypeScript, Prisma, PostgreSQL
**Architecture**: Monorepo with packages: api, web, shared
**Key Patterns**:
- Feature-based folder structure
- Repository pattern for data access
- Service layer for business logic
**Team Preferences**:
- Test coverage: 80% minimum
- Code style: Prettier + ESLint
- Commit messages: Conventional commits
- PR process: Requires review + CI pass
```
### Progressive Refinement
Track understanding level:
```markdown
## Understanding Map
**Well Understood** (★★★):
- Authentication flow
- Database schema
- API endpoints
**Partially Understood** (★★):
- Caching strategy
- Error handling patterns
**Need to Learn** (★):
- Deployment process
- Monitoring setup
- Feature flags system
```
## Implementation Hooks
### Post-Task Hook
After completing any task:
```bash
#!/bin/bash
# .claude/hooks/post-task.sh
echo "## Task Completed: $1" >> .claude/journal/daily/$(date +%Y-%m-%d).md
echo "" >> .claude/journal/daily/$(date +%Y-%m-%d).md
echo "**Approach**: $2" >> .claude/journal/daily/$(date +%Y-%m-%d).md
echo "**Outcome**: $3" >> .claude/journal/daily/$(date +%Y-%m-%d).md
echo "**Policy Delta**: $4" >> .claude/journal/daily/$(date +%Y-%m-%d).md
echo "" >> .claude/journal/daily/$(date +%Y-%m-%d).md
```
### Pre-Task Hook
Before starting task:
```bash
#!/bin/bash
# .claude/hooks/pre-task.sh
# Check for similar past tasks
echo "Checking learnings for: $1"
grep -r "$1" .claude/policy .claude/journal 2>/dev/null | head -5
# Check for known pitfalls
grep -r "mistake.*$1" .claude/policy .claude/journal 2>/dev/null
```
## Knowledge Base Structure
```
.claude/
journal/
daily/
2026-01-30.md
2026-01-29.md
weekly/
2026-week-05.md
patterns/
successful/
authentication-patterns.md
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.