# Craft Model

> Crafting the Eloquent model. Source of truth.

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

---


# Skill: Craft Model

> "The Model is the heart. Everything else is plumbing."

## The Standard

1. **$dataClass**: Define the DTO representation.
2. **Casts**: Enums, Value Objects, dates. Never raw strings for state.
3. **Relationships**: Define all. Use `ofMany` for latest/oldest.
4. **Custom Builder**: Register via `newEloquentBuilder()`.
5. **Custom Collection**: Register via `newCollection()`.

## The Anti-Patterns

| ❌ Don't           | ✅ Do                                 | Why                      |
|-------------------|--------------------------------------|--------------------------|
| No $dataClass     | Define `protected string $dataClass` | Type-safe representation |
| String status     | Enum cast                            | Type safety              |
| Scopes in Model   | Custom QueryBuilder                  | Separation               |
| Fat Model methods | Actions for logic                    | Single responsibility    |

## Real-World Examples

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

