Back to search
pattern-advisor
MarketplaceWorks with Claude CodeGitHub
Claude Code plugin: picks the right design pattern (or deliberately none) when Claude adds a feature, fixes a bug or refactors.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Checked today
Badge for your README
Markdown
[](/listings/abderrahmannjeh--pattern-advisor)HTML
<a href="/listings/abderrahmannjeh--pattern-advisor"><img src="/api/listings/abderrahmannjeh--pattern-advisor/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
In Claude Code:
/plugin marketplace add abderrahmannjeh/pattern-advisor /plugin install pattern-advisor@pattern-advisor
Or from a terminal:
claude plugin marketplace add abderrahmannjeh/pattern-advisor claude plugin install pattern-advisor@pattern-advisor
Try it locally without installing:
claude --plugin-dir ./pattern-advisor
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 19 lines
- {
- "name": "pattern-advisor",
- "owner": {
- "name": "Abderrahman Njeh"
- },
- "metadata": {
- "description": "Design-pattern guidance for Claude Code."
- },
- "plugins": [
- {
- "name": "pattern-advisor",
- "source": "./",
- "description": "Makes Claude pick the right design pattern (or deliberately none) when it adds a feature, fixes a bug or refactors.",
- "version": "0.2.0",
- "category": "development",
- "keywords": ["design-patterns", "architecture", "refactoring", "code-quality"]
- }
- ]
- }
README.md · README · 120 lines
- # pattern-advisor
- A Claude Code plugin that makes Claude **think about design patterns before it writes code** —
- and, just as important, **refuse patterns that aren't needed**.
- When Claude adds a feature, fixes a bug or refactors, the plugin makes it:
- 1. **Read the house style first** — which patterns your codebase already uses for this kind of problem, so new code stays consistent.
- 2. **Name the forces** — what varies, how many variants really exist, what must stay stable.
- 3. **Map symptoms to patterns** — repeated `switch` on a type → Strategy / sealed types; constructor with 9 params → Builder or options object; vendor SDK leaking everywhere → Adapter; invalid status transitions → State machine…
- 4. **Apply the "earns its place" test** — rule of three, local next change, idiomatic in *your* language, cheaper to read than before.
- 5. **Use the idiomatic form** — a dict of functions in Python, a discriminated union in TypeScript, a sealed class in Kotlin, an enum + `match` in Rust — not Java-style class hierarchies everywhere.
- 6. **Keep bug fixes minimal** — fix first, propose the refactor separately.
- 7. **Tell you what it chose and why** in a two-line note — and, when a pattern isn't worth it *yet*, the threshold at which it would be ("if a 3rd provider arrives, extract a Strategy").
- ## What's inside
- | Component | Name | What it does |
- |---|---|---|
- | Skill (auto) | `design-patterns` | Loaded automatically when Claude is about to add a feature, fix a structural bug or refactor. |
- | Command | `/pattern-advisor:suggest <feature \| file \| bug>` | Advice only: recommended pattern, sketch in your codebase's style, rejected alternatives. |
- | Command | `/pattern-advisor:review [file \| ref] [--apply]` | Reviews the diff (or a path) for missing patterns, misused patterns and over-engineering (up to 5 findings + a "leave alone" list). `--apply` applies the low/medium-risk ones in small, tested steps. |
- | Agent | `pattern-scout` | Fast read-only agent that maps the conventions and extension points of an area of the repo. |
- | Hook | `SessionStart` | Adds a ~100-token reminder at session start so Claude reliably loads the skill before feature/fix/refactor edits (in tests, without it Claude often skipped the skill and copy-pasted the new case into every branch). |
- Reference material the skill reads on demand:
- - `smell-to-pattern.md` — symptom → candidate patterns (incl. bug-fix signals and UI patterns)
- - `catalog.md` — GoF + modern patterns (Repository, DI, Value Object, Use Case, MVVM/MVI, Outbox, Circuit Breaker, Specification, hooks…) with *use when / avoid when / lightest form*
- - `languages/` — code examples of the idiomatic form in **TypeScript/JavaScript, Python, Kotlin/Java (Android), C#/.NET, PHP, Dart/Flutter**
- - `language-idioms.md` — one-table overview across languages, including Go and Rust
- - `refactoring.md` — smell → refactoring, patterns to *remove*, safe small steps, report format
- - `anti-patterns.md` — over-engineering checklist run after writing code
- ## Install
- In Claude Code:
- ```
- /plugin marketplace add abderrahmannjeh/pattern-advisor
- /plugin install pattern-advisor@pattern-advisor
- ```
- Or from a terminal:
- ```bash
- claude plugin marketplace add abderrahmannjeh/pattern-advisor
- claude plugin install pattern-advisor@pattern-advisor
- ```
- Try it locally without installing:
- ```bash
- claude --plugin-dir ./pattern-advisor
- ```
- ## Examples
- ```
- > Add a "student" pricing mode to checkout
- ```
- Claude surveys `pricing/`, sees three modes in an `if/else` chain duplicated in two files,
- turns them into a map of pricing functions, adds `student` as one entry, and ends with:
- > **Pattern:** Strategy (map of pricing functions) — 3 modes already branched in 2 places; new modes are now one entry.
- > **Considered:** State — rejected, mode doesn't change during an order's life.
- ```
- > /pattern-advisor:suggest we need to send notifications by email, SMS and Slack, urgent or digest
- ```
- → recommends Bridge-like separation of *channel* × *delivery policy* instead of 6 classes.
- ```
- > Fix: orders in "cancelled" can still be shipped
- ```
- → minimal guard fix now; proposes an explicit transition table as a follow-up instead of bundling a refactor into the fix.
- ## Philosophy
- - Patterns answer forces; no forces, no pattern.
- - Consistency with the existing codebase beats textbook optimality.
- - Architecture-level patterns (hexagonal, CQRS, event sourcing, sagas) are surfaced as proposals, never slipped into a feature.
- ## Does it actually work? — evals
- `evals/` holds 5 scenarios run **with and without** the plugin (`claude plugin eval`), each graded by file checks plus an LLM judge:
- | Scenario | What a pass means | With plugin | Without |
- |---|---|---|---|
- | `feature-duplicated-branches` (TS) | new pricing mode added by consolidating 3 duplicated branches into one table | 2/2 | 0/2 |
- | `feature-python-channels` (Python) | new notification channel added without a 3rd `elif` in 3 files | 2/2 | 0/2 |
- | `trivial-label-change` | one-line edit, no refactor | 2/2 | 2/2 |
- | `simple-param-no-pattern` | optional CC param, no Builder/class | 2/2 | 2/2 |
- | `bugfix-stays-minimal` | minimal guard, no State-pattern rewrite inside a fix | 2/2 | 2/2 |
- Measured on 2026-11-19 with Sonnet, 2 runs per arm. The plugin changes behaviour exactly where a pattern is due and leaves the other cases alone. Cost: about +0.03 USD per feature task (the skill is read before coding).
- Reproduce:
- ```bash
- claude plugin eval . --scaffold --allow-tools Edit Write --model sonnet -j 4
- ```
- ## Credits
- v0.2 merges ideas and the per-language reference files from *pattern-pilot*, an earlier take on the same plugin by the same author.
- ## Contributing
- Issues and PRs welcome — especially new smell → pattern rows, language idioms, and counter-examples where the plugin over-engineers.
- Validate before opening a PR:
- ```bash
- claude plugin validate . --strict
- ```
- ## License
- MIT
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.