Skip to content
learn logo

Pattern Learning Skill

learn

Teach Claude a new pattern, preference, or convention explicitly. Use when you want to save a correction, preference, or coding pattern for future sessions. Triggers on keywords like "remember this", "always do", "never do", "learn this pattern", "/learn".

SKILL.md

Full skill instructions

Pattern Learning Skill

Explicitly teach Claude patterns, preferences, or conventions that should be remembered across sessions.

Quick Usage

/​learn always use PlatformValidationResult instead of throwing ValidationException
/​learn [wrong] var x = 1 [right] const x = 1 - always prefer const
/​learn prefer async/​await over .then() chains in this codebase

Teaching Formats

Format 1: Natural Language

/​learn always use IGrowthRootRepository instead of generic IPlatformRootRepository

Detected patterns: "always use X instead of Y", "prefer X over Y", "never do X"

Format 2: Explicit Wrong/​Right

/​learn [wrong] throw new ValidationException("Invalid") [right] return PlatformValidationResult.Invalid("Invalid")

Best for code-level corrections with exact examples.

Format 3: Code Block Comparison

/​learn
Wrong:
```csharp
public void Process() {
    if (x == null) throw new ArgumentNullException();
}

Right:

public PlatformValidationResult Process() {
    return x == null
        ? PlatformValidationResult.Invalid("X required")
        : PlatformValidationResult.Valid();
}

### Format 4: Category-Specific

/​learn backend: always add [ComputedEntityProperty] attribute to computed properties with empty setter /​learn frontend: extend AppBaseComponent instead of using raw Component /​learn workflow: always use TodoWrite before starting multi-step tasks


## How It Works

1. **Detection**: The pattern-learner hook detects your teaching input
2. **Extraction**: Extracts wrong/​right pair, keywords, and context
3. **Storage**: Saves to `.claude/​learned-patterns/​{category}/​{slug}.yaml`
4. **Injection**: Future sessions automatically inject relevant patterns based on context

## Pattern Categories

| Category | Use For |
|----------|---------|
| `backend` | C#, .NET, API, Entity, Repository patterns |
| `frontend` | Angular, TypeScript, Component, Store patterns |
| `workflow` | Development process, git, planning patterns |
| `general` | Cross-cutting concerns |

## Confidence System

- Explicit teaching starts at **80% confidence**
- Implicit corrections (detected from "no, do X instead") start at **40% confidence**
- Confidence increases when pattern is:
  - Confirmed by user
  - Injected and followed
- Confidence decreases when:
  - Pattern conflicts with user action
  - 30 days pass without use (decay)
- Patterns below **20% confidence** are auto-archived

## Conflict Checking

Patterns that conflict with `docs/​claude/​*.md` documentation are blocked to prevent inconsistencies.

## Examples

### Backend Pattern

/​learn backend: DTO mapping should be in the DTO class using MapToEntity(), not in command handlers


### Frontend Pattern

/​learn frontend: always use .pipe(this.untilDestroyed()) for subscriptions in components


### Anti-Pattern

/​learn never call external APIs directly in command handlers - use Entity Event Handlers for side effects


### Code Style

/​learn [wrong] items.Select(x => new Dto(x)).ToList() [right] items.SelectList(x => new Dto(x))


## Related Commands

| Command | Purpose |
|---------|---------|
| `/​learned-patterns` | List and manage learned patterns |
| `/​learned-patterns view <id>` | View specific pattern details |
| `/​learned-patterns archive <id>` | Archive a pattern |
| `/​learned-patterns boost <id>` | Increase pattern confidence |

## Storage Location

Patterns are stored in:

.claude/​learned-patterns/ index.yaml # Pattern lookup index backend/ # Backend patterns frontend/ # Frontend patterns workflow/ # Workflow patterns general/ # General patterns archive/ # Archived patterns


## Tips

1. **Be Specific**: Include context about when the pattern applies
2. **Use Examples**: Code blocks help clarify exact patterns
3. **Categorize**: Prefix with category for better organization
4. **Review Periodically**: Use `/​learned-patterns` to review and prune

## Technical Details

- Storage: YAML files in `.claude/​learned-patterns/`
- Detection: `pattern-learner.cjs` hook on UserPromptSubmit
- Injection: `pattern-injector.cjs` hook on SessionStart and PreToolUse
- Max injection: 5 patterns per context, ~400 tokens budget

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View