learn-by-mistake

learn-by-mistake is a skill for Claude Code from JuanMarchetto/agent-skills. It costs 68 tokens per session (3,912 once invoked), scanned A, original, MIT.

A system that records lessons from errors and keeps them available across coding sessions.

In plain words
What is it for?
Use it with test failures, build errors, crashes, and failed commands to identify causes, fixes, and prevention steps.
Why use it?
It helps the agent recognise repeated failures and avoid making the same mistake again.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md.

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /home/username/project/....

Part of the learn-by-mistake plugin — 1 skill, 4 commands, 3 hooks shipped together

Good fit Use it with test failures, build errors, crashes, and failed commands to identify causes, fixes, and prevention steps.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add JuanMarchetto/agent-skills
Claude Code
/plugin install learn-by-mistake

Made for: Claude Code.

Or install learn-by-mistake, the plugin that ships this one along with the rest of its 1 skill, 4 commands, 3 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for learn-by-mistake

README.md
[![agentmods](https://agentmods.dev/badge/skills/juanmarchetto/agent-skills/learn-by-mistake/github.svg)](https://agentmods.dev/skills/juanmarchetto/agent-skills/learn-by-mistake)
Your own site
<a href="https://agentmods.dev/skills/juanmarchetto/agent-skills/learn-by-mistake"><img src="https://agentmods.dev/badge/skills/juanmarchetto/agent-skills/learn-by-mistake/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for learn-by-mistake

Your own site · 80×15
<a href="https://agentmods.dev/skills/juanmarchetto/agent-skills/learn-by-mistake"><img src="https://agentmods.dev/badge/skills/juanmarchetto/agent-skills/learn-by-mistake.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,912 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00068 $0.03912
Opus 5 $0.00034 $0.01956
Sonnet 5 $0.00014 $0.00782
Haiku 4.5 $0.00007 $0.00391

Measured 9d ago against content hash 224b8479d4b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

learn-by-mistake scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (demo/demo.sh, hooks/scripts/detect-error.sh, hooks/scripts/load-lessons.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/learn-by-mistake/SKILL.md · 357 lines

How it starts

The opening of the file, as written. The whole thing — 357 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Learn by Mistake

After EVERY tool use that results in an error:

  1. Check .claude/lessons.md for matching lessons BEFORE attempting a fix
  2. After fixing, evaluate if this error warrants a new lesson
  3. If yes, write or update the lesson file

This applies even if the user did not ask about the error. If a command fails, you act.

You are an AI assistant with persistent error memory. You analyze failures, extract root-cause lessons, and prevent the same mistake from happening twice. This system applies to all error types: test failures, build errors, runtime crashes, command failures, linter errors, and type errors.

The lesson file lives at .claude/lessons.md relative to the project root.


1. Session Start — Load Lessons

At the start of every session, check if .claude/lessons.md exists in the current project.

If it exists:

  • Read it silently (do not print the contents unprompted).
  • Load all Active Lessons into working memory, prioritized by Hits count (highest first).
  • Keep the top 20 most-hit active lessons readily available for pattern matching.
  • Be prepared to match ANY active lesson against errors encountered during the session.

If it does not exist:

  • Do nothing. The file will be created on the first error worth learning from.

1b. User Correction Detection — Conversational Errors

Errors are not only technical. When the user corrects you, that is ALSO a learning opportunity. Detect user corrections by watching for phrases like:

  • "no, that's wrong" / "that's not right" / "that's incorrect"
  • "don't do that" / "never do that" / "stop doing that"
  • "that's not what I asked" / "I said X not Y"
  • "undo that" / "revert that" / "that broke things"
  • "you already made this mistake" / "we went through this"
  • "use X instead" / "the correct way is..." / "actually..."
  • Any explicit statement that your output, approach, or code was wrong

Read the full file on GitHub · 357 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 357 lines · 68 tokens per session scan A 224b8479d4b8

Subscribe to this mod's changes

learn-by-mistake is a skill published in the GitHub repository JuanMarchetto/agent-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 68 tokens to every session and 3,912 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

unicli-repair

Evidence-driven repair workflow for a broken Uni-CLI adapter. Trigger on a failed unicli envelope, a quarantined adapter, or an explicit adapter-repair request. Classifies non-source failures, edits only the reported adapter path, and uses the original command as a bounded oracle.

olo-dot-io/Uni-CLI · 68 tokens

bgclick-rev

Reverse-engineer a macOS GUI automation app's background-click path and produce a Swift reproduction. Use only when the user provides a target .app and explicitly asks for IDA-backed background-click reverse engineering. Requires IDA Pro with IDA MCP attached.

olo-dot-io/Uni-CLI · 56 tokens

diagnose-with-memory

A bug-diagnosis workflow that uses records of earlier failures, decisions, and lessons. It checks whether past findings still apply to the current version and environment before investigating the code.

ezBuilder/code-brain · 32 tokens

omen

A pre-mortem planning tool that lists ways a plan, design, or system could fail before work begins and ranks the risks.

seaworld008/Commonly-used-high-value-skills · 18 tokens

opencli-autofix

Automatically fix broken OpenCLI adapters when commands fail. Load this skill when an opencli command fails — it guides you through collecting a trace artifact, patching the adapter, retrying, and filing an upstream GitHub issue after a verified fix. Works with any AI agent.

jackwener/OpenCLI · 61 tokens

exploiting-linux-kernel-vulnerabilities

Methodology for discovering and exploiting Linux kernel memory-corruption vulnerabilities (UAF, OOB read/write, race/TOCTOU, type confusion) during authorized engagements, covering reachability analysis, building stable read/write primitives from a single bug, defeating KASLR/SMEP/SMAP/KPTI, slab/buddy heap grooming…

xalgorix/xalgorix · 96 tokens