# Decide Builder

> When to use the fluent Builder pattern vs constructors or factories.

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

---


# Skill: Builder

> "Many options. One fluent API."

## The Decision

**Use Builder when:**
- Object requires many optional parameters
- Construction order matters
- You want a fluent, readable API
- Configuration is context-dependent

**Use Constructor/Factory when:**
- Object is simple (few required params)
- All params are mandatory
- No variation in construction

## The Heuristic

Ask: *"Do I need to configure this object in multiple ways?"*

- **Yes, many options** → Builder
- **No, fixed construction** → Constructor/Factory

## The Quick Test

| Scenario                             | Use         |
|--------------------------------------|-------------|
| 5+ optional parameters               | Builder     |
| Context-dependent defaults           | Builder     |
| Method chaining improves readability | Builder     |
| Simple, mandatory params             | Constructor |
| Single creation path                 | Factory     |

## Real-World Examples

For concrete examples from Laravel, Spatie, and production code, see [examples.md](examples.md).

