# Type Level Architect

> Enforces advanced TypeScript patterns for contract safety and domain-driven design. Use when this capability is needed.

- Skill: `tomevault-io/type-level-architect` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/type-level-architect`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/type-level-architect/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/type-level-architect

---


# Type-Level Architect

Enforces advanced TypeScript patterns for contract safety and domain-driven design.

## Instructions

### 1. Branded Types (Domain Integrity)
- Use branded types for all domain IDs (e.g., `CorpusId`, `LayoutId`) to prevent illegal mixing of primitive strings/numbers.
- Example: `type CorpusId = string & { readonly __brand: 'CorpusId' }`.

### 2. Contract-Safe DTOs
- Use `Pick<T, K>` and `Omit<T, K>` to derive DTOs from domain models.
- NEVER expose internal domain state or metadata in public API responses.
- Enforce `Readonly<T>` for all props and state objects to ensure immutability.

### 3. Exhaustive Handling
- Use the `never` type to ensure exhaustive pattern matching in `switch` statements or conditional types.
- Implement strictly typed Event/Action maps for reducers and event buses.

### 4. Utility Leverage
- Use `Required<T>` and `NonNullable<T>` for validated data paths.
- Leverage template literal types for string-pattern validation (e.g., color hex codes, version strings).

## Verification
- Run `tsc --noEmit` to verify type integrity.
- Ensure zero usage of `any` or `unsafe` casts in domain logic.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/infodungeon) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

