keep-lesson
Skill4 starsChanged 23 days agoMITView on GitHub
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).
In this repository27 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ai-cost-reportSkill
- browser-testing-with-devtoolsSkill
- ce-noslopSkill
- codebase-designSkill
- commit-trailSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- draw-flowSkill
- grillingSkill
- handoffSkill
- improve-codebase-architectureSkill
- interview-meSkill
- lesson-generatorSkill
- make-skillSkill
- meeting-notesSkill
- qa-siteSkill
- qa-testSkill
- security-auditSkill
- session-retroSkill
- tddSkill
- ui-ux-pro-maxSkill
- write-paperSkill
- write-patentSkill
- write-specSkill
- wtfSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Keep: after a problem is solved and checked, store its lesson where the next change will meet it.
- Distinctive: line 15
Recall: before planning or starting a change, read the lessons that cover the same area.
- Distinctive: line 21
Keep a lesson only when all of these hold:
- Distinctive: line 37
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 …
- Distinctive: line 39
Never change product code here.
- Very specific: line 44
Not twice: search the folder first (grep -ril on the area and the main words).
- Very specific: line 84
Before planning or starting a change in a repository that has docs/lessons/ (or the folder it uses for this):
- Very specific: line 86
Search the folder for the area, the files and the main words of the task (grep -ril).
- Distinctive: line 87
Read the notes that match, not the whole folder.
- Distinctive: line 93
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.
- Distinctive: line 94
Never copy a conversation, a log or an error's text into a note.
- Distinctive: line 95
Never invent a cause, a result or a number.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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:
- 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".
- 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. - 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 -rilon the area and the main words). When a note already covers the same problem, update it and addupdated: YYYY-MM-DDinstead 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.
---
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):
- Search the folder for the area, the files and the main words of the task (
grep -ril). - Read the notes that match, not the whole folder.
- Say in one line each which notes apply and what they change in the plan. Say nothing when none apply.
- A note whose
retire_whenhas 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

