# Craft Context

> Crafting Context Objects. Parameter encapsulation for complex operations.

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

---


# Skill: Craft Context

> "When an action needs too many parameters, the parameters become the object."

## The Standard

1. **Private Constructor**: Direct instantiation blocked. Forces use of named factories.
2. **Named Factories**: `::forProvider()`, `::forBatch()`. Intent in the name.
3. **Self-Validating**: Validate in constructor. Invalid context throws immediately.
4. **Immutable**: `readonly class`. Set once, read many. No setters.

## The Anti-Patterns

| ❌ Don't                     | ✅ Do                          | Why                           |
|-----------------------------|-------------------------------|-------------------------------|
| 5+ action parameters        | Context object                | Clarity, maintainability      |
| Generic constructor         | Named constructors            | Intent is explicit            |
| Mutable context             | Immutable properties          | Prevents bugs in long chains  |
| Array of options            | Typed properties              | IDE support, validation       |

## Real-World Examples

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

