Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Forge Typescript Strict?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-forge-typescript-strict)
---
name: forge-typescript-strict
description: Write and refactor TypeScript under strict compiler settings without escape hatches
---
<!-- Generated from catalog/skills/typescript-strict/SKILL.md by scripts/build-plugin.ts. Edit the catalog, not this file. -->
# TypeScript under strict mode
Use when writing or changing TypeScript, or when type errors block a change.
## Ground rules
- Read `tsconfig.json` first. Respect `strict`, `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` if they are on; never turn them off to make an error go away.
- No new `any`, `as unknown as T`, non-null `!` on values you have not checked, or `// @ts-ignore`. If you truly need an escape hatch, use `// @ts-expect-error <reason>` so it fails when it is no longer needed.
- Model data at the boundary: parse unknown input (`JSON.parse`, request bodies, env vars, files) with a schema (zod, valibot) or a hand-written type guard, then work with the narrowed type.
## Patterns that keep types honest
- **Discriminated unions** for state: `{ status: "ok"; value: T } | { status: "error"; error: E }`. Switch on the tag and add `const _exhaustive: never = state` in the default branch.
- **`satisfies`** to check an object literal against a type without widening it: `const routes = {...} satisfies Record<string, Route>`.
- **Branded IDs** when two strings must not be mixed: `type UserId = string & { readonly __brand: "UserId" }`.
- **`readonly`** arrays and properties for data you do not mutate.
- **Index access**: with `noUncheckedIndexedAccess`, `arr[0]` is `T | undefined`. Handle it (`const first = arr[0]; if (!first) return;`) instead of asserting.
- **Optional vs undefined**: with `exactOptionalPropertyTypes`, `{ a?: string }` cannot be assigned `{ a: undefined }`. Build objects with conditional spreads: `{ ...(a ? { a } : {}) }`.
- Prefer `unknown` in `catch (error)` and narrow with `error instanceof Error`.
## Verify
1. `npx tsc --noEmit -p tsconfig.json` (or the project's `typecheck` script) with zero new errors.
2. Search your diff for `any`, ` as `, `!.`, `@ts-ignore` and justify each remaining one.
3. Run the tests that cover the changed module.