agentleFS
harshadmadayeharshadmadaye/OPM/skills/compound-learnings/SKILL.md

compound-learnings

Skill4 starsChanged 58 days agoMITView on GitHub

Captures a solved, non-obvious problem as a durable learning doc under docs/solutions/ with validated frontmatter, and retrieves matching learnings before new work starts. Use after a tricky bug fix, a surprising root cause, or a decision with real tradeoffs, and at the start of planning to check whether the team already learned this.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 7 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every non-obvious fix that lives only in one engineer's head (or one chat transcript) gets re-discovered later at full cost.

    line 8
  2. Distinctive:

    Write a learning only when it passes this counterfactual:

    line 16
  3. Distinctive:

    After a root cause turned out to be surprising.

    line 37
  4. Distinctive:

    After a decision with tradeoffs was made and its rationale would otherwise be lost.

    line 38
  5. Very specific:

    When opm:executing-plans or opm:verification-before-completion finishes a task and the session contains reasoning that is not in the code.

    line 39
  6. Distinctive:

    Do not run it for routine work whose artefacts already explain themselves.

    line 42
  7. Very specific:

    Search docs/solutions/ by symptom, error text, module, and tag before creating anything:

    line 48
  8. Very specific:

    If a match covers the same root cause: update that doc (add the new symptom, correct the fix, refresh the date) instead of creating a …

    line 56
  9. Very specific:

    Add component: opm only when the root cause or fix is clearly in OPM itself (a skill, hook, agent, template or CLI), not in the user's code.

    line 83
  10. Very specific:

    If docs/solutions/INDEX.md exists, append one line:

    line 98
  11. Distinctive:

    If it does not exist, skip this step.

    line 104
  12. Distinctive:

    If nothing was written, state which part of the durable bar failed.

    line 109
  13. Very specific:

    Before planning (opm:writing-plans, opm:milestone-planning) or debugging, spend two minutes looking for prior learnings.

    line 118

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “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

Compound Learnings

Every non-obvious fix that lives only in one engineer's head (or one chat transcript) gets re-discovered later at full cost. This skill writes it down once, in a place the next engineer (human or agent) will find by grepping for the symptom.

Two halves: capture (after the work) and retrieval (before the work).

The durable bar

Write a learning only when it passes this counterfactual:

If this document did not exist, would a future engineer reading the final code, tests, and existing docs still be likely to repeat the mistake or redo substantial investigation?

Yes -> write it. No -> write nothing and say why.

Effort, diff size, and "it was hard" do not qualify a learning. What qualifies:

  • A bug whose root cause was not where the symptom pointed.
  • A fix that looks wrong or unnecessary without the story behind it.
  • A failed approach that a reasonable engineer would try first.
  • A decision with real tradeoffs where the losing option will look attractive again.
  • A tooling or environment quirk that cost more than an hour.
  • An existing learning that is now inaccurate (update it; a misleading doc is worse than none).

One learning per doc. A session that produced three learnings produces three docs.

When to run

  • Right after a non-obvious bug fix is verified (tests pass, behaviour confirmed).
  • After a root cause turned out to be surprising.
  • After a decision with tradeoffs was made and its rationale would otherwise be lost.
  • When opm:executing-plans or opm:verification-before-completion finishes a task and the session contains reasoning that is not in the code.

Do not run it for routine work whose artefacts already explain themselves.

Capture procedure

1. Check for an existing doc

Search docs/solutions/ by symptom, error text, module, and tag before creating anything:

grep -rliE 'symptoms:.*(<error fragment>|<symptom keyword>)' docs/solutions/
grep -rliE '(title|tags):.*(<module>|<library>|<concept>)' docs/solutions/
grep -rli '<distinctive error string>' docs/solutions/

If a match covers the same root cause: update that doc (add the new symptom, correct the fix, refresh the date) instead of creating a duplicate. If a match is adjacent but different, link it via related:.

2. Choose category and slug

