TypeScript Type Validator skill for Claude and Codex
Generates a runtime type guard that proves an unknown value matches your interface: deep checks on every required field, optional fields handled, strict or…
Install it once and Claude or Codex runs it for you. When your request matches, your AI loads the skill, asks for anything it is missing, and works through the template itself. Prefer to fill it in by hand? See the full prompt template.
Download the skill (.zip) · View SKILL.md
When it is used
Use when data from an API, form, or file arrives as unknown and you need a type guard that checks it deeply against an existing interface at runtime. Do not use for generating the interface itself, validating with a schema library, or building a validating store. Related topics: coding, typescript.
What it will ask you for
- Interface name (free text, e.g. "OrderPayload")
- Interface definition (longer free text)
- Variable to validate (free text, e.g. "payload")
- Extra properties (choose one: Strict (reject unknown keys), Loose (ignore unknown keys))
- Include detailed errors (choose one: Yes, No)
- Export as (choose one: Named function, Default export)
How it works
- Write a helper guard per nested type that checks primitives, literals, arrays element by element, and unions variant by variant.
- Write the main guard with a type predicate return type that rejects null and non-objects first, then checks every required property.
- Validate optional properties only when present and apply the strict or loose rule for undeclared keys.
- When detailed errors are on, collect every failure as path plus message and expose them through an assert variant or error list.
- Confirm the guard compiles against the pasted interface and narrows the variable at a call site.
What you get
One typescript code block with helper guards, the main type-predicate guard, and the assert or error-list variant when requested; no prose outside it.
What it watches out for
- Returning boolean instead of a type predicate, so the caller gets no narrowing from the guard.
- Treating an optional property set to undefined as a type error, which rejects values the interface allows.
- Checking only the first element of an array, which lets a malformed item through into typed code.
How to install
Claude.ai and the Claude desktop app
- Download the skill .zip.
- Open Settings, then Capabilities, and find Skills.
- Choose Upload skill and select the .zip.
- Ask Claude for help with the task. It loads the skill when your request matches.
Claude Code
- Download the skill .zip.
- Unzip it into ~/.claude/skills/ (or .claude/skills/ inside a project).
- Start a new session. Claude Code loads the skill when your request matches.
Codex
- Download the skill .zip.
- Unzip it into ~/.agents/skills/ (or .agents/skills/ inside a project).
- Codex picks it up on its own. Type $ and the skill name to use it, or just ask for the task.
Cursor
- Download the Cursor rule (.mdc).
- Save it in .cursor/rules/ inside your project.
- Cursor's agent applies the rule when your request matches its description.
AGENTS.md (Codex, Cursor, and other coding agents)
- Copy the AGENTS.md section.
- Paste it into AGENTS.md at the root of your repository, creating the file if needed.
- Coding agents that read AGENTS.md follow it when your request fits.