hexagonal-knowledge

Hexagonal architecture (ports and adapters) knowledge base. Provides patterns and anti-patterns for auditing hexagonal architecture, with PHP-specific guidance and practical advice to assess implementation of ports, adapters, and boundary separation.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "hexagonal-knowledge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-98a6076dad67b94e171d19a3a1524263dc14e198dadf925776a43ee052c98634. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Hexagonal architecture (ports and adapters) knowledge base. Provides patterns and anti-patterns for auditing hexagonal architecture, with PHP-specific guidance and practical advice to assess implementation of ports, adapters, and boundary separation.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

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

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: hexagonal-knowledge
description: Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.

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.4 Hexagonal Patterns

Driving Port (Use Case Interface)

<?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

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

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

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

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 提供六边形架构的核心模式与反模式,帮助开发者进行架构审计
  • 包含 PHP 8.4 具体实现示例,实用性强
  • 快速检查清单便于日常开发参考
Trigger Precision92/100

Highlights

  • description 清晰定义功能范围:六边形架构知识库,涵盖模式、反模式与 PHP 指南
  • 触发词精准,边界明确,不易误触
Structure and Standards95/100

Highlights

  • 文档结构清晰,分核心原则、检查清单、违规参考、代码示例
  • frontmatter 完整,包含名称与描述
  • 提供端到端 PHP 代码示例,便于理解与落地
Execution Reliability90/100

Areas to improve

  • Description in the wrong location Reported severity: Minor

    顶层 frontmatter 中 description 字段为空,实际描述内容位于 skill_body 内部的 frontmatter 中

    Recommendation: 建议将 description 内容移至顶层 frontmatter,以符合规范

Highlights

  • 作为知识库型 Skill,无外部依赖或不可逆操作,执行风险低
  • 示例代码规范,符合 PHP 8.4 语法与六边形架构最佳实践
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.