agentleFS
strikersamstrikersam/autonomous-ai-agency/.agents/skills/learn-rule/SKILL.md

learn-rule

Skill9 starsChanged 3 months agoMITView on GitHub

Persist corrections and patterns to long-term memory. When a mistake is made or a rule is learned, write it to .claude/state/learnings.md so it's never repeated.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill whenever:

    line 22
  2. Distinctive:

    Create it if it doesn't exist.

    line 48
  3. Distinctive:

    If the rule is general enough to apply to every future session:

    line 72
  4. Distinctive:

    Add it to the "Coding Rules" section (numbered, concise)

    line 74
  5. Very specific:

    Use repo-memory-updater skill if multiple rules need updating

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Skill: learn-rule

When to Use

Use this skill whenever:

  • The user corrects a mistake you made
  • You discover a repo-specific rule that isn't in CLAUDE.md
  • A pattern works unexpectedly (positively or negatively)
  • You want to persist a decision for future sessions

This is how Claude gets smarter at this specific repo over time.


Instructions

Step 1 — Identify the rule

Extract the core rule from the correction or discovery. A good rule is:

  • Specific — refers to a concrete situation
  • Actionable — tells you what to do or not do
  • Memorable — can be read in under 10 seconds

Bad rule: "Be careful with auth code." Good rule: "Always call risky-module-review before touching admin_auth.py — even for 1-line changes."

Step 2 — Append to learnings file

File: .claude/state/learnings.md

Create it if it doesn't exist. Always append — never overwrite.

## YYYY-MM-DD — <short title>

**Situation:** What was being worked on when this was learned.
**Mistake/Discovery:** What went wrong or what was surprising.
**Rule:** <One clear, actionable sentence starting with a verb.>
**Source:** user-correction | self-discovery | docs

Example entry:

## 2026-04-09 — Don't use git add -A

**Situation:** Committing the router refactor.
**Mistake:** Used `git add -A` which staged keys.json accidentally.
**Rule:** Always stage specific files by name; never use `git add -A` or `git add .`.
**Source:** user-correction

Step 3 — Check if CLAUDE.md should be updated

If the rule is general enough to apply to every future session:

  1. Read CLAUDE.md
  2. Add it to the "Coding Rules" section (numbered, concise)
  3. Use repo-memory-updater skill if multiple rules need updating

Learnings File Format

.claude/state/learnings.md:

# Session Learnings

Rules and corrections learned from working in this repo.
Read this at the start of sessions via the `replay-learnings` skill.

---

## YYYY-MM-DD — title

**Situation:** ...
**Mistake/Discovery:** ...
**Rule:** ...
**Source:** ...

---

Acceptance Checks

  • Rule is specific and actionable (not vague advice)
  • Entry appended to .claude/state/learnings.md
  • CLAUDE.md updated if rule is broadly applicable
  • Rule phrased as an imperative: "Always X", "Never Y", "Before Z, do W"

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.