acc-layer-arch-knowledge
Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered Architecture audits.
Best use case
acc-layer-arch-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered Architecture audits.
Teams using acc-layer-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
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-layer-arch-knowledge/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-layer-arch-knowledge Compares
| Feature / Agent | acc-layer-arch-knowledge | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered 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
# Layered Architecture Knowledge Base
Quick reference for Layered (N-Tier) Architecture patterns and PHP implementation guidelines.
## Core Principles
### Layered Architecture Overview
```
┌─────────────────────────────────────────────────────────────────┐
│ PRESENTATION LAYER │
│ (Controllers, Views, API Endpoints, CLI) │
│ │
│ Responsibilities: │
│ - Handle user input │
│ - Display output │
│ - Validate input format │
│ - Route requests │
└───────────────────────────┬─────────────────────────────────────┘
│ calls
▼
┌─────────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER │
│ (Services, Use Cases, DTOs, Facades) │
│ │
│ Responsibilities: │
│ - Orchestrate business operations │
│ - Transaction management │
│ - Coordinate domain objects │
│ - Map between layers │
└───────────────────────────┬─────────────────────────────────────┘
│ calls
▼
┌─────────────────────────────────────────────────────────────────┐
│ DOMAIN LAYER │
│ (Entities, Value Objects, Domain Services, Rules) │
│ │
│ Responsibilities: │
│ - Business logic │
│ - Business rules and invariants │
│ - Domain events │
│ - Core algorithms │
└───────────────────────────┬─────────────────────────────────────┘
│ calls
▼
┌─────────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE LAYER │
│ (Repositories, External APIs, Database, Cache) │
│ │
│ Responsibilities: │
│ - Data persistence │
│ - External service integration │
│ - Technical infrastructure │
│ - Framework-specific code │
└─────────────────────────────────────────────────────────────────┘
```
**Core Rule:** Each layer only communicates with the layer directly below it.
### Layer Communication Rules
| From Layer | Can Call | Cannot Call |
|------------|----------|-------------|
| Presentation | Application | Domain, Infrastructure |
| Application | Domain, Infrastructure | Presentation |
| Domain | Infrastructure (via interfaces) | Presentation, Application |
| Infrastructure | — | All upper layers |
## Quick Checklists
### Presentation Layer Checklist
- [ ] Controllers are thin
- [ ] No business logic
- [ ] Input validation only
- [ ] Calls application services
- [ ] Transforms output for display
- [ ] Framework code contained here
### Application Layer Checklist
- [ ] Orchestrates operations
- [ ] Transaction boundaries
- [ ] No direct DB access
- [ ] Uses domain objects
- [ ] DTOs for input/output
- [ ] No framework dependencies
### Domain Layer Checklist
- [ ] Pure business logic
- [ ] No infrastructure code
- [ ] Rich entity behavior
- [ ] Value objects for concepts
- [ ] Business rules encapsulated
- [ ] Repository interfaces only
### Infrastructure Layer Checklist
- [ ] Implements domain interfaces
- [ ] Database operations
- [ ] External API calls
- [ ] Caching logic
- [ ] No business logic
## Common Violations Quick Reference
| Violation | Where to Look | Severity |
|-----------|---------------|----------|
| Skipping layers | Controller calling DB | Critical |
| Upward dependency | Domain using Application | Critical |
| Business in Controller | if/switch in controllers | Warning |
| Anemic services | Service = simple delegation | Warning |
| Fat repository | Logic in repository | Warning |
## PHP 8.5 Layered Architecture Patterns
### Presentation Layer (Controller)
```php
<?php
declare(strict_types=1);
namespace Presentation\Api\Order;
use Application\Order\Service\OrderService;
use Application\Order\DTO\CreateOrderDTO;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
final readonly class OrderController
{
public function __construct(
private OrderService $orderService
) {}
public function create(Request $request): JsonResponse
{
$dto = CreateOrderDTO::fromRequest($request);
$result = $this->orderService->createOrder($dto);
return new JsonResponse($result->toArray(), 201);
}
public function show(string $id): JsonResponse
{
$order = $this->orderService->getOrder($id);
return new JsonResponse($order->toArray());
}
}
```
### Application Layer (Service)
```php
<?php
declare(strict_types=1);
namespace Application\Order\Service;
use Application\Order\DTO\CreateOrderDTO;
use Application\Order\DTO\OrderDTO;
use Domain\Order\Entity\Order;
use Domain\Order\Repository\OrderRepositoryInterface;
use Domain\Order\ValueObject\OrderId;
final readonly class OrderService
{
public function __construct(
private OrderRepositoryInterface $orderRepository,
private TransactionManagerInterface $transactionManager
) {}
public function createOrder(CreateOrderDTO $dto): OrderDTO
{
return $this->transactionManager->transactional(function () use ($dto) {
$order = Order::create(
id: $this->orderRepository->nextIdentity(),
customerId: $dto->customerId,
lines: $dto->lines
);
$this->orderRepository->save($order);
return OrderDTO::fromEntity($order);
});
}
public function getOrder(string $id): OrderDTO
{
$order = $this->orderRepository->findById(new OrderId($id));
if ($order === null) {
throw new OrderNotFoundException($id);
}
return OrderDTO::fromEntity($order);
}
}
```
### Domain Layer (Entity)
```php
<?php
declare(strict_types=1);
namespace Domain\Order\Entity;
use Domain\Order\ValueObject\OrderId;
use Domain\Order\ValueObject\CustomerId;
use Domain\Order\ValueObject\Money;
use Domain\Order\Enum\OrderStatus;
final class Order
{
private OrderStatus $status;
private array $lines = [];
public function __construct(
private readonly OrderId $id,
private readonly CustomerId $customerId
) {
$this->status = OrderStatus::Draft;
}
public static function create(OrderId $id, CustomerId $customerId, array $lines): self
{
$order = new self($id, $customerId);
foreach ($lines as $line) {
$order->addLine($line);
}
return $order;
}
public function confirm(): void
{
if (!$this->canBeConfirmed()) {
throw new CannotConfirmOrderException();
}
$this->status = OrderStatus::Confirmed;
}
public function total(): Money
{
return array_reduce(
$this->lines,
fn (Money $carry, OrderLine $line) => $carry->add($line->total()),
Money::zero('USD')
);
}
private function canBeConfirmed(): bool
{
return $this->status === OrderStatus::Draft && !empty($this->lines);
}
}
```
### Infrastructure Layer (Repository)
```php
<?php
declare(strict_types=1);
namespace Infrastructure\Persistence\Order;
use Domain\Order\Entity\Order;
use Domain\Order\Repository\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/layer-responsibilities.md` — Detailed layer responsibilities
- `references/layer-communication.md` — Inter-layer communication patterns
- `references/dto-patterns.md` — Data Transfer Object patterns
- `references/antipatterns.md` — Common violations with detection patternsRelated Skills
acc-psr-autoloading-knowledge
PSR-4 autoloading standard knowledge base for PHP 8.5 projects. Provides quick reference for namespace-to-path mapping, composer.json configuration, directory structure, and common mistakes. Use for autoloading audits and project structure reviews.
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.
acc-clean-arch-knowledge
Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and Hexagonal Architecture audits.
acc-claude-code-knowledge
Knowledge base for Claude Code formats and patterns. Use when creating or improving commands, agents, skills, or hooks.
acc-architecture-doc-template
Generates ARCHITECTURE.md files for PHP projects. Creates layer documentation, component descriptions, and architectural diagrams.
acc-adr-knowledge
Action-Domain-Responder pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for ADR (web-specific MVC alternative) audits.
Academic Researcher
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
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
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
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
[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
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.