Turn high-value lessons from one-off conversations into reusable assets within the project.
Quick Reference
| Situation | Action |
|---|---|
| Command/tool failure | Record to .learnings/ERRORS.md |
| User corrects you | Record to .learnings/LEARNINGS.md, category correction |
| User requests a missing capability | Record to .learnings/FEATURE_REQUESTS.md |
| External API failure | Record to .learnings/ERRORS.md, including integration details |
| Knowledge is outdated | Record to .learnings/LEARNINGS.md, category knowledge_gap |
| Discover a better approach | Record to .learnings/LEARNINGS.md, category best_practice |
| Similar to an existing entry | Use See Also to link, consider raising the priority |
| Broadly applicable lesson | Promote to CLAUDE.md / AGENTS.md |
File structure
.learnings/
├── LEARNINGS.md
├── ERRORS.md
└── FEATURE_REQUESTS.md
When to record
Prioritize recording these situations:
- The user corrected your judgment, assumption, or implementation approach
- A tool, command, or runtime environment had a non-obvious failure
- The user requested a capability the current system does not directly support
- You discovered a project constraint, workflow, or best practice worth reusing
- Your knowledge is outdated or does not match actual behavior
Do not record these situations:
- Obvious, one-off errors
- Small problems that can be solved without a retrospective
- Generic common knowledge unrelated to the current project
Recording principles
- Keep only high-signal information; avoid turning
.learnings/into a noise dump - Write "why this will still be useful later" first, then write "what happened this time"
- If it is an error, clearly state reproduction clues and the suggested fix direction
- If it is a user correction, clearly state where the original assumption was wrong
- Search existing entries before recording; link duplicates with See Also
- If the pattern is already stable, consider promoting it to
AGENTS.mdor extracting a new skill
Recording format
Learning
## [LRN-YYYYMMDD-XXXXXX] correction | knowledge_gap | best_practice
**Logged**: 2026-03-23T10:00:00+00:00
**Priority**: low | medium | high | critical
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config | runtime
### Summary
一句话说明学到了什么
### Details
说明当时的错误假设、触发条件和正确做法
### Suggested Action
以后应如何避免再次犯错
### Metadata
- Source: user_feedback | error | conversation
- Related Files: path/to/file.py
- Tags: tag1, tag2
- See Also: LRN-20260320-001 (如果与已有条目相关)
- Pattern-Key: correction.api_format (可选,用于重复模式追踪)
- Recurrence-Count: 1 (可选)
---
Error
## [ERR-YYYYMMDD-XXXXXX] auto_logged_error
**Logged**: 2026-03-23T10:00:00+00:00
**Priority**: medium | high
**Status**: pending
**Area**: runtime
### Summary
一句话说明哪里失败了
### Error
```text
具体错误内容
```
### Context
- Step: 3
- Tool: `bash`
- Task: 当前任务摘要
### Suggested Fix
说明后续应怎么复盘或修正
### Metadata
- Reproducible: yes | no | unknown
- Related Files: N/A
- Pattern-Key: tool_error.bash (可选)
- Recurrence-Count: 2 (可选)
---
Feature Request
## [FEAT-YYYYMMDD-XXXXXX] capability_name
**Logged**: 2026-03-23T10:00:00+00:00
**Priority**: medium
**Status**: pending
**Area**: runtime
### Requested Capability
用户需要什么能力
### User Context
为什么需要它
### Complexity Estimate
simple | medium | complex
### Suggested Implementation
可行的最小实现思路
### Metadata
- Frequency: first_time | recurring
- Related Features: N/A
---
Entry lifecycle
| Status | Meaning |
|---|---|
pending |
New record, pending |
in_progress |
In progress |
resolved |
Fixed/resolved |
promoted |
Promoted to CLAUDE.md / AGENTS.md / new skill |
wont_fix |
Decided not to handle it (explain the reason in Resolution) |
When resolving an entry, append a Resolution block:
### Resolution
- **Resolved**: 2026-03-24T09:00:00Z
- **Commit/PR**: abc123 or #42
- **Notes**: 简述做了什么
Duplicate pattern detection
Search existing entries before recording:
grep -r "keyword" .learnings/
If a similar entry is found:
- Use
See Alsoto link - Consider raising the priority
- If Recurrence-Count >= 3, strongly recommend promoting it to a project rule
Priority guidance
| Priority | Applicable scenarios |
|---|---|
critical |
Blocks core functionality, risk of data loss, security issues |
high |
Significant impact, common workflows blocked, recurring |
medium |
Moderate impact, has a workaround |
low |
Minor inconvenience, edge cases |
Area tags
| Area | Scope |
|---|---|
frontend |
UI, components, client code |
backend |
API, services, server-side code |
infra |
CI/CD, deployment, Docker, cloud |
tests |
Test files, test tooling |
docs |
Documentation, comments |
config |
Config files, environment variables |
runtime |
Agent runtime, tool execution |
Promotion paths
When a learning has been verified multiple times and has cross-task value:
| Learning type | Promotion target | Example |
|---|---|---|
| Project convention | CLAUDE.md |
"Use uv as the package manager, not pip" |
| Workflow rule | AGENTS.md |
"The client must be regenerated after API changes" |
| Reusable pattern | New skill | A pattern complex enough to require dedicated guidance |
After promotion, update the original entry's Status to promoted, and note **Promoted**: CLAUDE.md。
Skill extraction criteria
When a learning meets any of the following conditions, it can be extracted as a standalone skill:
- Has 2+ See Also links (recurs repeatedly)
- Status is resolved and the fix has been verified
- Non-obvious, requires actual debugging to discover
- Not limited to a specific project, usable across codebases
- The user explicitly requests "save this as a skill"
Relationship with native Hooks
Within the project, SelfImprovementHook automatically does these things:
- Before running, reminds you to use this skill when necessary
- Automatically logs a basic record to
ERRORS.mdwhen a tool fails - Automatically raises priority and tracks Pattern-Key when the same tool fails repeatedly
- Automatically logs to
LEARNINGS.mdon user reject/edit feedback - Automatically logs to
FEATURE_REQUESTS.mdon feature_request feedback
Automatic logging is only a fallback. Truly high-quality learnings still require you to proactively organize them before the task ends.
Periodic review
Review .learnings/:
- Before starting a new large task
- After completing a feature
- When working in an area with historical learnings
grep -h "Status\*\*: pending" .learnings/*.md | wc -l
grep -B5 "Priority\*\*: high" .learnings/*.md | grep "^## \["