# Type Safety Enforcer

> Systematically eliminate type holes (as any, !, @ts-ignore) from the codebase. Use during audits or when hard guardrails are violated. Use when this capability is needed.

- Skill: `tomevault-io/type-safety-enforcer` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/type-safety-enforcer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/type-safety-enforcer/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- 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-safety-enforcer

---


# Type-Safety Enforcer

## Instructions

1.  **Detection**:
    *   Run `grit check patternName="ban-type-assertions"` to find `as Type`, `as any`, and `!`.
    *   Run `grit check patternName="ban-ts-ignore"` to find suppression comments.
2.  **Context Analysis**: For each violation, analyze the surrounding code to determine the best remediation strategy.
3.  **Remediation**:
    *   **External Data**: Use `Schema.decodeUnknown` (Effect) to validate at the boundary.
    *   **Null Checks**: Replace `!` with proper `if (value != null)` guards or optional chaining `?.`.
    *   **Type Widening**: Replace `as any` with `unknown` and proper type narrowing.
    *   **Logic Errors**: If a cast is used to hide a bug, refactor the underlying logic.
4.  **Verification**:
    *   Run `tsc --noEmit` to ensure the codebase is clean.
    *   Verify that no new linting violations are introduced in `biome check`.

## Guardrails (CRITICAL)
- NEVER replace `as any` with another unsafe cast.
- ALWAYS prioritize runtime validation for external data.

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

