Strict TypeScript
FreeTighten types at the boundary you are editing: no any, no fake optionals, names that match the runtime.
Purpose
Stop agents from papering over errors with casts.
Procedure
--- name: strict-typescript description: Tighten types at the boundary you are editing: no any, no fake optionals, names that match the runtime. ---
Strict TypeScript
Purpose
Stop agents from papering over errors with casts.
Procedure
Work in the files the task touches. Do not turn on stricter compiler flags for the whole repo unless asked.
Rules:
- Do not add any, and do not use as SomeType to silence an error you do not understand. If you narrow, show the check.
- Distinguish missing (undefined, field absent) from empty ("" or []).
- Export a type for data that crosses a function boundary. Name it after the concept, not Data or Props2.
- Prefer a union of string literals to string when the set is closed (difficulty, status).
- Do not mark a field optional to avoid filling it in. Pass the value.
- Generic helpers are not required for a single call site.
If a value comes from JSON, the type assertion is a claim. Parse it (a small function or the project's schema tool) at the edge, then trust the parsed type inside.
Do not rewrite unrelated modules to satisfy a new type. If a type error is pre-existing and outside the task, leave it and say so.
Do not add ts-ignore.
Example requests
1. Type a response
Request: Apply Strict TypeScript to the skill list response. Do not rename public fields unless they are wrong. Expected: A named type, no any, and a parser or a comment that the server is the source of the shape.
Dependencies
None. Work in the repository that is already open. Do not add packages unless the procedure names one.
Compatibility
This document follows the Agent Skills layout (a folder named strict-typescript containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it. Last verified 2026-11-15.
Example prompts
Type a response
Apply Strict TypeScript to the skill list response. Do not rename public fields unless they are wrong.
Expected: A named type, no any, and a parser or a comment that the server is the source of the shape.
Choose the agent
This skill is installed for one agent at a time. Pick the section you are using.
Related
- Schema Contracts
Validate input at the server boundary and return a stable error shape.
- Test Plan
Add the smallest test that would have caught the bug, or a checklist if the change is visual.
- Component API
Shape a React component's props around composition and a small variant set, not boolean soup.
Reviews
No reviews yet.
Sign in to review.
Report a problem
Inaccurate steps, an unsafe instruction, or a licensing concern.
Sign in to report.