Awesome-claude-code create-facade

Generates Facade pattern for PHP 8.4. Creates simplified interface to complex subsystems. 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-facade" ~/.claude/skills/dykyi-roman-awesome-claude-code-create-facade && rm -rf "$T"
manifest: skills/create-facade/SKILL.md
source content

Facade Pattern Generator

Creates Facade pattern infrastructure for providing simplified access to complex subsystems.

When to Use

ScenarioExample
Complex subsystem simplificationOrder facade combining inventory, payment, shipping
Multiple service orchestrationNotification facade coordinating email, SMS, push
Legacy system wrappingFacade hiding complex legacy APIs
Layered system accessApplication layer facade for domain services

Component Characteristics

Facade

  • Simple unified interface
  • Delegates to subsystem classes
  • No business logic, only orchestration
  • Lives in Application layer

Subsystem Classes

  • Independent complex operations
  • Can be used directly or through facade
  • Domain or Infrastructure services

Generation Process

Step 1: Generate Facade

Path:

src/Application/{BoundedContext}/Facade/

  1. {Name}Facade.php
    — Unified interface to subsystem

Step 2: Identify Subsystem Classes (Existing)

Paths: Domain or Infrastructure services

  1. Services, Repositories, External APIs
  2. Multiple components with related functionality

Step 3: Generate Tests

  1. {FacadeName}Test.php
    — Facade orchestration verification

File Placement

ComponentPath
Facade
src/Application/{BoundedContext}/Facade/
Subsystem Classes
src/Domain/
or
src/Infrastructure/
Unit Tests
tests/Unit/Application/{BoundedContext}/Facade/

Naming Conventions

ComponentPatternExample
Facade
{Name}Facade
OrderFacade
Test
{ClassName}Test
OrderFacadeTest

Quick Template Reference

Facade

final readonly class {Name}Facade
{
    public function __construct(
        private {SubsystemA} $subsystemA,
        private {SubsystemB} $subsystemB,
        private {SubsystemC} $subsystemC
    ) {}

    public function {complexOperation}({params}): {returnType}
    {
        $stepA = $this->subsystemA->{methodA}({params});
        $stepB = $this->subsystemB->{methodB}($stepA);
        $stepC = $this->subsystemC->{methodC}($stepB);

        return $stepC;
    }
}

Usage Example

// Without facade - complex coordination
$inventory = $inventoryService->reserve($productId, $quantity);
$payment = $paymentService->charge($amount, $token);
$shipment = $shippingService->schedule($address, $inventory);
$order = $orderRepository->save(new Order(...));
$notificationService->sendConfirmation($order);

// With facade - simple call
$order = $orderFacade->placeOrder($command);

Common Facades

FacadePurpose
OrderFacadeCoordinate inventory, payment, shipping, notifications
NotificationFacadeSend via email, SMS, push, Slack
ReportFacadeGenerate PDF, Excel, CSV reports
UserRegistrationFacadeValidate, create account, send welcome email
PaymentFacadeAuthorize, charge, record, notify
ExportFacadeFetch data, transform, format, save file

Anti-patterns to Avoid

Anti-patternProblemSolution
God FacadeFacade does too muchSplit into focused facades
Business Logic in FacadeFacade makes decisionsMove logic to domain services
Tight CouplingFacade depends on concrete classesInject interfaces
No Subsystem AccessClients can't bypass facadeAllow direct subsystem use
Stateful FacadeFacade holds state between callsKeep facades stateless

References

For complete PHP templates and examples, see:

  • references/templates.md
    — Facade templates for order, notification, report systems
  • references/examples.md
    — OrderFacade, NotificationFacade, ReportFacade with unit tests