From acc
Generates DDD Specifications for PHP 8.4 apps. Creates composable business rule objects using Specification pattern for validation, filtering, querying. Includes unit tests and base infrastructure.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-specificationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate DDD-compliant Specifications for encapsulating business rules and filtering logic.
Generate DDD-compliant Specifications for encapsulating business rules and filtering logic.
| Scenario | Example |
|---|---|
| Business rule validation | IsActiveCustomer, CanPlaceOrder |
| Collection filtering | OverdueInvoice, PremiumProduct |
| Repository queries | OrdersByCustomer, ActiveUsers |
| Policy enforcement | EligibleForDiscount, CanBeShipped |
| Complex conditions | Composite AND/OR specifications |
Path: src/Domain/Shared/Specification/
SpecificationInterface.php — Generic interface with isSatisfiedBy()AbstractSpecification.php — Base with AND/OR/NOT methodsAndSpecification.php — Composite ANDOrSpecification.php — Composite ORNotSpecification.php — Negation wrapperPath: src/Domain/{BoundedContext}/Specification/
{Name}Specification.php — Implements business rulePath: tests/Unit/Domain/{BoundedContext}/Specification/
| Component | Path |
|---|---|
| Base Interface | src/Domain/Shared/Specification/ |
| Abstract Spec | src/Domain/Shared/Specification/ |
| Composites | src/Domain/Shared/Specification/ |
| Concrete Specs | src/Domain/{BoundedContext}/Specification/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Specification/ |
| Pattern | Example |
|---|---|
Is{Condition}Specification | IsActiveCustomerSpecification |
Has{Property}Specification | HasPurchaseHistorySpecification |
Can{Action}Specification | CanBeCancelledSpecification |
| Factory Method | IsOverdueInvoiceSpecification::now() |
/**
* @template T
*/
interface SpecificationInterface
{
public function isSatisfiedBy(mixed $candidate): bool;
public function and(self $other): self;
public function or(self $other): self;
public function not(): self;
}
/**
* @extends AbstractSpecification<{Entity}>
*/
final readonly class {Name}Specification extends AbstractSpecification
{
public function __construct({parameters}) {}
public function isSatisfiedBy(mixed $candidate): bool
{
if (!$candidate instanceof {Entity}) {
return false;
}
return {businessRule};
}
}
$eligible = $isActive
->and($hasPurchases)
->and($isNotBlacklisted->not());
$customers = array_filter(
$all,
fn($c) => $eligible->isSatisfiedBy($c)
);
| Anti-pattern | Problem | Solution |
|---|---|---|
| God Specification | Too many conditions | Split into composable specs |
| Side Effects | Modifies candidate | Keep pure, read-only |
| Infrastructure | DB calls in spec | Keep in domain, use for in-memory |
| Weak Typing | isSatisfiedBy(mixed) | Add type check first |
| No Composition | Copy-paste conditions | Use AND/OR composition |
For complete PHP templates and examples, see:
references/templates.md — Interface, Abstract, Composite, Concrete templatesreferences/examples.md — Customer, Product, Invoice, Order specifications and testsnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accImplements Clean Architecture, Hexagonal (Ports & Adapters), and Domain-Driven Design patterns in PHP 8.3+ with Symfony 7.x. For enterprise app architecture, legacy refactoring, DDD, and testable backends.
Translates domain rules into code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.
Generates DDD-compliant aggregates for PHP 8.4 with root entity, child entities, domain events, invariant protection, and unit tests.