acc-create-anti-corruption-layer
Generates DDD Anti-Corruption Layer for PHP 8.5. Creates translation layer between bounded contexts or external systems. Includes adapters, translators, facades, and unit tests.
Best use case
acc-create-anti-corruption-layer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates DDD Anti-Corruption Layer for PHP 8.5. Creates translation layer between bounded contexts or external systems. Includes adapters, translators, facades, and unit tests.
Teams using acc-create-anti-corruption-layer should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-anti-corruption-layer/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-anti-corruption-layer Compares
| Feature / Agent | acc-create-anti-corruption-layer | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates DDD Anti-Corruption Layer for PHP 8.5. Creates translation layer between bounded contexts or external systems. Includes adapters, translators, facades, and unit tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Anti-Corruption Layer Generator
Generate DDD-compliant Anti-Corruption Layer (ACL) components for isolating bounded contexts and integrating with external/legacy systems.
## When to Use
| Scenario | Example |
|----------|---------|
| Legacy system integration | ERP, CRM, mainframe |
| Third-party API integration | Payment gateway, shipping API |
| Bounded context communication | Order ↔ Inventory contexts |
| Database migration | Old schema → new domain model |
| Microservice integration | External service with different model |
## Anti-Corruption Layer Characteristics
- **Isolation**: Protects domain model from external/foreign concepts
- **Translation**: Converts between domain and external models
- **Facade**: Provides simplified interface to external systems
- **Adapter**: Implements domain ports using external services
- **No Domain Leakage**: External concepts never enter domain layer
- **Bidirectional**: Can translate both inbound and outbound
---
## ACL Architecture
```
YOUR BOUNDED CONTEXT
├── DOMAIN LAYER
│ └── Port (Interface) ←────────────┐
│ │
├── ANTI-CORRUPTION LAYER │
│ ├── Adapter (implements Port) ────┘
│ ├── Translator (Domain ↔ External)
│ ├── Facade (External system wrapper)
│ └── External DTOs
│
└── EXTERNAL SYSTEM (Legacy, API, other bounded context)
```
---
## Generation Process
### Step 1: Generate Domain Port
**Path:** `src/Domain/{BoundedContext}/Port/`
1. `{ExternalSystem}PortInterface.php` — Domain interface for external system
### Step 2: Generate External DTOs
**Path:** `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/DTO/`
1. `{ExternalSystem}{Concept}DTO.php` — DTOs matching external format
### Step 3: Generate Translator
**Path:** `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/`
1. `{ExternalSystem}Translator.php` — Domain ↔ External conversion
### Step 4: Generate Facade
**Path:** `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/`
1. `{ExternalSystem}Facade.php` — Simplified external system interface
### Step 5: Generate Adapter
**Path:** `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/`
1. `{ExternalSystem}Adapter.php` — Implements domain port
### Step 6: Generate Exceptions
**Path:** `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/Exception/`
1. `{ExternalSystem}Exception.php` — Domain exception
2. `{ExternalSystem}ConnectionException.php` — Infrastructure exception
### Step 7: Generate Tests
1. `{ExternalSystem}TranslatorTest.php` — Translation tests
2. `{ExternalSystem}AdapterTest.php` — Adapter integration tests
---
## File Placement
| Component | Path |
|-----------|------|
| Domain Port | `src/Domain/{BoundedContext}/Port/{ExternalSystem}PortInterface.php` |
| External DTO | `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/DTO/` |
| Translator | `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/{ExternalSystem}Translator.php` |
| Facade | `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/{ExternalSystem}Facade.php` |
| Adapter | `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/{ExternalSystem}Adapter.php` |
| Exceptions | `src/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/Exception/` |
| Tests | `tests/Unit/Infrastructure/{BoundedContext}/ACL/{ExternalSystem}/` |
---
## Naming Conventions
| Component | Pattern | Example |
|-----------|---------|---------|
| Port | `{ExternalSystem}PortInterface` | `PaymentGatewayPortInterface` |
| DTO | `{ExternalSystem}{Concept}DTO` | `StripeChargeDTO` |
| Translator | `{ExternalSystem}Translator` | `StripeTranslator` |
| Facade | `{ExternalSystem}Facade` | `StripeFacade` |
| Adapter | `{ExternalSystem}Adapter` | `StripeAdapter` |
| Exception | `{ExternalSystem}Exception` | `StripeException` |
---
## Quick Template Reference
### Domain Port
```php
interface {ExternalSystem}PortInterface
{
public function {operation}({DomainParameters}): {DomainReturnType};
}
```
### Translator
```php
final readonly class {ExternalSystem}Translator
{
public function toDomain({ExternalSystem}DTO $dto): {Entity};
public function toExternal({Entity} $entity): {ExternalSystem}DTO;
}
```
### Adapter
```php
final readonly class {ExternalSystem}Adapter implements {ExternalSystem}PortInterface
{
public function __construct(
private {ExternalSystem}Facade $facade,
private {ExternalSystem}Translator $translator,
) {}
public function {operation}({DomainParameters}): {DomainReturnType}
{
$dto = $this->translator->toExternal($entity);
$result = $this->facade->{externalOperation}($dto);
return $this->translator->toDomain($result);
}
}
```
---
## Usage Example
```php
// Domain port interface
interface PaymentGatewayPortInterface
{
public function charge(Payment $payment): PaymentId;
public function refund(PaymentId $paymentId, Money $amount): void;
}
// Adapter implementation
final readonly class StripeAdapter implements PaymentGatewayPortInterface
{
public function charge(Payment $payment): PaymentId
{
$stripeCharge = $this->translator->toStripeCharge($payment);
$result = $this->facade->createCharge($stripeCharge);
return $this->translator->toPaymentId($result);
}
}
```
---
## Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|--------------|---------|----------|
| Domain using external DTOs | External concepts leak into domain | Always translate at ACL boundary |
| Translator in domain layer | Infrastructure concern in domain | Keep translator in infrastructure |
| Exposing external exceptions | Coupling to external system | Wrap in domain exceptions |
| Direct API calls from domain | No isolation | Use port/adapter pattern |
| Shared DTOs across ACLs | Coupling between integrations | Each ACL has own DTOs |
| Business logic in translator | Wrong responsibility | Translator only maps data |
---
## DI Configuration
```yaml
# services.yaml
Domain\Payment\Port\PaymentGatewayPortInterface:
alias: Infrastructure\Payment\ACL\Stripe\StripeAdapter
Infrastructure\Payment\ACL\Stripe\StripeFacade:
arguments:
$client: '@stripe.client'
```
---
## References
For complete PHP templates and examples, see:
- `references/templates.md` — Domain Port, External DTO, Translator, Facade, Adapter, Exception templates
- `references/examples.md` — Stripe Payment Gateway ACL complete example and testsRelated Skills
acuantia-dataform
Use when working on Acuantia's BigQuery Dataform pipeline (acuantia-gcp-dataform project) - adds Acuantia-specific patterns on top of dataform-engineering-fundamentals: ODS two-arg ref() syntax, looker_ filename prefix, Looker integration (looker_prod/looker_dev), acuantia dataset conventions, coordination with callrail_data_export/dialpad_data_integration/looker projects
acc-layer-arch-knowledge
Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered Architecture audits.
acc-create-value-object
Generates DDD Value Objects for PHP 8.5. Creates immutable, self-validating objects with equality comparison. Includes unit tests.
acc-create-use-case
Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
acc-create-test-builder
Generates Test Data Builder and Object Mother patterns for PHP 8.5. Creates fluent builders with sensible defaults and factory methods for test data creation.
acc-create-strategy
Generates Strategy pattern for PHP 8.5. Creates interchangeable algorithm families with context class, strategy interface, and concrete implementations. Includes unit tests.
acc-create-state
Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.
acc-create-specification
Generates DDD Specification for PHP 8.5. Creates reusable business rule objects for validation, filtering, and querying with composite pattern support. Includes unit tests.
acc-create-saga-pattern
Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.
acc-create-retry-pattern
Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.