typescript-strict
Skill0 starsChanged 38 days agoMITView on GitHub
Write and review TypeScript as if strict mode plus the hardening flags (noUncheckedIndexedAccess, exactOptionalPropertyTypes) are enforced, and migrate loose codebases to full strictness flag by flag without breaking the build. Use when someone asks "how do I get rid of any", "turn on strict mode in an existing project", "is this type assertion safe", "why does tsc say possibly undefined", or when writing new TypeScript that must pass a strict compiler. Do NOT use for migrating between language or runtime versions - use language-version-migrator instead.
13 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/typescript-skillstheir own version, first seen Nov 8, 2026
- conjurer-rich/skillstheir own version, first seen Oct 25, 2026
- Greg-Klein/ai-rules-skillstheir own version, first seen Oct 15, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
- Sagargupta16/claude-code-recipestheir own version, first seen Sep 6, 2026
- ngnthanhdev/claude_template_codetheir own version, first seen Aug 20, 2026
Used with
Projects with it also use react-patterns, api-design and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
xenitV1Skillreact-patterns
Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.
Also in 3 projects that use this
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 5 projects that use this
Microsoft AzureSkillgit-workflow
Squad branching model: dev-first workflow with insiders preview channel
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 13
- Sagargupta16/claude-code-recipes★ 8same name
- 0xMassi/claude-skills★ 7same name
- kevinaimonster/skill-hub★ 4same name
- halflength-ampleness75/claude-code-recipes★ 2same name
- aprameyak/coding-skills★ 1same name
- conjurer-rich/skills★ 1same name
- microsoft/typescript-skills★ 1same name
- NaviAndrei/AgentFlow-Studio★ 1same name
- theseus-run/theseus★ 1same name
- Greg-Klein/ai-rules-skills★ 0same name
3 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- changelog-generatorSkill
- code-review-checklistSkill
- tdd-expertSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 5 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Write to the banned/required pattern lists: Every review comment and every fix should cite one of them.
- Distinctive: line 17
Prefer narrowing over asserting: When the compiler complains, the question is "how do I prove this to the compiler," not "how do I silence …
- Very specific: line 111
Delete every @ts-expect-error you can after each step.
- Very specific: line 128
Do not fix a strict error by widening a type to any or adding !
- Distinctive: line 129
Do not flip all flags at once on a large codebase.
- Distinctive: line 130
Do not allow a suppression list that can grow.
- Very specific: line 131
Do not use as to satisfy the compiler on data from outside the process - validate, then narrow.
- Very specific: line 132
Do not skip noUncheckedIndexedAccess because it is noisy.
- Distinctive: line 138
Every remaining cast sits inside a validating adapter with a reason comment.
- Very specific: line 139
Every switch over a union has a never exhaustiveness check.
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TypeScript Strict Mode
Every any is a runtime bug that the compiler was ready to catch and was told not to. Strict TypeScript converts a class of production failures - undefined access, wrong-shape API responses, unhandled union cases - into compile errors that cost seconds instead of incidents. This skill enforces strictness in new code and migrates existing loose codebases without a big-bang rewrite.
Operating procedure
- Determine the mode. Greenfield code: apply the full config and the banned/required patterns below from the first commit. Existing loose codebase: jump to the migration procedure - do not flip every flag at once, because a wall of 2,000 errors gets the whole effort reverted.
- Set the config. The target tsconfig is the artifact below.
"strict": trueis the floor, not the ceiling -noUncheckedIndexedAccessandexactOptionalPropertyTypescatch real bugs thatstrictalone misses. - Write to the banned/required pattern lists. Every review comment and every fix should cite one of them.
- Prefer narrowing over asserting. When the compiler complains, the question is "how do I prove this to the compiler," not "how do I silence it." Use the narrowing toolkit.
- Contain unavoidable casts with the escape-hatch policy. A cast is a claim the compiler cannot check; isolate it, validate it, and never let it propagate.
Inputs to collect
Before migrating or reviewing, gather: (1) the current tsconfig, (2) whether the codebase is greenfield or existing - and if existing, the error count per flag (tsc --noEmit after toggling each flag tells you), (3) any third-party libraries with missing or bad types, since those are where casts concentrate. If the error counts are unknown, measure them first; label any estimate a guess.
Target tsconfig
{
"compilerOptions": {
"strict": true, // enables all strict-family checks
"noUncheckedIndexedAccess": true, // arr[i] and obj[key] are T | undefined
"exactOptionalPropertyTypes": true, // { a?: string } rejects { a: undefined }
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true
}
}Banned patterns
any- useunknownand narrow, or define the type.as SomeTypeon values from outside the type system - use type guards or schema validation instead.value!.propertynon-null assertion - handle null/undefined explicitly.@ts-ignore- fix the error. If suppression is truly unavoidable,@ts-expect-errorwith a reason comment, which errors when the underlying problem is fixed.- Implicit
anyin function parameters.
Required patterns
- Explicit return types on exported/public functions.
unknownoveranyfor truly unknown data, then narrow.satisfiesoveraswhen checking a value against a type without widening it.- Discriminated unions over bags of optional properties.
as constassertions for literal types.- Exhaustive switches with a
nevercheck in the default case.
Good/bad pairs
Bad - any erases checking downstream:
function parse(json: string): any { return JSON.parse(json) }
const user = parse(body); user.emial // typo compiles, crashes laterGood - unknown forces proof before use:
function parse(json: string): unknown { return JSON.parse(json) }
const data = parse(body)
if (isUser(data)) { data.email } // typo is a compile errorBad - assertion claims without evidence:
const user = JSON.parse(body) as User // wrong shape crashes at runtimeGood - narrowing proves the shape:
function isUser(x: unknown): x is User {
return typeof x === 'object' && x !== null && 'id' in x && 'email' in x
}Good - exhaustive switch that breaks the build when a variant is added:
function handle(action: Action) {
switch (action.type) {
case 'A': return handleA(action)
case 'B': return handleB(action)
default: { const _exhaustive: never = action; throw new Error('unreachable') }
}
}Migration procedure for a loose codebase
Order matters: each flag builds on the previous one's guarantees, and the noisiest flags come last so early wins build momentum.
- Ban new violations first: turn on the target flags in CI for new and changed files only (lint rule or a diff-based check), so the hole stops getting deeper while you drain it.
- Enable
noImplicitAny. Fix by adding real types, not: any. This is the highest-value flag per error fixed. - Enable
strictNullChecks(withstrictFunctionTypesandalwaysStrict). Usually the largest error count. If a flag produces more errors than the team can fix in about two weeks, scope it per-directory with project references or a second tsconfig, and ratchet the boundary weekly - never let an "errors allowed" list grow. - Enable the remainder of the strict family (
strictBindCallApply,strictPropertyInitialization,useUnknownInCatchVariables), then replace the individual flags with"strict": true. - Enable
noUncheckedIndexedAccess, thenexactOptionalPropertyTypes. These are last because they are the noisiest and the fixes (index checks,undefined-vs-absent distinctions) are mechanical once the codebase is null-safe. - Delete every
@ts-expect-erroryou can after each step; each one still standing needs a reason comment.
Escape-hatch policy
A cast is acceptable only at a boundary the type system cannot see across: deserialized JSON, a third-party library with wrong types, a test fixture. Contain it:
- One cast per boundary, inside a single adapter function that validates before asserting (type guard or schema check). Callers receive a real type and never see the cast.
- Comment every cast with the reason it is safe.
as unknown as Tdouble assertions only in test code, never in production paths.@ts-expect-errorover@ts-ignore, always with a description.
Deliverable
Produce strict-compliant code plus, for migrations, a flag-by-flag plan: current error count per flag, the enablement order above, the per-directory scoping if any count exceeds the two-week budget, and the CI ratchet that blocks new violations immediately.
Do NOT
- Do not fix a strict error by widening a type to
anyor adding!- that converts a found bug back into a hidden one. - Do not flip all flags at once on a large codebase; the resulting error wall gets the migration reverted.
- Do not allow a suppression list that can grow; ratchets only tighten.
- Do not use
asto satisfy the compiler on data from outside the process - validate, then narrow. - Do not skip
noUncheckedIndexedAccessbecause it is noisy; unchecked index access is the single most common strict-mode blind spot.
Quality bar
tsc --noEmitpasses with the target config (or the migration plan states exactly which flags are pending and their error counts).- Zero
any, zero@ts-ignore, zero bare non-null assertions in the changed code. - Every remaining cast sits inside a validating adapter with a reason comment.
- Every switch over a union has a
neverexhaustiveness check. - Public functions declare their return types.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

