acc-hexagonal-knowledge

Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.

16 stars

Best use case

acc-hexagonal-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.

Teams using acc-hexagonal-knowledge 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-hexagonal-knowledge-majiayu000/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/tools/acc-hexagonal-knowledge-majiayu000/SKILL.md"

Manual Installation

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

How acc-hexagonal-knowledge Compares

Feature / Agentacc-hexagonal-knowledgeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.

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

# Hexagonal Architecture Knowledge Base

Quick reference for Hexagonal Architecture (Ports & Adapters) patterns and PHP implementation guidelines.

## Core Principles

### Hexagonal Architecture Overview

```
                         ┌─────────────────────────────┐
                         │      PRIMARY ACTORS         │
                         │   (Users, External Apps)    │
                         └──────────────┬──────────────┘
                                        │
                         ┌──────────────▼──────────────┐
                         │     DRIVING ADAPTERS        │
                         │  (Controllers, CLI, GUI,    │
                         │   Message Consumers)        │
                         └──────────────┬──────────────┘
                                        │
              ┌─────────────────────────▼─────────────────────────┐
              │                  DRIVING PORTS                     │
              │              (Input Interfaces)                    │
              └─────────────────────────┬─────────────────────────┘
                                        │
              ┌─────────────────────────▼─────────────────────────┐
              │                                                    │
              │              APPLICATION CORE                      │
              │     ┌─────────────────────────────────┐           │
              │     │       APPLICATION LAYER         │           │
              │     │      (Use Cases, Services)      │           │
              │     └─────────────────┬───────────────┘           │
              │                       │                            │
              │     ┌─────────────────▼───────────────┐           │
              │     │         DOMAIN LAYER            │           │
              │     │  (Entities, Value Objects,      │           │
              │     │   Domain Services)              │           │
              │     └─────────────────────────────────┘           │
              │                                                    │
              └─────────────────────────┬─────────────────────────┘
                                        │
              ┌─────────────────────────▼─────────────────────────┐
              │                  DRIVEN PORTS                      │
              │            (Output Interfaces)                     │
              └─────────────────────────┬─────────────────────────┘
                                        │
                         ┌──────────────▼──────────────┐
                         │      DRIVEN ADAPTERS        │
                         │  (Repositories, External    │
                         │   APIs, Message Publishers) │
                         └──────────────┬──────────────┘
                                        │
                         ┌──────────────▼──────────────┐
                         │     SECONDARY ACTORS        │
                         │  (Database, External APIs,  │
                         │   Message Queues)           │
                         └─────────────────────────────┘
```

**Core Rule:** Application Core defines Ports. Adapters implement or use them.

### Key Concepts

| Concept | Description | Location |
|---------|-------------|----------|
| **Port** | Interface defining how to interact with the core | Application/Domain |
| **Driving Port** | Input interface (how to use the application) | Application layer |
| **Driven Port** | Output interface (what the application needs) | Application/Domain |
| **Driving Adapter** | Implements input mechanism (HTTP, CLI) | Infrastructure |
| **Driven Adapter** | Implements external dependencies | Infrastructure |
| **Application Core** | Business logic, isolated from I/O | Domain + Application |

## Quick Checklists

### Driving Port Checklist

- [ ] Interface in Application layer
- [ ] Defines use case boundary
- [ ] Uses domain/application types
- [ ] No framework types
- [ ] Single responsibility

### Driven Port Checklist

- [ ] Interface in Application/Domain layer
- [ ] Abstracts external dependency
- [ ] Uses domain types for return values
- [ ] No implementation details in signature
- [ ] Can have multiple adapters

### Driving Adapter Checklist

- [ ] Implements/calls driving port
- [ ] Converts external format to domain format
- [ ] No business logic
- [ ] Framework code contained here
- [ ] One adapter per delivery mechanism

### Driven Adapter Checklist

- [ ] Implements driven port interface
- [ ] Converts domain format to external format
- [ ] No business logic
- [ ] Handles external errors
- [ ] Easily replaceable

## Common Violations Quick Reference

| Violation | Where to Look | Severity |
|-----------|---------------|----------|
| Core depends on adapter | Domain importing Infrastructure | Critical |
| Missing port abstraction | Direct external service call | Critical |
| Business logic in adapter | if/switch in adapter | Critical |
| Framework in core | Symfony/Laravel in Domain | Warning |
| Port with implementation details | Interface using DB types | Warning |
| Adapter without port | Controller calling repository directly | Warning |

## PHP 8.5 Hexagonal Patterns

### Driving Port (Use Case Interface)

```php
<?php

declare(strict_types=1);

namespace Application\Order\Port\Input;

use Application\Order\DTO\CreateOrderRequest;
use Application\Order\DTO\CreateOrderResponse;

interface CreateOrderUseCaseInterface
{
    public function execute(CreateOrderRequest $request): CreateOrderResponse;
}
```

