/claude-toolkit:design-patternsfrom claude-toolkit
Suggests, implements, refactors, and reviews design patterns in PHP/Laravel codebases. Covers GoF patterns, Laravel-specific patterns (Actions, DTOs, Services), SOLID principles, and anti-pattern detection.
Ships in claude-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Pattern advisor for PHP and Laravel projects. Suggests the right pattern for the problem, implements it with production-ready code, refactors existing code toward better patterns, and reviews architecture for anti-patterns.
| Command | Description |
|---|---|
/pattern suggest | Analyse a problem or code snippet and recommend the best pattern(s) |
/pattern implement | Generate production-ready implementation of a specific pattern |
/pattern refactor | Refactor existing code to follow a recommended pattern |
/pattern review | Review code for anti-patterns, SOLID violations, and improvement opportunities |
/pattern suggest — Pattern RecommendationWhen the user describes a problem or pastes code:
| Problem Category | Likely Patterns |
|---|---|
| Complex object creation | Factory, Builder |
| Data access / persistence | Repository |
| Cross-cutting concerns (logging, caching, auth) | Decorator, Pipeline |
| Multiple algorithms / strategies for same task | Strategy |
| Reacting to events / side effects | Observer (Event/Listener) |
| State transitions / workflows | State Machine |
| Encapsulating a business operation | Action, Command (Job) |
| Transforming data between layers | DTO, API Resource, Value Object |
| Simplifying a complex subsystem | Facade (real), Adapter |
| Validation / input processing | Form Request |
| Query composition / reuse | Query Builder Scopes |
Read references/decision-matrix.md for the full mapping of problem types to patterns
with trade-offs and when-to-avoid guidance.
Format:
**Recommended:** [Pattern Name]
**Why:** [One sentence — what problem it solves in this context]
**Trade-off:** [What you give up]
**Alternative:** [Second-best option and when you'd pick it instead]
If multiple patterns apply (e.g., Repository + DTO), explain how they compose together.
/pattern implement — Generate Pattern CodeWhen the user asks to implement a specific pattern:
Ask (only if not already clear):
references/pattern-catalog.md — for GoF patterns adapted to PHP/Laravelreferences/laravel-patterns.md — for Laravel-specific patternsGenerate all files needed for the pattern:
| Pattern | Files Generated |
|---|---|
| Repository | Interface, Eloquent implementation, Service Provider binding |
| Action | Action class, test file (uses cleaniquecoders/laravel-action conventions) |
| Strategy | Interface, concrete strategies, context class |
| Observer | Event class, Listener class, EventServiceProvider registration |
| Pipeline | Pipeline stages as invokable classes, pipeline orchestrator |
| DTO | DTO class with fromRequest() and fromModel() factory methods |
| Value Object | Immutable class with validation in constructor, equality comparison |
| Factory | Interface, concrete factory, registration in Service Provider |
| Builder | Builder class with fluent API, Director class if needed |
| Decorator | Interface, base implementation, decorator(s), Provider binding |
| State Machine | State interface, concrete states, context class with transitions |
Always include a usage example showing how the pattern integrates with the rest of the application — controller, route, test, or artisan command.
/pattern refactor — Refactor Toward PatternWhen the user pastes code that needs restructuring:
Identify:
Before writing code, show the plan:
**Current:** [What the code does now and why it's problematic]
**Target:** [What pattern(s) to apply]
**Steps:**
1. [Extract X into Y]
2. [Create Z interface]
3. [Move logic from A to B]
**Files changed:** [List of files that will be created/modified]
Get confirmation before proceeding.
Show each file with clear comments marking what changed and why. Include before/after comparison for the main file (e.g., the controller that got thinner).
For every refactored pattern, generate a Pest test that verifies the behaviour is preserved.
/pattern review — Architecture ReviewWhen the user asks for a code review focused on patterns and architecture:
Look at:
| Anti-Pattern | Symptoms | Recommendation |
|---|---|---|
| God Controller | Controller > 200 lines, multiple responsibilities | Extract to Actions or Service classes |
| Fat Model | Model has business logic, query logic, and validation | Extract to Actions, Scopes, Form Requests |
| Service Locator | app()->make() scattered everywhere | Use constructor injection |
| Premature Abstraction | Interface with only one implementation, no plan for second | Remove interface, use concrete class |
| Anaemic Domain Model | Models are just data bags, all logic in services | Move domain logic to model methods or Value Objects |
| Leaky Abstraction | Controller knows about database columns, raw queries | Use Repository or Eloquent scopes |
| God Service | Service class > 300 lines doing everything | Split by use case into Action classes |
| Config in Code | Hardcoded values that should be configurable | Extract to config files or .env |
Format as a structured report:
## Architecture Review — [Context]
### Score: [A/B/C/D] — [One-line summary]
### Strengths
- [What's already good]
### Issues Found
1. **[SEVERITY]** [Anti-pattern name] in [file]
- Problem: [What's wrong]
- Fix: [Recommended pattern/action]
### Recommended Refactors (Priority Order)
1. [Highest impact change]
2. [Second highest]
3. [Third]
### Quick Wins
- [Small changes that improve things immediately]
ponytail is installed by default with this toolkit and enforces a minimalism ladder on every
response: skip it → reuse what exists → stdlib → native platform feature → an
already-installed dependency → one line → the minimum that works. Stop at the first rung
that holds.
Apply it before proposing any structure here. The most common failure in this skill's area is a pattern introduced for a problem that does not exist yet:
Reach for a pattern when there is a second case, not in anticipation of one. /ponytail-review
checks a diff for over-engineering; /ponytail-audit sweeps a whole repo. The ladder shortens
the solution — it never shortens the reading you do first.
| Pattern | Use When | Laravel Context |
|---|---|---|
| Factory | Need to create objects without specifying exact class | Service container bindings, notification channels |
| Builder | Complex object with many optional parameters | Query builders, mail message composition |
| Singleton | Exactly one instance needed (use sparingly) | Service container singleton() bindings |
| Pattern | Use When | Laravel Context |
|---|---|---|
| Repository | Decouple data access from business logic | Eloquent repository with interface |
| Decorator | Add behaviour without modifying original class | Cache decorator around repository |
| Adapter | Make incompatible interfaces work together | Wrapping third-party APIs |
| Facade (real) | Simplify complex subsystem interface | Not Laravel's Facade class — actual structural pattern |
| Pattern | Use When | Laravel Context |
|---|---|---|
| Strategy | Algorithm varies at runtime | Payment gateways, export formats, notification channels |
| Observer | React to events without coupling | Laravel Events + Listeners |
| Pipeline | Sequential processing with stages | Laravel Pipeline, middleware |
| Command | Encapsulate operation as object | Laravel Jobs, queued operations |
| State Machine | Object behaviour changes based on state | Order status, approval workflows |
| Pattern | Use When | Package/Feature |
|---|---|---|
| Action | Single-purpose business operation | cleaniquecoders/laravel-action |
| Service Class | Orchestrate multiple actions/repos | Plain PHP class, injected via container |
| DTO | Transfer data between layers | Plain PHP class with readonly properties |
| Value Object | Domain concept with equality by value | Immutable PHP class (Money, Email, etc.) |
| Query Scope | Reusable query constraints | Eloquent local/global scopes |
| Form Request | Validation + authorization | Laravel Form Request classes |
| API Resource | Presentation/transformation layer | Laravel API Resources + Resource Collections |
Apply these when suggesting or reviewing patterns:
| Principle | Check | Common Laravel Violation |
|---|---|---|
| S — Single Responsibility | Does this class have one reason to change? | Controller doing validation + business logic + response formatting |
| O — Open/Closed | Can I extend behaviour without modifying? | Switch statements that grow with new cases → use Strategy |
| L — Liskov Substitution | Can I swap implementations? | Repository interface methods that only work with Eloquent |
| I — Interface Segregation | Does the consumer use all methods? | Bloated service interface → split into focused interfaces |
| D — Dependency Inversion | Do I depend on abstractions? | new ConcreteClass() inside business logic → inject interface |
| File | Read When |
|---|---|
references/pattern-catalog.md | Implementing any GoF pattern — has full PHP/Laravel code examples |
references/laravel-patterns.md | Implementing Laravel-specific patterns — Actions, Services, DTOs, etc. |
references/decision-matrix.md | Deciding which pattern to use — problem-to-pattern mapping with trade-offs |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
php, laravel, design-patterns, architecture, solid, gof-patterns, anti-patterns
npx claudepluginhub nasrulhazim/claude --plugin claude-toolkit43 skills in this plugin
/business-cardSVG business card designer that takes contact details and brand preferences, then produces 12 front design concepts with optional back designs, interactive HTML preview galleries, individual card showcases with front/back flip animation, and print-ready SVG exports with bleed area and crop marks. Supports horizontal and vertical orientations, six layout styles (minimal, corporate, creative, elegant, bold, tech), multiple color schemes, QR code placeholders, social media icons, and logo integration. Use this skill whenever the user asks to design a business card, create a name card, make visiting cards, or says "design business card", "buat kad bisnes", "create name card", "reka kad perniagaan", "design kad nama", "I need a business card for X".
/ci-cd-pipelineCI/CD pipeline builder for Laravel projects — extends Kickoff's existing GitHub Actions CI with continuous deployment pipelines (staging/production), Docker containerisation, secret management, and failure notifications. Generates Dockerfiles, docker-compose.yml, deployment configs for VPS via SSH, container registry push workflows, and leverages Kickoff's /bin scripts (deploy.sh, backup.sh, setup.sh) in automated workflows. Use this skill whenever the user asks to set up deployment pipelines, containerise a Laravel app, configure CD for staging or production, push Docker images to a registry, manage deployment secrets, add failure notifications to CI, or integrate /bin scripts with GitHub Actions. Triggers for requests like "set up CD pipeline", "deploy to staging automatically", "dockerise my Laravel app", "add Docker to my project", "push image to registry", "manage secrets in CI", "notify on failure", "extend CI with deployment", "setup deploy pipeline", "nak deploy guna GitHub Actions", "tambah Docker dalam project", "setup CD untuk staging", "nak auto deploy ke production", "dockerise Laravel app aku", "tambah notification kalau CI fail", "macam mana nak manage secrets dalam GitHub Actions", or "integrate bin scripts dengan CI". Assumes Laravel Kickoff as the baseline — GitHub Actions CI (Pint, PHPStan, Rector, Pest) and /bin scripts (deploy.sh, backup.sh) are already configured. This skill extends that baseline with CD, Docker, and deployment automation.
/code-qualityPHP and Laravel code quality toolchain — static analysis with Larastan/PHPStan, code style enforcement with Pint, automated refactoring with Rector, baseline management for legacy codebases, and CI pipeline integration via GitHub Actions. Use this skill whenever the user asks to check code quality, fix linting errors, run static analysis, modernise PHP code, set up CI quality gates, manage PHPStan baselines, configure Pint presets, or apply Rector rules. Triggers for requests like "run quality check", "fix my code style", "analyse with larastan", "update phpstan baseline", "modernise my PHP code", "set up CI for quality", "check code quality", "pint tak jalan", "nak fix phpstan error", "setup rector", "betulkan code style", "tambah quality gate dalam CI", or "baseline phpstan untuk legacy code". Assumes Laravel Kickoff as the baseline — PHPStan, Pint, Rector, and GitHub Actions CI are already configured. This skill extends and customises that baseline.
/courseware-builderInteractive HTML courseware builder — turns any technical topic, flow, or process into a CD-Courseware-style interactive slide deck with animated diagrams, step-by-step simulation, syntax-highlighted code examples, and key points panels. Use this skill whenever the user wants to create teaching materials, interactive slides, animated flow diagrams, or step-by-step technical walkthroughs — even if they say "buatkan slides untuk topik X", "jadikan courseware", "buat interactive tutorial", or "create a lesson on X". Also triggers for "convert my diagram to interactive slides" or "build a visual walkthrough for my training".
/debuggingSystematic debugging and error recovery for Laravel and PHP projects — a five-step triage that goes reproduce, localise, reduce, fix, guard. Covers reading a stack trace properly, bisecting with git, isolating a failure to the smallest reproducer, telling a symptom apart from a root cause, and closing every fix with a regression test. Includes Laravel-specific traps: N+1 masked as a timeout, queue jobs failing silently on the wrong connection, cache and config caches serving stale values, Livewire state desync, and eloquent/model events firing in unexpected order. Use this skill whenever the user reports something broken, failing, flaky, slow-then-erroring, or behaving differently in production than locally — including "this test is flaky", "why is this failing", "debug this error", "it works locally but not on staging", "find the root cause", "this exception makes no sense", "the queue job never runs", "bisect this regression", "kenapa error ni", "tolong debug", "test ni kejap pass kejap fail", "cari punca sebenar", "jalan kat local tapi tak jalan kat production", or "job queue tak jalan". Pairs with kickoff-pest-testing for the regression test and log-monitor for production-log-driven investigations.
/deploy-appDeploys a Kickoff-based Laravel application to its host by running `bin/deploy` over SSH, then verifies the release and knows what each way it can stop means. Use this skill whenever the user asks to deploy an app, push the latest code to production, check what commit production is running, bring a site back up after a failed deploy, or roll back — "deploy latest", "deploy the app", "tolong deploy", "deploy latest dulu", "push to production", "apa commit dekat production", "site down after deploy", "keluarkan maintenance mode", "rollback production", "kenapa 503". Covers the deploy command and its flags, the post-deploy verification checklist, the recovery path for each failure mode, and the production traps that have already cost time. Does NOT cover provisioning a new host from bare metal (`bin/provision-host`), CI/CD pipeline design (`ci-cd-pipeline`), or writing deploy operations.
Other plugins' skills for the same job