Category is the subdirectory under docs/solutions/. Use an existing one when it fits; the canonical set is build-errors, test-failures, runtime-errors, performance, database, security, ui-bugs, integration, logic-errors, architecture, tooling, conventions, workflow. The slug is lowercase, hyphenated, and names the problem, not the fix: docs/solutions/runtime-errors/stale-closure-in-websocket-reconnect.md.

3. Write the doc from the template

Copy assets/resolution-template.md (in this skill directory) and fill every section:

  • Problem - what was observed and what it cost (1-3 sentences).
  • Investigation - what was tried, in order, including the dead ends and why they were plausible.
  • Root cause - the actual mechanism, at the level of "why", not "what".
  • Fix - what changed, with the smallest code excerpt that shows it.
  • Prevention - a test, lint rule, guard, or convention that stops recurrence. If nothing prevents it, say so.
  • References - commits, PRs, issues, upstream docs, related learnings.

Frontmatter fields: title, date, category, problem_type, symptoms[], root_cause, severity, tags[], related[]. Symptoms are the strings someone would grep for: error messages, log lines, observable misbehaviour. Tags are lowercase-hyphenated technologies and concepts. Quote any YAML value containing : or #. Add component: opm only when the root cause or fix is clearly in OPM itself (a skill, hook, agent, template or CLI), not in the user's code; when unsure, omit it.

4. Validate the frontmatter

node <skill-dir>/scripts/validate-frontmatter.js docs/solutions/<category>/<slug>.md

The script checks required fields, enum values for problem_type, severity, and category, the date format, and YAML quoting hazards. Exit code 1 lists what to fix. Do not commit a doc that fails validation.

5. Optionally index it

If docs/solutions/INDEX.md exists, append one line:

- [<title>](<category>/<slug>.md) - <one-line root cause> (`<tag>`, `<tag>`)

If it does not exist, skip this step; grep over frontmatter is the primary retrieval path.

6. Report

State the path written or updated, the one-sentence root cause, and the prevention added. If nothing was written, state which part of the durable bar failed.

For a component: opm doc, ask one question: "Open an issue on harshadmadaye/OPM", "Append to .opm/opm-feedback.md", or "Neither". Nothing leaves the machine without a yes: for the issue, show the title and body, then run gh issue create --repo harshadmadaye/OPM only after a yes. For the file, create .opm/ if missing and append the date, title, doc path and one-paragraph lesson.

Retrieval: check the corpus before new work

Before planning (opm:writing-plans, opm:milestone-planning) or debugging, spend two minutes looking for prior learnings. Grep frontmatter first, read only the matches:

# Discover categories that exist in this repo
ls docs/solutions/

# Match on the fields most likely to carry the signal, case-insensitive, in parallel
grep -rliE 'title:.*(<keyword>|<synonym>)' docs/solutions/
grep -rliE 'tags:.*(<library>|<concept>)' docs/solutions/
grep -rliE 'symptoms:' docs/solutions/ | xargs grep -liE '(<error fragment>|<behaviour>)'
grep -rliE 'problem_type: (<type>)' docs/solutions/

Scoring: a hit on title, tags, or symptoms is strong; a hit only on problem_type or category is weak. Read the frontmatter (first ~20 lines) of strong hits, then the full doc of the ones that still look relevant. Cap at five docs.

Turn what you find into planning inputs: constraints to respect, approaches known to fail, tests that must exist, and files to read first. Note each doc's date; a learning can be superseded by later code, and present evidence beats past notes. If the corpus has nothing, say so; that absence is itself a signal that the current work may be worth capturing afterwards.

Anti-patterns

  • Writing a learning for every task. The bar exists so the corpus stays trustworthy.
  • Recording the fix without the investigation. The dead ends are the valuable part.
  • Vague symptoms ("it was slow"). Put in the exact error text or metric.
  • Batching several learnings into one doc. Retrieval works per problem.
  • Skipping the grep and creating a duplicate that later contradicts the original.

Related skills

  • opm:tdd-workflow - the reproducer test often becomes the Prevention section.
  • opm:writing-plans and opm:milestone-planning - run retrieval at the start of both.
  • opm:brainstorming - decisions with tradeoffs made there are capture candidates.
<!-- Adapted from EveryInc/compound-engineering-plugin (MIT) -->

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.