clean-arch-knowledge

A Clean Architecture knowledge base providing audit patterns, common anti-patterns, and PHP-specific guidance for Clean and Hexagonal Architecture to support architecture assessment and improvements.

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 "clean-arch-knowledge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-fc044a75b3b825bf48d968b6acf37a2f753ba8400690082021b470ee7ac4287b. 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

A Clean Architecture knowledge base providing audit patterns, common anti-patterns, and PHP-specific guidance for Clean and Hexagonal Architecture to support architecture assessment and improvements.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and Hexagonal Architecture audits.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: clean-arch-knowledge
description: Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and Hexagonal Architecture audits.

Clean Architecture Knowledge Base

Quick reference for Clean Architecture / Hexagonal Architecture patterns and PHP implementation guidelines.

Core Principles

The Dependency Rule

┌────────────────────────────────────────────────────────────────┐
│                    FRAMEWORKS & DRIVERS                        │
│  (Web, UI, DB, External Services, Devices)                     │
├────────────────────────────────────────────────────────────────┤
│                    INTERFACE ADAPTERS                          │
│  (Controllers, Gateways, Presenters, Repositories)             │
├────────────────────────────────────────────────────────────────┤
│                    APPLICATION BUSINESS RULES                  │
│  (Use Cases, Application Services)                             │
├────────────────────────────────────────────────────────────────┤
│                    ENTERPRISE BUSINESS RULES                   │
│  (Entities, Value Objects, Domain Services)                    │
└────────────────────────────────────────────────────────────────┘
                              ▲
                              │
              Dependencies point INWARD only

Rule: Source code dependencies must point INWARD. Inner layers know nothing about outer layers.

Hexagonal Architecture (Ports & Adapters)

                    ┌─────────────────┐
                    │   Primary       │
                    │   Adapters      │
                    │  (Controllers)  │
                    └────────┬────────┘
                             │
                             ▼
                    ┌─────────────────┐
        ┌──────────►│     PORTS       │◄──────────┐
        │           │  (Interfaces)   │           │
        │           └────────┬────────┘           │
        │                    │                    │
        │                    ▼                    │
        │           ┌─────────────────┐           │
        │           │   APPLICATION   │           │
        │           │    (Use Cases)  │           │
        │           └────────┬────────┘           │
        │                    │                    │
        │                    ▼                    │
        │           ┌─────────────────┐           │
        │           │     DOMAIN      │           │
        │           │   (Entities)    │           │
        │           └─────────────────┘           │
        │                                         │
        │           ┌─────────────────┐           │
        └───────────│   Secondary     │───────────┘
                    │   Adapters      │
                    │ (Repositories,  │
                    │  External APIs) │
                    └─────────────────┘

Rule: Application core defines Ports (interfaces). Adapters implement them.

Quick Checklists

Domain Layer Checklist

  • [ ] No imports from outer layers
  • [ ] No framework dependencies
  • [ ] Pure business logic
  • [ ] Value Objects for concepts
  • [ ] Entities with behavior
  • [ ] Repository interfaces only

Application Layer Checklist

  • [ ] Use Cases orchestrate domain
  • [ ] Defines Ports (interfaces) for external services
  • [ ] DTOs for input/output
  • [ ] No infrastructure details
  • [ ] No framework dependencies

Interface Adapters Checklist

  • [ ] Implements domain/application interfaces
  • [ ] Controllers call Use Cases
  • [ ] Presenters format output
  • [ ] No business logic

Frameworks & Drivers Checklist

  • [ ] Configuration only
  • [ ] Wiring/DI setup
  • [ ] Framework-specific code isolated

Common Violations Quick Reference

Violation Where to Look Severity
Inner layer imports outer Domain/Application importing Infrastructure Critical
Framework in core Doctrine/Symfony in Domain Critical
Use Case with HTTP details Request/Response in Application Critical
Business logic in Controller if/switch on domain state Warning
Missing Port Direct external service call Warning
Adapter with logic Repository doing validation Warning

