From acc
Generates immutable DTO classes for PHP 8.4 apps, including request/response objects for API boundaries, layer-specific data transfer, serialization methods, and unit tests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-dtoThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate DTOs for transferring data between layers, API boundaries, and external systems.
Generate DTOs for transferring data between layers, API boundaries, and external systems.
| Type | Purpose | Location |
|---|---|---|
| Request DTO | API input validation | Presentation layer |
| Response DTO | API output formatting | Presentation layer |
| Command DTO | Use case input | Application layer |
| Query Result DTO | Read model output | Application layer |
| Integration DTO | External API data | Infrastructure layer |
Determine the purpose and layer for the DTO.
Path based on type:
src/Presentation/Api/{Context}/Request/src/Presentation/Api/{Context}/Response/src/Application/{Context}/DTO/src/Infrastructure/ExternalApi/{Service}/DTO/fromArray() — Create from raw datafromEntity() — Create from domain entity (Response DTOs)toArray() / jsonSerialize() — Serialize for outputPath: tests/Unit/{Layer}/{Context}/{Type}/
| Type | Path |
|---|---|
| Request DTO | src/Presentation/Api/{Context}/Request/ |
| Response DTO | src/Presentation/Api/{Context}/Response/ |
| Application DTO | src/Application/{Context}/DTO/ |
| Integration DTO | src/Infrastructure/ExternalApi/{Service}/DTO/ |
| Unit Tests | tests/Unit/{Layer}/{Context}/{Type}/ |
| Type | Pattern | Example |
|---|---|---|
| Request | {Action}{Entity}Request | CreateOrderRequest, UpdateUserRequest |
| Response | {Entity}Response | OrderResponse, UserResponse |
| Collection | {Entity}CollectionResponse | OrderCollectionResponse |
| Application | {Entity}DTO | UserDTO, OrderDTO |
| Integration | {Service}{Action}Response | PaymentGatewayResponse |
final readonly class {Name}Request
{
public function __construct(
#[Assert\NotBlank]
public string $field,
#[Assert\Valid]
public ?NestedRequest $nested = null
) {}
public static function fromArray(array $data): self;
}
final readonly class {Name}Response implements \JsonSerializable
{
public function __construct(
public string $id,
public string $name,
/** @var array<ItemResponse> */
public array $items = []
) {}
public static function fromEntity({Entity} $entity): self;
public function jsonSerialize(): array;
}
final readonly class {Name}DTO
{
public function __construct(
public string $id,
public string $field
) {}
public static function fromRequest({Name}Request $request): self;
public function toArray(): array;
}
| Anti-pattern | Problem | Solution |
|---|---|---|
| Business Logic | DTO with calculations | Keep DTOs data-only |
| Mutable DTO | setters, state changes | Use readonly, immutable |
| Domain Objects | Returning entities from API | Map to Response DTO |
| Anemic Validation | No input validation | Use Assert attributes |
| Deep Nesting | Complex nested DTOs | Flatten or split |
| Missing Serialization | No JSON support | Implement JsonSerializable |
For complete PHP templates and examples, see:
references/templates.md — Request, Response, Application, Collection, Integration DTO templatesreferences/examples.md — Order, User, Payment examples and testsnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accCreates DTO (Data Transfer Object) classes for entities in Spring Boot projects. Supports Java classes, records, Lombok, and Kotlin data classes with attribute selection and optional mapper delegation.
Designs Value Objects for domain concepts and DTOs for data transfer with readonly immutability and validation in Symfony projects.
Builds PHP 8.3+ applications with Laravel/Symfony, strict typing, PHPStan level 9, and PSR standards. Creates typed DTOs, controllers, migrations, tests, and REST/GraphQL APIs.