Skip to main content
command CX Codex

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

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add rohitg00/pro-workflow
/plugin install pro-workflow@pro-workflow
Open on GitHub

What 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-workflow

2Manually: put the files in place

.claude/commands/learn-rule.md

Call it with /learn-rule. For all projects use ~/.claude/commands/

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

Similar slash commands

All slash commands for Agent setup: memory, context, orchestration →

From the same set83

The whole set →
communication-style communication-style sets how Claude replies: short, no openers or praise, code before prose. Useful when agent answers drown in politeness. CX Codex +1 ★ 2,966repo stars search Runs full-text keyword searches across the pro-workflow learnings database. Helps recall previous mistakes and project rules while coding. CX Codex +1 ★ 2,966repo stars sprint-status sprint-status is a Claude Code command that summarizes active sessions and branches. Run it to resume work or check parallel sessions. CX Codex +1 ★ 2,966repo stars deslop The /deslop command cleans the current branch of unnecessary code added by AI: obvious comments, defensive try/catch blocks, one-off abstractions, and docstrings on unchanged functions. CX Codex +1 ★ 2,966repo stars wrap-up The wrap-up skill audits code changes, runs quality checks, and records what to pick up next. Use it when you are about to end a coding session. CX Codex +1 ★ 2,966repo stars incremental-verify incremental-verify keeps the agent on one failing test at a time: the smallest change that passes it, then a commit, before the next behavior starts. CX Codex +1 ★ 2,966repo stars token-efficiency token-efficiency cuts token burn in Claude Code by removing conversational filler, enforcing read-before-write, and stopping unwanted refactoring loops. CX Codex +1 ★ 2,966repo stars scout scout examines a codebase before implementation and rates readiness across five dimensions. Use it to see whether the task is ready to start or needs more investigation. CX Codex ★ 2,966repo stars

Project sponsors

Companies that keep this analytics open