# Decide Casts

> When to use Eloquent Cast vs Accessor. Value representation decisions.

- Skill: `attac-t/decide-casts` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add attac-t/decide-casts`
- Raw SKILL.md: https://api.skillmd.com/api/skills/attac-t/decide-casts/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-casts

---


# Skill: Casts

> "Casts change storage format. Accessors change presentation."

## The Decision

**Use Cast when:**
- Value requires different storage format (int → Money)
- Transformation applies on both read AND write
- Value Object should be reusable across models

**Use Accessor when:**
- Computed from other attributes
- Read-only transformation
- Depends on model state/context

## The Heuristic

Ask: *"Does this transform how data is stored, or how it's displayed?"*

- **Storage** → Cast
- **Display** → Accessor

## The Quick Test

| Ask Yourself                 | Answer | Use      |
|------------------------------|--------|----------|
| Reusable across models?      | Yes    | Cast     |
| Needs read + write?          | Yes    | Cast     |
| Depends on other attributes? | Yes    | Accessor |
| Computed value?              | Yes    | Accessor |

## Real-World Examples

For concrete examples, see [examples.md](examples.md).