### Driven Port (Repository Interface)

```php
<?php

declare(strict_types=1);

namespace Domain\Order\Port\Output;

use Domain\Order\Entity\Order;
use Domain\Order\ValueObject\OrderId;

interface OrderRepositoryInterface
{
    public function findById(OrderId $id): ?Order;
    public function save(Order $order): void;
    public function nextIdentity(): OrderId;
}
```

### Driving Adapter (HTTP Controller)

```php
<?php

declare(strict_types=1);

namespace Infrastructure\Http\Controller;

use Application\Order\Port\Input\CreateOrderUseCaseInterface;
use Application\Order\DTO\CreateOrderRequest;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

final readonly class CreateOrderController
{
    public function __construct(
        private CreateOrderUseCaseInterface $createOrder
    ) {}

    public function __invoke(Request $request): JsonResponse
    {
        $dto = CreateOrderRequest::fromArray($request->toArray());

        $response = $this->createOrder->execute($dto);

        return new JsonResponse($response->toArray(), 201);
    }
}
```

### Driven Adapter (Repository Implementation)

```php
<?php

declare(strict_types=1);

namespace Infrastructure\Persistence\Doctrine;

use Domain\Order\Entity\Order;
use Domain\Order\Port\Output\OrderRepositoryInterface;
use Domain\Order\ValueObject\OrderId;
use Doctrine\ORM\EntityManagerInterface;

final readonly class DoctrineOrderRepository implements OrderRepositoryInterface
{
    public function __construct(
        private EntityManagerInterface $em
    ) {}

    public function findById(OrderId $id): ?Order
    {
        return $this->em->find(Order::class, $id->value);
    }

    public function save(Order $order): void
    {
        $this->em->persist($order);
        $this->em->flush();
    }

    public function nextIdentity(): OrderId
    {
        return OrderId::generate();
    }
}
```

## References

For detailed information, load these reference files:

- `references/ports-patterns.md` — Driving and Driven Port patterns
- `references/adapters-patterns.md` — Adapter implementation patterns
- `references/testing-patterns.md` — Testing strategies for hexagonal architecture
- `references/antipatterns.md` — Common violations with detection patterns

Related Skills

acc-stability-patterns-knowledge

16
from diegosouzapw/awesome-omni-skill

Stability Patterns knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Circuit Breaker, Retry, Rate Limiter, Bulkhead, and resilience audits.

acc-solid-knowledge

16
from diegosouzapw/awesome-omni-skill

SOLID principles knowledge base for PHP 8.5 projects. Provides quick reference for SRP, OCP, LSP, ISP, DIP with detection patterns, PHP examples, and antipattern identification. Use for architecture audits and code quality reviews.

acc-saga-pattern-knowledge

16
from diegosouzapw/awesome-omni-skill

Saga Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for saga orchestration, choreography, and distributed transaction audits.

acc-cqrs-knowledge

16
from diegosouzapw/awesome-omni-skill

CQRS architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Command Query Responsibility Segregation audits.

acc-testing-knowledge

16
from diegosouzapw/awesome-omni-skill

Testing knowledge base for PHP 8.5 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

acc-psr-overview-knowledge

16
from diegosouzapw/awesome-omni-skill

PHP Standards Recommendations (PSR) overview knowledge base. Provides comprehensive reference for all accepted PSRs including PSR-1,3,4,6,7,11,12,13,14,15,16,17,18,20. Use for PSR selection decisions and compliance audits.

acc-psr-coding-style-knowledge

16
from diegosouzapw/awesome-omni-skill

PSR-1 and PSR-12 coding standards knowledge base for PHP 8.5 projects. Provides quick reference for basic coding standard and extended coding style with detection patterns, examples, and antipattern identification. Use for code style audits and compliance reviews.

app-knowledge

16
from diegosouzapw/awesome-omni-skill

When any part of the application needs to be found or understood.

knowledge-base-cache

16
from diegosouzapw/awesome-omni-skill

Create and manage a layered knowledge base with hot/cold/warm cache tiers. Provides component-based architecture with Working Memory layer, automatic caching, semantic retrieval, and intelligent context assembly. Reduces API costs and supports unlimited knowledge scale.

knowledge-capture

16
from diegosouzapw/awesome-omni-skill

Capture and organize business rules, technical patterns, and service interfaces discovered during analysis or implementation into structured documentation

acc-documentation-qa-knowledge

16
from diegosouzapw/awesome-omni-skill

Documentation QA knowledge base. Provides quality checklists, audit criteria, and metrics for documentation review.

acc-documentation-knowledge

16
from diegosouzapw/awesome-omni-skill

Documentation knowledge base. Provides documentation types, audiences, best practices, and antipatterns for technical documentation creation.