acc-cqrs-knowledge

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

16 stars

Best use case

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

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

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

Manual Installation

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

How acc-cqrs-knowledge Compares

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

Frequently Asked Questions

What does this skill do?

CQRS architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Command Query Responsibility Segregation 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

# CQRS Knowledge Base

Quick reference for CQRS architecture patterns and PHP implementation guidelines.

## Core Principles

### Separation of Concerns

```
┌─────────────────────────────────────────────────────────────┐
│                      APPLICATION                            │
├─────────────────────────────────────────────────────────────┤
│   WRITE SIDE (Commands)     │     READ SIDE (Queries)       │
├─────────────────────────────┼───────────────────────────────┤
│ Command → Handler → Domain  │  Query → Handler → ReadModel  │
│ Changes state               │  Returns data, no side effects│
│ Uses Domain Model           │  Can bypass Domain Model      │
│ Single aggregate per cmd    │  Can join multiple sources    │
└─────────────────────────────┴───────────────────────────────┘
```

**Rule:** Commands WRITE, Queries READ. Never mix.

### CQRS Components

| Component | Purpose | Returns | Side Effects |
|-----------|---------|---------|--------------|
| **Command** | Request to change state | void or ID | Yes |
| **CommandHandler** | Executes command logic | void or ID | Yes |
| **Query** | Request for data | Data DTO | No |
| **QueryHandler** | Fetches and transforms data | Data DTO | No |
| **CommandBus** | Routes commands to handlers | Depends | N/A |
| **QueryBus** | Routes queries to handlers | Query result | N/A |

## Quick Checklists

### Command Checklist

- [ ] Named as imperative verb + noun (CreateOrder, ConfirmPayment)
- [ ] Immutable (readonly class)
- [ ] Contains only data needed for operation
- [ ] Returns void or created ID (never entities)
- [ ] One command = one aggregate affected
- [ ] Validated before dispatch

### Query Checklist

- [ ] Named as Get/Find/List + noun (GetOrderDetails, ListCustomers)
- [ ] Immutable (readonly class)
- [ ] Contains filtering/pagination params
- [ ] Handler has NO side effects
- [ ] Can use optimized read models
- [ ] Returns DTOs, not entities

### Handler Checklist

- [ ] Single `execute()` or `__invoke()` method
- [ ] One handler per command/query
- [ ] CommandHandler can dispatch domain events
- [ ] QueryHandler never dispatches events
- [ ] No cross-aggregate transactions in single handler

## Common Violations Quick Reference

| Violation | Where to Look | Severity |
|-----------|---------------|----------|
| Query with side effects | QueryHandler calling save() | Critical |
| Command returning data | CommandHandler returning entity | Critical |
| Mixed read/write in handler | Handler with both get and save | Critical |
| Business logic in handler | if/switch on domain state | Warning |
| Missing command validation | Command without invariants | Warning |
| Query using write DB | QueryHandler using EntityManager | Info |

## PHP 8.5 CQRS Patterns

### Command

```php
final readonly class CreateOrderCommand
{
    public function __construct(
        public CustomerId $customerId,
        /** @var array<OrderLineData> */
        public array $lines,
        public ?string $notes = null
    ) {
        if (empty($lines)) {
            throw new InvalidArgumentException('Order must have at least one line');
        }
    }
}
```

### Command Handler

```php
final readonly class CreateOrderHandler
{
    public function __construct(
        private OrderRepositoryInterface $orders,
        private EventDispatcherInterface $events
    ) {}

    public function __invoke(CreateOrderCommand $command): OrderId
    {
        $order = Order::create(
            id: OrderId::generate(),
            customerId: $command->customerId,
            lines: $command->lines
        );

        $this->orders->save($order);

        foreach ($order->releaseEvents() as $event) {
            $this->events->dispatch($event);
        }

        return $order->id();
    }
}
```

### Query

```php
final readonly class GetOrderDetailsQuery
{
    public function __construct(
        public OrderId $orderId
    ) {}
}
```

### Query Handler

```php
final readonly class GetOrderDetailsHandler
{
    public function __construct(
        private OrderReadModelInterface $readModel
    ) {}

    public function __invoke(GetOrderDetailsQuery $query): ?OrderDetailsDTO
    {
        return $this->readModel->findById($query->orderId);
    }
}
```

## References

For detailed information, load these reference files:

- `references/command-patterns.md` — Command structure, naming, validation
- `references/query-patterns.md` — Query structure, read models
- `references/handler-patterns.md` — Handler patterns, async/sync
- `references/bus-patterns.md` — Command/Query bus implementations
- `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-hexagonal-knowledge

16
from diegosouzapw/awesome-omni-skill

Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture 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.