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.

16 stars

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

$curl -o ~/.claude/skills/acc-create-anti-corruption-layer/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/acc-create-anti-corruption-layer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/acc-create-anti-corruption-layer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How acc-create-anti-corruption-layer Compares

Feature / Agentacc-create-anti-corruption-layerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/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 tests

Related Skills

acc-create-bulkhead

16
from diegosouzapw/awesome-omni-skill

Generates Bulkhead pattern for PHP 8.5. Creates resource isolation with semaphore-based concurrency limiting and thread pool isolation. Includes unit tests.

acc-create-action

16
from diegosouzapw/awesome-omni-skill

Generates ADR Action classes for PHP 8.5. Creates single-responsibility HTTP endpoint handlers with PSR-7 support. Includes unit tests.

ui-design-create-component

16
from diegosouzapw/awesome-omni-skill

Guided component creation with proper patterns Use when: the user asks to run the `create-component` workflow and the task requires multi-step orchestration. Do not use when: the task is small, single-step, and can be completed directly without orchestration overhead.

create-rule

16
from diegosouzapw/awesome-omni-skill

Create project rules for persistent AI guidance. Use when the user wants to create a rule, add coding standards, set up project conventions, configure file-specific patterns, create RULE.md files, or asks about the workspace rules directory or AGENTS.md.

create-design-system-rules

16
from diegosouzapw/awesome-omni-skill

Generates custom design system rules for the user's codebase. Use when user says "create design system rules", "generate rules for my project", "set up design rules", "customize design system guidelines", or wants to establish project-specific conventions for Figma-to-code workflows. Requires Figma MCP server connection.

antiquities-extractor

16
from diegosouzapw/awesome-omni-skill

Extract and structure data from documents about the illegal antiquities trade, including dealers, collectors, artifacts, locations, and relationships. Use when processing news reports, academic articles, legal documents, encyclopedia entries, or research materials pertaining to looted artifacts, antiquities trafficking, provenance research, or cultural heritage crimes. Returns structured JSON with entities (persons, organizations, artifacts, locations) and their relationships.

anticipation-payoff

16
from diegosouzapw/awesome-omni-skill

Use when designing action sequences, gags, reveals, or any motion that needs setup before delivery—preparing audiences for what's coming and maximizing impact.

anticipation-mastery

16
from diegosouzapw/awesome-omni-skill

Use when designing action sequences, user interactions, state transitions, or any motion that needs telegraphing to feel intentional rather than sudden.

---name: antibody-design-agent

16
from diegosouzapw/awesome-omni-skill

description: An advanced agent for de novo antibody design and optimization using state-of-the-art protein language models (MAGE, RFdiffusion).

typespec-m365-copilot-typespec-create-agent

16
from diegosouzapw/awesome-omni-skill

Generate a complete TypeSpec declarative agent with instructions, capabilities, and conversation starters for Microsoft 365 Copilot Use when: the task directly matches typespec create agent responsibilities within plugin typespec-m365-copilot. Do not use when: a more specific framework or task-focused skill is clearly a better match.

typespec-create-agent

16
from diegosouzapw/awesome-omni-skill

Generate a complete TypeSpec declarative agent with instructions, capabilities, and conversation starters for Microsoft 365 Copilot

rust-anti-pattern

16
from diegosouzapw/awesome-omni-skill

Rust 反模式与常见错误。处理代码审查、clone、unwrap、String 用法、迭代器等问题。触发词:anti-pattern, common mistake, clone, unwrap, code review, 代码异味, 常见错误, 代码审查, refactor, 重构