Keep the lesson of a problem that was just solved, so the next change in the repository does not have to learn it again: as a test when one can catch it, otherwise as a short note in docs/lessons/. Also reads those notes before a change in the same area. Use when the user types /keep-lesson, says \"remember this for next time\", \"write down what we learned\", or when a verified fix showed that something works differently from what everyone assumed. Do not use it for work that went as first p...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Keep Lesson?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anhle9x-keep-lesson)
---
name: keep-lesson
description: "Keep the lesson of a problem that was just solved, so the next change in the repository does not have to learn it again: as a test when one can catch it, otherwise as a short note in docs/lessons/. Also reads those notes before a change in the same area. Use when the user types /keep-lesson, says \"remember this for next time\", \"write down what we learned\", or when a verified fix showed that something works differently from what everyone assumed. Do not use it for work that went as first planned, and not for a handoff to the next session (use handoff). Giữ lại bài học của một vấn đề vừa giải xong để lần sửa sau trong repo không phải học lại: thành một test khi test bắt được, còn không thì thành một ghi chú ngắn trong docs/lessons/. Cũng đọc các ghi chú đó trước khi sửa cùng khu vực. Dùng khi người dùng gõ /keep-lesson, nói \"ghi lại bài học\", \"nhớ cái này cho lần sau\", hoặc khi một bản sửa đã kiểm cho thấy một thứ chạy khác với điều mọi người vẫn tưởng. Không dùng cho việc chạy đúng như kế hoạch ban đầu, cũng không dùng để bàn giao cho phiên sau (việc đó dùng handoff)."
---
# Keep the lesson
Answer the user in their language. Write the lesson in the language the repository's documents use; English when there are none.
Purpose: each change makes the next one easier. A mistake that cost an hour today should cost nobody that hour again, whether it is the same person, a colleague, or another AI session that never saw this conversation.
This skill does two jobs:
- **Keep:** after a problem is solved and checked, store its lesson where the next change will meet it.
- **Recall:** before planning or starting a change, read the lessons that cover the same area.
## Keep
### 1. Is there a lesson?
Keep a lesson only when all of these hold:
- The problem is **solved and checked**: the fix was run and shown to work, not just written.
- Something **turned out different from what was believed**: an approach that failed, a wrong assumption, a misleading document, a bug a review caught.
- **The current code does not already tell it.** Ask: someone who reads the code, tests and documents as they are now, without this conversation, would they still be likely to make the same mistake or redo the same search? If not, there is nothing to keep.
How long the work took or how big the change was does not make a lesson. If there is none, write nothing and say why in one or two lines. One run keeps one lesson; a session with three lessons gets three runs.
### 2. Pick the cheapest form that stops the repeat
Try these in order and take the first that holds:
1. **A test**, when a test the repository already runs can catch the mistake and its failure says what to fix. Keep it only after you saw it pass on the current code and fail when the mistake is put back in a throwaway copy (never in the working tree). If you cannot show both, do not keep the test: describe it in the note under "Prevention".
2. **A line in an existing `CODING_STANDARDS.md`** (or the rules file the repository already has for this), when the mistake is one a reviewer can see in a diff and no test can catch it. Add one condition in that file's style. Never create such a file.
3. **A note** in `docs/lessons/`, for the reasoning that code and tests cannot carry: why a way was chosen, what was tried and failed, a number that was measured.
After a test or a standards line, ask the question in step 1 again: write a note only for what would still be lost, and have it point at the test or the line.
Never change product code here. If the real fix is in the code (two ways of doing the same thing, a missing check in the program), name it in the note as work for whoever owns that code.
### 3. Write the note
- **Where:** `docs/lessons/<short-name>.md`. If the repository already keeps such notes elsewhere (`docs/solutions/`, `docs/learnings/`), use that folder and its way of naming and filing.
- **Not twice:** search the folder first (`grep -ril` on the area and the main words). When a note already covers the same problem, update it and add `updated: YYYY-MM-DD` instead of writing a second one. When an existing note turned out wrong, correcting it is the lesson.
- **Check every claim** about how the code behaves against the current files before writing it, and name the file. Write what you could not check as unverified.
```markdown
---
title: "<what was learned, in a plain sentence>"
date: YYYY-MM-DD
area: <the part of the project>
kind: bug | knowledge
tags: [word-one, word-two]
retire_when: "<optional: the outside change that makes this note stale, such as a library version, and how to check it>"
---
# <title>
## What happened
What was seen, in one to three lines.
## What did not work
- The approach tried, and why it failed.
## What works, and why
The fix or the right way, with the file names and a short code example when it helps.
## Prevention
The test, the standards line, or the code change that would stop the repeat, and where it is (or that it is only proposed).
```
For a `knowledge` note, "What happened" is the situation that called for the guidance, and "What did not work" can be left out.
### 4. Make it findable
The note is useless if the next session never reads it. Look at the repository's `CLAUDE.md` or `AGENTS.md`. If neither mentions the lessons folder, propose one line such as: "Before changing an area, read the notes in `docs/lessons/` that cover it." Add the line only after the user says yes. Never create one of those files just for this line.
### 5. Report
In a few lines: what was kept and where (the test with what it showed, the standards line, the note), or why nothing was kept. Do not commit: the user commits the note with the change it belongs to.
## Recall
Before planning or starting a change in a repository that has `docs/lessons/` (or the folder it uses for this):
1. Search the folder for the area, the files and the main words of the task (`grep -ril`).
2. Read the notes that match, not the whole folder.
3. Say in one line each which notes apply and what they change in the plan. Say nothing when none apply.
4. A note whose `retire_when` has come true, or that the current code now contradicts, is stale: tell the user, and suggest correcting or removing it in a separate change.
## Never
- Never put a password, key, token, internal address, or a customer's or colleague's name in a note: it stays in the history for good. Write "the staging database", not its address.
- Never copy a conversation, a log or an error's text into a note; say what it showed.
- Never invent a cause, a result or a number. A note that says "not checked" is worth more than one that claims too much.
## Source
The idea and the order of forms (a test, then a standards line, then a note) follow `ce-compound` in EveryInc/compound-engineering-plugin (MIT, see `LICENSE` in this folder). This is a short version written for this project: one pass, no subagents, no configuration file and no scripts.