learn

learn is a command for Claude Code from MadAppGang/magus. It costs 24 tokens per session (2,854 once invoked), scanned B, original, MIT.

A command that examines a coding session for repeatable preferences or useful working patterns, then can apply or remove them from project guidance.

In plain words
What is it for?
Proposing, applying, or pruning learned rules in a project’s CLAUDE.md file.
Why use it?
It helps keep helpful conventions while avoiding stale or forgotten instructions.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md; names the AskUserQuestion tool.

Part of the dev plugin — 19 skills, 15 commands, 12 agents shipped together

Good fit Proposing, applying, or pruning learned rules in a project’s CLAUDE.md file.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/madappgang/magus/learn
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.

Clone the repo
git clone --depth 1 https://github.com/MadAppGang/magus

Made for: Claude Code.

Or install dev, the plugin that ships this one along with the rest of its 19 skills, 15 commands, 12 agents.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/madappgang/magus/learn/github.svg)](https://agentmods.dev/commands/madappgang/magus/learn)
Your own site
<a href="https://agentmods.dev/commands/madappgang/magus/learn"><img src="https://agentmods.dev/badge/commands/madappgang/magus/learn/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

Your own site · 80×15
<a href="https://agentmods.dev/commands/madappgang/magus/learn"><img src="https://agentmods.dev/badge/commands/madappgang/magus/learn.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,854 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00024 $0.02854
Opus 5.5 $0.00010 $0.01142
Sonnet 5.5 $0.00005 $0.00571
Haiku 4.5 $0.00002 $0.00285

Measured 22d ago against content hash 17a1e119c832, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

learn scanned grade B with 1 finding 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 22d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

cat .claude/CLAUDE.md 2>/dev/null || cat CLAUDE.md 2>/dev/null || echo "No CLAUDE.md found"
plugins/dev/commands/learn.md · 358 lines

How it starts

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

<user_request> Analyze this session for learnable patterns and propose CLAUDE.md updates. $ARGUMENTS </user_request>

<workflow_apply condition="--apply argument"> Bulk-apply all staged HIGH-confidence learnings from the daemon Read pending-learnings.json: bash PENDING_FILE="${CWD}/.claude/.coaching/pending-learnings.json" if [ ! -f "$PENDING_FILE" ] || [ ! -s "$PENDING_FILE" ]; then echo "No pending learnings to apply." exit 0 fi cat "$PENDING_FILE" For each pending learning: 1. Show the learning with evidence 2. Read current CLAUDE.md 3. Find or create ## Learned Preferences section 4. Find or create the appropriate subsection (Code Style, Project Structure, Tools & Commands, Conventions, Workflow) 5. Check the current line count in the ## Learned Preferences section against the 200-line budget before adding. Skip any learning that would exceed budget and warn the user. 6. Add the learning as a single line with metadata comment: markdown <!-- learned: {YYYY-MM-DD} session: {session_id_first_8} source: {type} --> - {rule_text} 7. Use Edit tool to update the file After applying all learnings: 1. Clear the pending-learnings.json file (write empty array []) 2. Read dedup-state.json from ${CWD}/.claude/.coaching/dedup-state.json, then update entries for all applied learnings: set staged_to_claude_md: true and record staged_session using the session id from each learning. 3. Confirm what was added: ``` ✓ Applied {N} learnings to CLAUDE.md: - {learning 1} - {learning 2}

         These will apply to all future sessions in this project.
         ```
    </step>
  </steps>
</phase>

</workflow_apply>

<workflow_prune condition="--prune argument"> Interactive review and cleanup of learned preferences in CLAUDE.md Read CLAUDE.md and extract all lines in the ## Learned Preferences section. Parse metadata comments to get dates, session IDs, and sources. A metadata comment has the format: <!-- learned: {YYYY-MM-DD} session: {session_id_first_8} source: {type} --> Pair each comment with the rule line immediately following it. Read dedup-state.json from ${CWD}/.claude/.coaching/dedup-state.json to check reinforcement: - Flag entries where times_seen == 1 (never reinforced) - Flag entries whose last_reinforced_session date is older than 90 days from today - Flag entries not seen recently (if session count available in _session_count and entry has not been reinforced in the last 50 sessions) Present entries grouped by status:

Read the full file on GitHub · 358 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. 22d ago Changed 17a1e119c832
  2. 1mo ago First seen · 358 lines · 24 tokens per session scan B 5991c8b7008e

Subscribe to this mod's changes

learn is a command published in the GitHub repository MadAppGang/magus (13 stars, last pushed today), licensed MIT. It adds 24 tokens to every session and 2,854 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.