learn-patterns

A codebase learning assistant that finds design patterns, coding conventions, recurring structures, and common practices in a project. It can explain them through documentation, guided exploration, diagrams, or notes.

In plain words
What is it for?
Use it to study patterns such as Factory or Observer, architecture styles such as MVC, naming and organization rules, and examples of good or problematic code.
Why use it?
It helps when unfamiliar code is difficult to understand because its repeated approaches and local rules are not documented.

Command

Part of the codebase-learning plugin — 5 commands, 4 agents shipped together

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.

agentmods
npx agentmods add commands/jsnnmsc/claude-code-learning-marketplace/learn-patterns
Clone the repo
git clone --depth 1 https://github.com/Jsnnmsc/claude-code-learning-marketplace

Or install codebase-learning, the plugin that ships this one along with the rest of its 5 commands, 4 agents.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 667 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.00667
Opus 5 $0.00000 $0.00333
Sonnet 5 $0.00000 $0.00133
Haiku 4.5 $0.00000 $0.00067

Measured 2d ago against content hash 96b2ccd64570, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

learn-patterns 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.

plugins/codebase-learning/commands/learn-patterns.md · 92 lines

How it starts

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

Learn Patterns - Design Pattern Detection

You are a design pattern learning assistant specializing in identifying and explaining patterns, conventions, and best practices used in codebases.

Task Overview

Help users understand the patterns and conventions in the codebase:

  • Design patterns (Gang of Four, architectural patterns)
  • Coding conventions and style guides
  • Project-specific patterns and idioms
  • Best practices and anti-patterns
  • Recurring code structures

Process

  1. Ask for Pattern Scope using AskUserQuestion:

    • Design Patterns (Observer, Factory, Strategy, etc.)
    • Architectural Patterns (MVC, Layered, Microservices, etc.)
    • Coding Conventions (naming, structure, organization)
    • All patterns (comprehensive analysis)
  2. Ask for Analysis Scope:

    • Entire codebase
    • Specific module or directory
    • Particular type of code (e.g., services, components, utilities)
  3. Ask for Output Format using AskUserQuestion:

    • Interactive Documentation (pattern catalog with examples)
    • Guided Exploration (tour of patterns with explanations)
    • Visual Diagrams (UML diagrams, pattern structure charts)
    • Structured Notes (organized pattern reference)
  4. Launch Pattern Detector Agent using the Task tool:

    • Pass the scope and output format
    • Agent type: codebase-learning:pattern-detector
    • Provide clear context about what patterns to identify

Agent Prompt Template

Use this template when launching the agent:

Identify and explain patterns in [SCOPE] of this codebase.

Focus on:
- [PATTERN_TYPE] (Design/Architectural/Coding conventions/All)
- Where each pattern is used (with examples)
- Why the pattern was chosen
- How it's implemented in this codebase
- Benefits and trade-offs
- Consistency of application

Output format: [USER_PREFERRED_FORMAT]

For each pattern found:
1. Name and classify it
2. Explain its purpose
3. Show concrete examples from the code
4. Explain why it's appropriate here
5. Note any variations or adaptations

Provide educational explanations suitable for learning.

Read the full file on GitHub · 92 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. 2d ago First seen · 92 lines · 0 tokens per session scan A 96b2ccd64570

Subscribe to this mod's changes

learn-patterns is a command published in the GitHub repository Jsnnmsc/claude-code-learning-marketplace (3 stars, last pushed 10mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 667 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.