acc-create-bridge
1
总安装量
1
周安装量
#51825
全站排名
安装命令
npx skills add https://github.com/dykyi-roman/awesome-claude-code --skill acc-create-bridge
Agent 安装分布
opencode
1
claude-code
1
Skill 文档
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}/
{Name}ImplementorInterface.phpâ Low-level operations
Step 2: Generate Abstraction
Path: src/Domain/{BoundedContext}/
Abstract{Name}.phpâ High-level interface
Step 3: Generate RefinedAbstraction
Path: src/Domain/{BoundedContext}/
{Type}{Name}.phpâ Specialized abstractions
Step 4: Generate ConcreteImplementors
Path: src/Infrastructure/{BoundedContext}/
{Platform}{Name}Implementor.phpâ Platform implementations
Step 5: Generate Tests
{ClassName}Test.phpâ Bridge behavior verification
File Placement
| Component | Path |
|---|---|
| Abstraction | src/Domain/{BoundedContext}/ |
| RefinedAbstraction | src/Domain/{BoundedContext}/ |
| Implementor Interface | src/Domain/{BoundedContext}/ |
| ConcreteImplementor | src/Infrastructure/{BoundedContext}/ |
| Unit Tests | tests/Unit/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Abstraction | Abstract{Name} |
AbstractNotification |
| RefinedAbstraction | {Type}{Name} |
UrgentNotification |
| Implementor Interface | {Name}ImplementorInterface |
NotificationImplementorInterface |
| ConcreteImplementor | {Platform}{Name}Implementor |
EmailNotificationImplementor |
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:
references/templates.mdâ Abstraction, refined abstraction, implementor templatesreferences/examples.mdâ Notification, report bridges with unit tests