An agent skill that reviews your design like a senior engineer: it finds code smells, judges the patterns already in your code, and refactors in small tested steps, only after you approve the plan.
npx skills@latest add ciroperf/patternwiseWhy · What you get · Commands · Install · How it works · Tested · Contributing
Ask a coding agent to "refactor with design patterns" and you usually get one of two things:
- Pattern cosplay: an
AbstractNotifierFactory, anINotifierwith one implementation, an event bus between two functions. More files, same problems. - Vague advice: "consider applying SOLID principles", with no line numbers and no plan.
patternwise makes the agent reason the way the refactoring literature does, from a concrete symptom to the smallest treatment that fixes it:
code smell ──▶ refactoring technique ──▶ design pattern (only if it fixes a problem you have today)
"switch on customer_type "Replace Conditional Strategy, as a dict of functions
repeated in 3 places" with Polymorphism" (idiomatic Python, not a class zoo)
- ⚖️ A verdict on every pattern, not just a name. Sound, misapplied, name only, over-engineered or uncertain, with the evidence.
- 📍 Evidence, not opinion. Every finding has
file:line, a severity weighted by git churn, the change it makes hard, and a named technique from a catalog of 66 refactorings. - ✂️ It deletes as readily as it adds. Over-engineering is reported as seriously as smells: Remove Middle Man and Collapse Hierarchy are first-class remedies.
- 🛡️ It never edits without asking. Fix mode shows a numbered plan, waits for your approval, runs your tests after every step, and writes characterization tests first when there are none.
- 🐛 Bugs are reported, not silently "fixed". A refactoring keeps behavior identical; a bug it finds goes in its own list.
- 🌍 Idiomatic in your language. A Strategy in Python or JS is often just a function, a Singleton is often a module. It follows your codebase's style, not a textbook's.
| Verdict | Meaning |
|---|---|
| ✅ Sound | Intent, structure and trade-off fit the problem |
| Real structure, wrong problem: e.g. a Singleton used as global mutable state | |
| 🏷️ Name only | Called *Factory / *Manager / *Proxy without the structure |
| 🧱 Over-engineered | Machinery with one variant: interface with one impl, factory for one product |
| ❓ Uncertain | Says so, and says what evidence would settle it |
Patterns found
Pattern Where Verdict Evidence Singleton shop/config.py:1⚠️ Misappliedget_instance()exposes mutable global state (orders_count); the constructor is still public"PaymentFactory" shop/payments.py:9🏷️ Name only create()always returnsCardPayment: one product, no creation decisionCode smells
Smell Where Severity Remedy Long Method OrderProcessor.process(orders.py:19)High Extract Method per phase: validation, totals, invoice Repeated switch on customer_typeshop/orders.py:35, 54, 106Medium Centralize the rules first; Strategy only if the variants keep growing
patternwise never runs on its own: you call it, and you pick the mode.
| Claude Code | Codex | What it does | Edits code? |
|---|---|---|---|
/patternwise analyze src/ |
$patternwise analyze src/ |
Pattern verdicts + code smells report | No |
/patternwise suggest src/ |
$patternwise suggest src/ |
Analyze + where a pattern or refactoring pays off | No |
/patternwise fix shop/orders.py |
$patternwise fix shop/orders.py |
Plan, your approval, then small steps with tests | Only after you approve the plan |
The path is optional, and anything after it is passed along as notes
(/patternwise fix src/ keep the public API). No mode means analyze. In Codex you can also
pick it from the /skills menu. Italian aliases work too: analizza, suggerisci, sistema.
Why explicit? A refactoring workflow should start when you ask for it, not because a prompt happened to say "clean up". In our tests implicit triggering was the least reliable part: another installed skill could win the match and edit without a plan.
Any agent (Claude Code, Codex, Cursor, Copilot, Antigravity and more, via skills.sh)
npx skills@latest add ciroperf/patternwisePick your agents interactively, or go non-interactive (-g = for your user, all projects):
npx skills@latest add ciroperf/patternwise -a claude-code -gnpx skills@latest add ciroperf/patternwise -a codex -gClaude Code plugin (auto-updates)
/plugin marketplace add ciroperf/patternwise
/plugin install patternwise@patternwise
Codex plugin
codex plugin marketplace add ciroperf/patternwisecodex plugin add patternwise@patternwiseManual
Download patternwise-vX.Y.Z.zip from the latest release
(or clone the repo) and copy skills/patternwise/ into ~/.claude/skills/
(Claude Code), ~/.agents/skills/ (Codex), or a single repo's .claude/skills/.
Optional: Python 3 for the hotspot scanner. Without it the skill falls back to git and ripgrep, or plain bash/PowerShell.
flowchart LR
A[Recognize project<br/>stack, tests, idioms] --> B[Map hotspots<br/>churn × size, type codes]
B --> C[Diagnose<br/>smells + pattern verdicts]
C --> D[Report<br/>file:line, severity, remedy]
D -->|Fix mode| E[Plan<br/>waits for approval]
E --> F[Apply one step<br/>run tests]
F -->|next step| F
F --> G[Close<br/>summary, what is left]
Under the hood:
SKILL.md: the workflow, severity rubric, report template and safety rules, under 300 lines.references/: loaded on demand, one file per finding, never all at once.- 23 code smells, each with treatments and when to ignore it.
- Smell → technique → pattern chains.
- 66 refactoring techniques with their mechanics.