design-patterns
БесплатноБез исполняемых скриптовНе проверенPHP and Laravel design pattern advisor — suggests, implements, refactors, and reviews design patterns in your codebase. Use this skill whenever the user asks…
от nasrulhazim★ 26 звёзд на GitHubОб этом скилле
Design Patterns — PHP & Laravel
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 Reference
| 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 |
1. /pattern suggest — Pattern Recommendation
When the user describes a problem or pastes code:
Step 1: Identify the Problem Category
| 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 |
Step 2: Read the Decision Matrix
Read references/decision-matrix.md for the full mapping of problem types to patterns
with trade-offs and when-to-avoid guidance.
Step 3: Present Recommendation
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.
2. /pattern implement — Generate Pattern Code
When the user asks to implement a specific pattern:
Step 1: Confirm Context
Ask (only if not already clear):
- What is the domain entity / use case? (e.g., "Order processing", "User registration")
- Laravel or plain PHP?
- Any existing interfaces or base classes to follow?
Step 2: Read Reference Files
references/pattern-catalog.md— for GoF patterns adapted to PHP/Laravelreferences/laravel-patterns.md— for Laravel-specific patterns
Step 3: Generate Implementation
Generate 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 |
Step 4: Show Usage
Always include a usage example showing how the pattern integrates with the rest of the application — controller, route, test, or artisan command.
3. /pattern refactor — Refactor Toward Pattern
When the user pastes code that needs restructuring:
Step 1: Analyse Current Code
Identify:
- What anti-patterns exist (God controller, fat model, etc.)
- What the code is actually doing (separate concerns)
- Which pattern(s) would improve it
Step 2: Present Refactoring Plan
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.
Step 3: Generate Refactored Code
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).
Step 4: Generate Tests
For every refactored pattern, generate a Pest test that verifies the behaviour is preserved.
4. /pattern review — Architecture Review
When the user asks for a code review focused on patterns and architecture:
Step 1: Scan the Codebase
Look at:
- Controllers — are they thin? Do they delegate to actions/services?
- Models — are they doing too much? Business logic in models?
- Se
Установить design-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл design-patterns?
PHP and Laravel design pattern advisor — suggests, implements, refactors, and reviews design patterns in your codebase. Use this skill whenever the user asks about which pattern to use, wants to refactor code to follow a pattern, needs a pattern implemented, or wants a code review focused on architecture and patterns. Triggers for requests like "suggest a pattern for this", "refactor this to use repository pattern", "implement the action pattern", "review my code architecture", "which pattern should I use here", "is this a good use of singleton", "how do I decouple this", "tolong suggest pattern", "refactor guna pattern", "review architecture code ni", "pattern mana sesuai untuk ni", "nak implement strategy pattern", or "code ni dah jadi god controller, macam mana nak fix". Covers GoF patterns adapted for PHP/Laravel, Laravel-specific patterns (Actions, Services, DTOs, Value Objects, Query Scopes, Form Requests, API Resources), SOLID principles, and anti-pattern detection. Works with cleaniquecoders/laravel-action for the Action pattern.
Как установить скилл design-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл design-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic