# Decide Dto Vs Array

> When to use DTO vs array. Type safety threshold.

- Skill: `attac-t/decide-dto-vs-array` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add attac-t/decide-dto-vs-array`
- Raw SKILL.md: https://api.skillmd.com/api/skills/attac-t/decide-dto-vs-array/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: attac-t (https://skillmd.com/u/attac-t)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/attac-t/decide-dto-vs-array

---


# Skill: DTO vs Array

> "Arrays are bags of anything. DTOs are contracts."

## The Decision

**Use Array when:**
- Quick prototyping / exploration
- Single-use, local scope
- Framework requires it (config, etc.)

**Use DTO when:**
- Data crosses boundaries (controller → action)
- Same structure appears 2+ times
- Validation needed
- IDE autocomplete matters

## The Heuristic

Ask: *"Will another developer need to know what's in this?"*

## The Quick Test

| Ask | Answer | Use |
|-----|--------|-----|
| Does it cross a class boundary? | Yes | DTO |
| Is it reused elsewhere? | Yes | DTO |
| Does it need validation? | Yes | DTO |
| Is it a quick local variable? | Yes | Array |

## Real-World Examples

See [examples.md](examples.md).