PHP 8.4 Clean Architecture Patterns

Port (Driven Port)

// Application layer - defines the contract
namespace Application\Order\Port;

interface PaymentGatewayInterface
{
    public function charge(PaymentRequest $request): PaymentResponse;
    public function refund(string $transactionId, Money $amount): RefundResponse;
}

Adapter (Driven Adapter)

// Infrastructure layer - implements the contract
namespace Infrastructure\Payment;

final readonly class StripePaymentGateway implements PaymentGatewayInterface
{
    public function __construct(
        private StripeClient $stripe
    ) {}

    public function charge(PaymentRequest $request): PaymentResponse
    {
        $charge = $this->stripe->charges->create([
            'amount' => $request->amount->cents(),
            'currency' => $request->currency->value,
            'source' => $request->token,
        ]);

        return new PaymentResponse(
            transactionId: $charge->id,
            status: PaymentStatus::from($charge->status)
        );
    }
}

Use Case (Application Service)

namespace Application\Order\UseCase;

final readonly class ProcessPaymentUseCase
{
    public function __construct(
        private OrderRepositoryInterface $orders,
        private PaymentGatewayInterface $paymentGateway,  // Port
        private EventDispatcherInterface $events
    ) {}

    public function execute(ProcessPaymentCommand $command): PaymentResult
    {
        $order = $this->orders->findById($command->orderId);

        $payment = $this->paymentGateway->charge(
            new PaymentRequest($order->total(), $command->paymentToken)
        );

        if ($payment->isSuccessful()) {
            $order->markAsPaid($payment->transactionId());
            $this->orders->save($order);
        }

        return new PaymentResult($payment->transactionId(), $payment->status());
    }
}

Controller (Driving Adapter)

namespace Presentation\Api\Order;

final readonly class PaymentController
{
    public function __construct(
        private ProcessPaymentUseCase $processPayment
    ) {}

    public function process(Request $request): JsonResponse
    {
        $command = new ProcessPaymentCommand(
            orderId: new OrderId($request->get('order_id')),
            paymentToken: $request->get('payment_token')
        );

        $result = $this->processPayment->execute($command);

        return new JsonResponse([
            'transaction_id' => $result->transactionId,
            'status' => $result->status->value,
        ]);
    }
}

References

For detailed information, load these reference files:

  • references/dependency-rule.md — The Dependency Rule explained
  • references/layer-boundaries.md — Layer responsibilities and boundaries
  • references/port-adapter-patterns.md — Hexagonal Architecture patterns
  • 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

  • 提供 Clean Architecture 和 Hexagonal Architecture 的核心原则与依赖规则图解
  • 包含 Domain/Application/Interface Adapters/Frameworks 四层检查清单,实用性强
  • PHP 8.4 代码示例覆盖 Port、Adapter、Use Case、Controller 完整实现
Trigger Precision92/100

Highlights

  • description 清晰定义 Skill 为架构知识库,触发边界明确
  • 涵盖模式、反模式、PHP 指南三大核心功能,无歧义
Structure and Standards75/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档未明确说明适用场景和使用时机

    Recommendation: 建议添加 When to Use 章节,说明何时使用此知识库进行架构审计

  • 缺少端到端完整示例 Reported severity: Minor

    虽有代码片段,但缺乏一个完整业务场景的端到端实现示例

    Recommendation: 建议补充一个完整用例(如订单支付流程)的端到端代码示例

Highlights

  • 文档结构清晰,分 Core Principles、Checklists、Violations、PHP Patterns 等逻辑章节
  • frontmatter 完整,包含 name 和 description
  • 使用 Mermaid 风格图示说明依赖规则和六边形架构
Execution Reliability88/100

Highlights

  • 知识库内容基于 Clean Architecture 经典理论,信息可靠
  • PHP 示例使用现代语法(readonly class, constructor property promotion)
  • Common Violations 表格提供快速检测参考,实用性强
Evidence Verifiability (mean of the first four)83/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.