learn

learn is a command for Claude Code, OpenCode from kylepelham/Drift. It costs 18 tokens per session (344 once invoked), scanned A, a copy of learn, MIT.

A command that extracts non-obvious lessons from a coding session and saves them in nearby AGENTS.md files. These files provide project guidance to coding agents working in that part of the codebase.

In plain words
What is it for?
It helps document debugging breakthroughs, architectural constraints, required file changes, and build or test commands for future work.
Why use it?
It preserves discoveries that would otherwise be lost after the session, such as hidden file relationships, unusual commands, or configuration details.

Command for Claude CodeOpenCode

Written for Claude Code and OpenCode: $ARGUMENTS substitution, but also installed under .opencode/. Also seen: mentions AGENTS.md.

Good fit It helps document debugging breakthroughs, architectural constraints, required file changes, and build or test commands for future work.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/kylepelham/drift/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/kylepelham/Drift

Made for: Claude Code, OpenCode.

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/kylepelham/drift/learn.svg)](https://agentmods.dev/commands/kylepelham/drift/learn)
Your own site
<a href="https://agentmods.dev/commands/kylepelham/drift/learn"><img src="https://agentmods.dev/badge/commands/kylepelham/drift/learn.svg" alt="Measured on agentmods" height="20"></a>
Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 344 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 100% copy Near-identical to another mod 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.00018 $0.00344
Opus 5 $0.00009 $0.00172
Sonnet 5 $0.00004 $0.00069
Haiku 4.5 $0.00002 $0.00034

Measured 2d ago against content hash 891675a8519c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 2d 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.

Origin

This is a copy

100% identical to learn — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

engine/upstream/.opencode/command/learn.md · 43 lines

What it actually says

Analyze this session and extract non-obvious learnings to add to AGENTS.md files.

AGENTS.md files can exist at any directory level, not just the project root. When an agent reads a file, any AGENTS.md in parent directories are automatically loaded into the context of the tool read. Place learnings as close to the relevant code as possible:

  • Project-wide learnings → root AGENTS.md
  • Package/module-specific → packages/foo/AGENTS.md
  • Feature-specific → src/auth/AGENTS.md

What counts as a learning (non-obvious discoveries only):

  • Hidden relationships between files or modules
  • Execution paths that differ from how code appears
  • Non-obvious configuration, env vars, or flags
  • Debugging breakthroughs when error messages were misleading
  • API/tool quirks and workarounds
  • Build/test commands not in README
  • Architectural decisions and constraints
  • Files that must change together

What NOT to include:

  • Obvious facts from documentation
  • Standard language/framework behavior
  • Things already in an AGENTS.md
  • Verbose explanations
  • Session-specific details

Process:

  1. Review session for discoveries, errors that took multiple attempts, unexpected connections
  2. Determine scope - what directory does each learning apply to?
  3. Read existing AGENTS.md files at relevant levels
  4. Create or update AGENTS.md at the appropriate level
  5. Keep entries to 1-3 lines per insight

After updating, summarize which AGENTS.md files were created/updated and how many learnings per file.

$ARGUMENTS

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. 2d ago First seen · 43 lines · 18 tokens per session scan A 891675a8519c

Subscribe to this mod's changes

learn is a command published in the GitHub repository kylepelham/Drift (20 stars, last pushed yesterday), licensed MIT. It adds 18 tokens to every session and 344 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to learn, differing in 0 lines, and is treated as a copy.