learn

A command for saving a correction or project convention as a persistent learning in `.claude/learnings`.

In plain words
What is it for?
Use it when you want the coding agent to remember a rule, mistake, or correction for future work. It saves the learning with its category, date, and project information.
Why use it?
It records lessons from a session in a standard format and rebuilds the learning index so the files and index stay aligned.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/sefaertunc/worclaude/learn
Clone the repo
git clone --depth 1 https://github.com/sefaertunc/Worclaude

Made for: Claude Code.

Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 843 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00009 $0.00843
Opus 5 $0.00005 $0.00421
Sonnet 5 $0.00002 $0.00169
Haiku 4.5 $0.00001 $0.00084

Measured 3d ago against content hash a4e40d747073, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

learn 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 3d ago.

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.

.claude/commands/learn.md · 98 lines

How it starts

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

The user wants to capture a learning from this session.

When invoked with arguments, use them as the learning to capture. Example: /learn Always use conventional commits for this project

If no arguments provided, ask the user what they want to remember.

Format

A learning is a [LEARN] block:

[LEARN] Category: One-line rule description
Mistake: What went wrong (optional)
Correction: What should happen instead (optional)

Write to .claude/learnings/{category-slug}.md with YAML frontmatter:

---
created: <today's date YYYY-MM-DD>
category: <from the [LEARN] block>
project: <package.json name, or directory name as fallback>
---

Do NOT add a times_applied field. The auto-capture hook never increments it; the field would be a lie. Removed in Phase 2 (2026-04).

After writing, regenerate .claude/learnings/index.json from the directory contents — never hand-maintain it. The regeneration walks .claude/learnings/*.md, parses each frontmatter, and writes the canonical { "learnings": [{file, category, created}, ...] } index. This guarantees the index never drifts from the files on disk.

Confirm to the user what was saved and where.

When to use /learn vs other memory layers

The system has multiple memory layers; pick the right one for the trigger:

Trigger Lands in Audience
Plain conversation ("user pushes back") Claude Code's auto-memory (autonomous) Personal, machine-local
/learn or [LEARN] marker .claude/learnings/ Team-relevant
/update-claude-md (later promotion path) CLAUDE.md Team, every session

/learn is the team signal. Use it when the rule belongs to the project, not your personal preferences. Examples:

  • ✅ "We always use pnpm in this repo, not npm" → /learn
  • ✅ "The conflict-resolver must not push" → /learn
  • ❌ "I prefer terse responses" → leave to auto-memory; don't /learn
  • ❌ "User pushes back on overengineering" → leave to auto-memory

Read the full file on GitHub · 98 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. 3d ago First seen · 98 lines · 9 tokens per session scan A a4e40d747073

Subscribe to this mod's changes

learn is a command published in the GitHub repository sefaertunc/Worclaude (4 stars, last pushed 24d ago), licensed MIT. It adds 9 tokens to every session and 843 once invoked, about $0.0000 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-08-31.