Automated summary
This skill sets out the structure, lifecycle, and transformation rules for DTOs in a PHP application so they stay simple, transport-safe data contracts.
Strengths
- Gives explicit, checkable rules: no business logic, no validation, no framework dependencies inside DTOs
- Enforces a single dependency direction (Model/Array → Transformer → DTO → Service), preventing circular coupling
- Provides clear criteria for when a DTO is required versus when it can be skipped (validated FormRequest, short-lived data)
- Ships a complete PHP example with fluent getters/setters and optional IDE region markers
Limitations
- Strongly PHP/Laravel-oriented (Eloquent, FormRequest), so the examples do not map directly to other languages
- The 'POPO with fluent setters' style is a team preference, not a universal standard; immutable or read-only DTOs are not covered
- Does not address nested DTOs, DTO collections, or serialization concerns
Use it when designing or reviewing a PHP DTO layer and you want consistent structure and transformation rules enforced.
Skip it if the project does not use DTOs (e.g. immutable value objects or plain arrays) or if the stack is not PHP/Laravel.
Security analysis
SafeThe skill is purely declarative documentation about DTO design patterns and contains no executable instructions, shell commands, network calls, or data exfiltration risks. It only provides PHP code examples as reference material.
No concerns found
How this analysis is madeExamples
Create an InvoiceDto following our DTO contract (private properties, fluent getters and setters, no validation or ORM logic) and an InvoiceTransformer with fromModel and fromArray methods that fill it.Here is a service method that passes a $data array across three services. Per our DTO contract, should this become a DTO? If yes, sketch the DTO and the transformer.Review this InvoiceDto against the DTO contract and flag any business logic, validation rules, or framework dependencies that should be moved into a transformer or service.name: dto-contract description: Defines DTO structure, lifecycle, and transformation rules across the application license: MIT metadata: author: project
DTO Contracts
DTOs define structured, transport-safe data contracts used between layers of the application.
They exist to replace unstructured arrays when data shape matters, is reused, or must remain consistent across boundaries.
1. Responsibility
DTOs MUST:
- represent structured application data
- act as transport carriers between layers
- be filled by Transformers
- avoid business logic
- avoid persistence logic
DTOs MUST NOT:
- contain ORM logic
- contain validation rules
- contain side effects
- depend on framework components (
Request, Eloquent models, etc.)
2. Structure
DTOs are simple POPOs with fluent getters and setters.
Example:
class InvoiceDto
{
private int $invoiceId;
private int $companyId;
private float $amount;
public function getInvoiceId(): int
{
return $this->invoiceId;
}
public function setInvoiceId(int $invoiceId): self
{
$this->invoiceId = $invoiceId;
return $this;
}
public function getCompanyId(): int
{
return $this->companyId;
}
public function setCompanyId(int $companyId): self
{
$this->companyId = $companyId;
return $this;
}
public function getAmount(): float
{
return $this->amount;
}
public function setAmount(float $amount): self
{
$this->amount = $amount;
return $this;
}
}
3. Creation Rule
DTOs MUST be created via Transformers.
$dto = InvoiceTransformer::fromModel($invoice);
or
$dto = InvoiceTransformer::fromArray($data);
DTOs MUST NOT be manually assembled inside services unless trivial and explicitly justified.
4. Transformer Dependency Rule
Transformers are the ONLY layer allowed to construct DTOs.
DTOs MUST NOT depend on Transformers.
Direction is strictly:
Model / Array → Transformer → DTO → Service
5. When DTOs are Required
Use DTOs when:
- data is shared across multiple services
- structure must remain stable across changes
- transformation logic exists (model → structured output)
- array shape would otherwise be ambiguous or inconsistent
6. When DTOs are NOT Required
DTOs MAY be skipped when:
- data is short-lived within a single method
- input comes from a validated
FormRequest - structure is trivial and not reused elsewhere
7. Core Principle
DTOs are explicit data contracts, not business logic containers.
IDE Hints (Optional)
DTOs MAY include region markers to improve IDE navigation (e.g. PhpStorm folding).
These are purely cosmetic and MUST NOT affect runtime behavior or architecture decisions.
Example:
class InvoiceDto
{
#region Properties
private int $invoiceId;
private int $companyId;
private float $amount;
#endregion
#region Getters
public function getInvoiceId(): int { ... }
public function getCompanyId(): int { ... }
public function getAmount(): float { ... }
#endregion
#region Setters
public function setInvoiceId(int $invoiceId): self { ... }
public function setCompanyId(int $companyId): self { ... }
public function setAmount(float $amount): self { ... }
#endregion
}
They exist to stabilize data shape across the system, not to introduce unnecessary abstraction.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/dto-contracts-mrx3xznh/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/dto-contracts-mrx3xznh' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/dto-contracts-mrx3xznh/download' --output '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md.part' && mv '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md.part' '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && test -s '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/dto-contract' && cp -R '.skill-downloads/dto-contracts-mrx3xznh' '.claude/skills/dto-contract'Cursor
test -f '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && test -s '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/dto-contract' && cp -R '.skill-downloads/dto-contracts-mrx3xznh' '.cursor/skills/dto-contract'Codex
test -f '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && test -s '.skill-downloads/dto-contracts-mrx3xznh/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/dto-contract' && cp -R '.skill-downloads/dto-contracts-mrx3xznh' '.agents/skills/dto-contract'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/dto-contracts-mrx3xznh'openskills read 'dto-contracts-mrx3xznh'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/dto-contracts-mrx3xznh/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.