# Craft Query

> Crafting QueryBuilders. Eloquent power, not Repositories.

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

---


# Skill: Craft Query

> "Eloquent is a superpower. Don't hide it behind a Repository."

## The Standard

1. **No Repositories**: Use Custom QueryBuilders.
2. **Atomic Methods**: Composable (`->pending()->forUser($u)`).
3. **Return Self**: Always `return $this` for chaining.
4. **Descriptive Names**: `pending()`, not `wherePending()`.

## The Anti-Patterns

| ❌ Don't                  | ✅ Do                     | Why                                 |
|--------------------------|--------------------------|-------------------------------------|
| Repository pattern       | QueryBuilder             | Eloquent is already the abstraction |
| One-off scope methods    | Reusable builder methods | DRY                                 |
| `whereStatus('pending')` | `pending()`              | Semantic clarity                    |
| Update logic in builder  | Actions for mutations    | Builders query, Actions mutate      |

## Real-World Examples

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

