# Ground Type Safety

> Type safety philosophy. Catch bugs at write time, not run time.

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

---


# Skill: Type Safety

> "Strong type systems allow developers to have much more insight into the program when writing the code, instead of having to run it."

## The Standard

- **Types Are Documentation**: A signature tells you what's expected.
- **Fail at Compile Time**: PHP 8+ gives us tools. Use them.
- **DTOs Over Arrays**: Named fields over string keys.
- **IDE as Partner**: If your IDE can't autocomplete, neither can your brain.

## The Check

Ask yourself:
- Can my IDE autocomplete this?
- Would a typo in a key cause a runtime error?
- Does the function signature tell me what it expects?
- Am I relying on documentation that might be stale?

## The Protocol

1. **Type Everything**: Return types, parameters, properties.
2. **Avoid Mixed**: If you write `mixed`, you've given up.
3. **Strict Mode**: `declare(strict_types=1);` in every file.
4. **Static Analysis**: Run PHPStan/Psalm. Trust the warnings.

## Real-World Examples

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

