Awesome-claude-code create-bridge
Generates Bridge pattern for PHP 8.4. Decouples abstraction from implementation. Includes unit tests.
install
source · Clone the upstream repo
git clone https://github.com/dykyi-roman/awesome-claude-code
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/dykyi-roman/awesome-claude-code "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/create-bridge" ~/.claude/skills/dykyi-roman-awesome-claude-code-create-bridge && rm -rf "$T"
manifest:
skills/create-bridge/SKILL.mdsource content
Bridge Pattern Generator
Creates Bridge pattern infrastructure for separating abstraction from implementation.
When to Use
| Scenario | Example |
|---|---|
| Multiple dimensions of variation | Notification types × channels |
| Avoid class explosion | Shape × rendering method |
| Runtime implementation switching | Database drivers |
| Platform independence | UI × OS |
Component Characteristics
Abstraction
- High-level interface
- Uses implementor
- Domain layer
RefinedAbstraction
- Extends abstraction
- Adds specialized behavior
Implementor Interface
- Low-level operations
- Multiple implementations
ConcreteImplementor
- Actual implementation
- Platform-specific code
Generation Process
Step 1: Generate Implementor Interface
Path:
src/Domain/{BoundedContext}/
— Low-level operations{Name}ImplementorInterface.php
Step 2: Generate Abstraction
Path:
src/Domain/{BoundedContext}/
— High-level interfaceAbstract{Name}.php
Step 3: Generate RefinedAbstraction
Path:
src/Domain/{BoundedContext}/
— Specialized abstractions{Type}{Name}.php
Step 4: Generate ConcreteImplementors
Path:
src/Infrastructure/{BoundedContext}/
— Platform implementations{Platform}{Name}Implementor.php
Step 5: Generate Tests
— Bridge behavior verification{ClassName}Test.php
File Placement
| Component | Path |
|---|---|
| Abstraction | |
| RefinedAbstraction | |
| Implementor Interface | |
| ConcreteImplementor | |
| Unit Tests | |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Abstraction | | |
| RefinedAbstraction | | |
| Implementor Interface | | |
| ConcreteImplementor | | |
Quick Template Reference
Abstraction
abstract readonly class Abstract{Name} { public function __construct( protected {Name}ImplementorInterface $implementor ) {} abstract public function {operation}({params}): {returnType}; }
RefinedAbstraction
final readonly class {Type}{Name} extends Abstract{Name} { public function {operation}({params}): {returnType} { {preprocessing} return $this->implementor->{implementorMethod}({params}); } }
Usage Example
$email = new EmailNotificationImplementor(); $urgent = new UrgentNotification($email); $urgent->send($message); // Switch implementation $sms = new SmsNotificationImplementor(); $urgent = new UrgentNotification($sms); $urgent->send($message);
Common Bridges
| Bridge | Purpose |
|---|---|
| NotificationBridge | Type × Channel (Email/SMS/Push) |
| ReportBridge | Format × Generator (PDF/Excel/CSV) |
| DatabaseBridge | Query × Driver (MySQL/PostgreSQL) |
| PaymentBridge | Gateway × Provider (Stripe/PayPal) |
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Missing Abstraction | Direct implementor use | Use abstraction layer |
| Tight Coupling | Abstraction knows concrete implementor | Depend on interface |
| Single Implementation | No variation | Use simple inheritance |
| Leaky Abstraction | Exposes implementor details | Hide implementation |
References
For complete PHP templates and examples, see:
— Abstraction, refined abstraction, implementor templatesreferences/templates.md
— Notification, report bridges with unit testsreferences/examples.md