acc-clean-arch-knowledge

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

16 stars

Best use case

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

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

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

Manual Installation

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

How acc-clean-arch-knowledge Compares

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

Frequently Asked Questions

What does this skill do?

Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and 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

# 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.5 Clean Architecture Patterns

### Port (Driven Port)

```php
// 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)

```php
// 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)

```php
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)

```php
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

Related Skills

acc-claude-code-knowledge

16
from diegosouzapw/awesome-omni-skill

Knowledge base for Claude Code formats and patterns. Use when creating or improving commands, agents, skills, or hooks.

acc-architecture-doc-template

16
from diegosouzapw/awesome-omni-skill

Generates ARCHITECTURE.md files for PHP projects. Creates layer documentation, component descriptions, and architectural diagrams.

acc-adr-knowledge

16
from diegosouzapw/awesome-omni-skill

Action-Domain-Responder pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for ADR (web-specific MVC alternative) audits.

Academic Researcher

16
from diegosouzapw/awesome-omni-skill

Academic paper search across 14+ scholarly platforms including arXiv, PubMed, Google Scholar, Web of Science, Semantic Scholar, Sci-Hub, and more. Use for literature review, research discovery, and citation management.

academic-research

16
from diegosouzapw/awesome-omni-skill

Create comprehensive academic research notes with deep literature coverage. Auto-detects language (EN prompt→EN output, TR prompt→TR output). Supports Obsidian markdown and PDF. Performs 8-15 iterative search cycles with 25-50+ sources for comprehensive coverage. Uses footnote citations and visual overviews.

academic-research-writer

16
from diegosouzapw/awesome-omni-skill

Write academic research documents following academic guidelines with peer-reviewed sources from Google Scholar and other academic databases. Always verify source credibility and generate IEEE standard references. Use for research papers, literature reviews, technical reports, theses, dissertations, conference papers, and academic proposals requiring proper citations and scholarly rigor.

academic-deep-research

16
from diegosouzapw/awesome-omni-skill

Transparent, rigorous research with full methodology — not a black-box API wrapper. Conducts exhaustive investigation through mandated 2-cycle research per theme, APA 7th citations, evidence hierarchy, and 3 user checkpoints. Self-contained using native OpenClaw tools (web_search, web_fetch, sessions_spawn). Use for literature reviews, competitive intelligence, or any research requiring academic rigor and reproducibility.

21-understand-research-150

16
from diegosouzapw/awesome-omni-skill

[21] UNDERSTAND. Deep research workflow for this project using 150% scope (100% core + 50% boundary), evidence-based reasoning, and structured investigation notes. Use when the task requires investigation, root-cause analysis, or mapping unknown areas. Always maintain a research log file that captures findings, hypotheses, and next branches; use web.run when external verification is needed.

1k-architecture

16
from diegosouzapw/awesome-omni-skill

OneKey monorepo architecture and code organization. Use when understanding project structure, package relationships, import rules, or component organization. Triggers on architecture, structure, packages, imports, hierarchy, dependencies, monorepo, organization.

ui-architect

16
from diegosouzapw/awesome-omni-skill

Design component architecture for legaltech UIs - layer separation, data flow, design system selection

microservices-architecture

16
from diegosouzapw/awesome-omni-skill

Microservices architecture patterns and best practices. Use when designing distributed systems, breaking down monoliths, or implementing service communication.

latex-research-posters

16
from diegosouzapw/awesome-omni-skill

Create professional research posters in LaTeX using beamerposter, tikzposter, or baposter. Layout design, typography, color schemes, figure integration, accessibility, and quality control for conference presentations. Includes ready-to-use templates. For programmatic figure generation use matplotlib-scientific-plotting or plotly-interactive-visualization.