agentleFS
anhle9xanhle9x/ai-worker/skills/keep-lesson/SKILL.md

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).

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
  1. Distinctive:

    Keep: after a problem is solved and checked, store its lesson where the next change will meet it.

    line 14
  2. Distinctive:

    Recall: before planning or starting a change, read the lessons that cover the same area.

    line 15
  3. Distinctive:

    Keep a lesson only when all of these hold:

    line 21
  4. Distinctive:

    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 …

    line 37
  5. Distinctive:

    Never change product code here.

    line 39
  6. Very specific:

    Not twice: search the folder first (grep -ril on the area and the main words).

    line 44
  7. Very specific:

    Before planning or starting a change in a repository that has docs/lessons/ (or the folder it uses for this):

    line 84
  8. Very specific:

    Search the folder for the area, the files and the main words of the task (grep -ril).

    line 86
  9. Distinctive:

    Read the notes that match, not the whole folder.

    line 87
  10. Distinctive:

    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.

    line 93
  11. Distinctive:

    Never copy a conversation, a log or an error's text into a note.

    line 94
  12. Distinctive:

    Never invent a cause, a result or a number.

    line 95

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.
---
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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.