learn-rule — Claude Code command: what it does, how to install
learn-rule extracts session mistakes into one-line rules and saves them to your project memory after explicit confirmation.
MIT ★ 2,966 updated 2026-09-29
/plugin marketplace add rohitg00/pro-workflow
/plugin install pro-workflow@pro-workflowWhat learn-rule does
The /learn-rule command turns agent missteps into structured guidelines for future sessions. It inspects what went wrong, drafts an alternative approach, and formats the result as a single line prefixed with [LEARN].
Entries belong to fixed categories covering navigation, code editing, testing, Git operations, quality checks, context, architecture, performance, prompt structure, and Claude Code workflows. The command then previews the rule and waits for a confirmation prompt. Nothing enters the LEARNED block until you respond with y.
What it helps with
- Turn session mistakes into persistent rules for the assistant
- Categorize project guidelines under fixed tags like Navigation or Git
- Prevent unreviewed memory modifications by requiring manual confirmation
Example prompts for the agent
- /learn-rule
- Remember this mistake and add it to our project rules
- Extract a rule about file paths after editing the wrong module
How to install learn-rule
1Plugin marketplace
/plugin marketplace add rohitg00/pro-workflow/plugin install pro-workflow@pro-workflow2Manually: put the files in place
.claude/commands/learn-rule.mdCall it with /learn-rule. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/learn-rule.mdCall it with /prompts:learn-rule. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/learn-rule.prompt.mdManually: put the files in place
.gemini/commands/learn-rule.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about learn-rule
How to install learn-rule in Claude Code?
Add the marketplace by running /plugin marketplace add rohitg00/pro-workflow, then run /plugin install pro-workflow@pro-workflow. Alternatively, place the file directly at .claude/commands/learn-rule.md.
What does learn-rule do?
It isolates a mistake from the current work, generates a categorized one-line guideline, and asks for user approval before appending it to the LEARNED section.
Which rule categories are supported?
The command groups notes under Navigation, Editing, Testing, Git, Quality, Context, Architecture, Performance, Claude-Code, and Prompting.
Source text
learn-rule.md · MIT
--- description: Capture a lesson as a reusable rule after user approval. --- # /learn-rule - Extract Correction to Memory Capture a lesson from this session into permanent memory. ## Process 1. **Identify the lesson** - What mistake was made? - What should happen instead? 2. **Format the rule** ``` [LEARN] Category: One-line rule ``` Categories: - Navigation (file paths, finding code) - Editing (code changes, patterns) - Testing (test approaches) - Git (commits, branches) - Quality (lint, types, style) - Context (when to clarify) - Architecture (design decisions) - Performance (optimization) - Claude-Code (sessions, modes, CLAUDE.md, skills, subagents, hooks, MCP) - Prompting (scope, constraints, acceptance criteria) 3. **Propose addition** Show what will be added to LEARNED section. 4. **Wait for approval** Only add after user confirms. ## Example ``` Recent mistake: Edited wrong utils.ts file [LEARN] Navigation: Confirm full path when multiple files share a name. Add to LEARNED section? (y/n) ``` --- ## Claude Code Examples ``` [LEARN] Claude-Code: Use plan mode before multi-file changes. Docs: https://code.claude.com/docs/common-workflows [LEARN] Claude-Code: Compact context at task boundaries, not mid-work. Docs: https://code.claude.com/docs/common-workflows [LEARN] Prompting: Always include acceptance criteria in prompts. ``` --- **Trigger:** Use when user says "remember this", "add to rules", or after making a mistake.
© Rohit Ghumare · MIT · rohitg00/pro-workflow