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.md
source content

Bridge Pattern Generator

Creates Bridge pattern infrastructure for separating abstraction from implementation.

When to Use

ScenarioExample
Multiple dimensions of variationNotification types × channels
Avoid class explosionShape × rendering method
Runtime implementation switchingDatabase drivers
Platform independenceUI × 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}/

  1. {Name}ImplementorInterface.php
    — Low-level operations

Step 2: Generate Abstraction

Path:

src/Domain/{BoundedContext}/

  1. Abstract{Name}.php
    — High-level interface

Step 3: Generate RefinedAbstraction

Path:

src/Domain/{BoundedContext}/

  1. {Type}{Name}.php
    — Specialized abstractions

Step 4: Generate ConcreteImplementors

Path:

src/Infrastructure/{BoundedContext}/

  1. {Platform}{Name}Implementor.php
    — Platform implementations

Step 5: Generate Tests

  1. {ClassName}Test.php
    — Bridge behavior verification

File Placement

ComponentPath
Abstraction
src/Domain/{BoundedContext}/
RefinedAbstraction
src/Domain/{BoundedContext}/
Implementor Interface
src/Domain/{BoundedContext}/
ConcreteImplementor
src/Infrastructure/{BoundedContext}/
Unit Tests
tests/Unit/

Naming Conventions

ComponentPatternExample
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

BridgePurpose
NotificationBridgeType × Channel (Email/SMS/Push)
ReportBridgeFormat × Generator (PDF/Excel/CSV)
DatabaseBridgeQuery × Driver (MySQL/PostgreSQL)
PaymentBridgeGateway × Provider (Stripe/PayPal)

Anti-patterns to Avoid

Anti-patternProblemSolution
Missing AbstractionDirect implementor useUse abstraction layer
Tight CouplingAbstraction knows concrete implementorDepend on interface
Single ImplementationNo variationUse simple inheritance
Leaky AbstractionExposes implementor detailsHide implementation

References

For complete PHP templates and examples, see:

  • references/templates.md
    — Abstraction, refined abstraction, implementor templates
  • references/examples.md
    — Notification, report bridges with unit tests