typescript
Skill1 starsChanged 4 months agoMITView on GitHub
TypeScript-specific expertise — strict-mode compiler settings and why each one catches real bugs, the boundary rule that types are erased at runtime (so parsed JSON, env vars, and request bodies must be validated with a schema and the type derived from it), disciplined use of the three escape hatches (`any`, `as`, `!`) with `unknown` + narrowing as the default, modeling with discriminated unions and literal types instead of boolean/optional soup, generics only where a real input↔output relationship exists, and `catch (e: unknown)` error handling. Use when a `tsconfig.json` exists, when authoring or reviewing `.ts`/`.tsx` files, when a type error needs diagnosing, or when asked directly (Thai or English) to เขียนหรือตรวจ TypeScript ให้ type ปลอดภัยและไม่ใช้ any. Not a replacement for react's component rules or nodejs's runtime rules — this is the language/typing layer that applies across every layer of the stack.
- Reads credentials
33 other projects use a version of this.
Adopted by
Most recently taken up by
- Quad4-Software/skillstheir own version, first seen Oct 3, 2026
- lobehub/lobehubtheir own version, first seen Oct 1, 2026
- jscraik/Agent-Skillstheir own version, first seen Sep 27, 2026
- wolzey/agent-factorytheir own version, first seen Sep 23, 2026
- microsoft/scopetheir own version, first seen Sep 23, 2026
- AvilaCarlosDev/openclaw-skillstheir own version, first seen Sep 19, 2026
Used with
Projects with it also use python, security and 1 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.
rogue-dev-studioSkillpython
Python 3.13 with uv package manager via mise. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `python` work when listed in TEAM.yaml or explicitly requested.
Also in 9 projects that use this
0xSeroSkillsecurity
Also in 4 projects that use this
BlockSkilldebugging
Debugging guidelines and best practices
Also in 3 projects that use this
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 33
- lobehub/lobehub★ 83ksame name
- microsoft/fast★ 9.7ksame name
- alinaqi/maggy★ 707same name
- Mindrally/skills★ 266same name
- martinholovsky/claude-skills-generator★ 47same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- siviter-xyz/dot-agent★ 22same name
- sordi-ai/skill-everything★ 20same name
- alexander-danilenko/cortex-ai-skills★ 16same name
- caidanw/skills★ 9same name
23 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 repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- agent-flowSkill
- dev-testingSkill
- dry-and-corSkill
- electronSkill
- firebaseSkill
- flutterSkill
- google-authSkill
- html-cssSkill
- mysqlSkill
- nodejsSkill
- postgresSkill
- reactSkill
- sqliteSkill
- stack-briefingSkill
- supabaseSkill
- tailwindSkill
- tursoSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 3 are distinctive, and 13 are very specific to this project.
0
Common
Most of the 27 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Check for tsconfig.json, .ts/.tsx sources, or typescript in devDependencies.
- Very specific: line 36
Prefer @ts-expect-error with a comment: it errors when the underlying problem is fixed, so it can't rot.
- Very specific: line 69
as: should be reachable only when you genuinely know more than the compiler (a readonly widening, a well-understood DOM cast) and carries … - Very specific: line 89
Prefer literal unions (type Role = 'admin' | 'user') to enum — unions are erased and structural, while enum emits runtime code and const …
- Very specific: line 92
Use satisfies to check a config object against a type while keeping its narrow literal inference.
- Very specific: line 103
Add a type parameter only to express a relationship the caller cares about — input type determines output type, or two arguments must match.
- Very specific: line 121
Don't type a function Promise<T> and then return a rejected path that callers can't see — model expected failures in the return type (a …
- Very specific: line 144
Don't use any, and don't launder it through as unknown as T.
- Very specific: line 145
Don't as-cast parsed JSON, req.body, or process.env into a type — validate, then derive the type from the validator.
- Very specific: line 147
Don't add @ts-ignore; use @ts-expect-error with a reason, or fix it.
- Very specific: line 148
Don't loosen tsconfig.json strictness to make an error disappear.
- Very specific: line 149
Don't use ! where an early if (!x) throw gives a real guarantee.
- Distinctive: line 150
Don't model state as several optional fields when a discriminated union makes the invalid combinations unrepresentable.
- Distinctive: line 152
Don't introduce a generic that's used once, and don't write a conditional type where an overload would be readable.
- Very specific: line 154
Don't use || for defaults on numbers or booleans — ??
- Distinctive: line 155
Don't treat a successful bundle as a passing typecheck.
“Common” is measured: kept by at least 6 in 10 of the 27 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
The language layer that cuts across the whole roster: frontend-dev,
backend-dev, and api-integration-dev all write TypeScript in most
modern projects, and the rules here apply the same in a React component, an
Express handler, and a migration script. Framework-specific rules stay in
skills/react/SKILL.md; runtime specifics stay in
skills/nodejs/SKILL.md.
Step 1 — Confirm TypeScript is actually in play
Check for tsconfig.json, .ts/.tsx sources, or typescript in
devDependencies. Read the existing tsconfig.json before writing code —
strict, moduleResolution, paths, and verbatimModuleSyntax all change
what valid code looks like. Match the project's settings rather than
assuming defaults, and never loosen a compiler flag to make an error go
away.
Step 2 — Strict mode is the baseline
strict: trueis the starting point, not an aspiration. If the project has it off, don't silently write code that only compiles because it's off — say so and keep the new code strict-clean.noUncheckedIndexedAccessmakesarr[i]andrecord[key]yieldT | undefined, which is the truth — turning it on surfaces a real class of runtime crashes. Recommend it where the project can absorb the churn.tsc --noEmit(or the project's typecheck script) is the actual gate. A bundler/transpiler such as esbuild, SWC, or Babel strips types without checking them, so "it builds" says nothing about type correctness.@ts-ignoredisables checking for the whole next line, silently, forever. Prefer@ts-expect-errorwith a comment: it errors when the underlying problem is fixed, so it can't rot.
Step 3 — Types are erased; boundaries need runtime validation
This is the single most common source of "TypeScript lied to me": an annotation on data that came from outside the program is an assertion, not a check.
// Wrong: a claim, verified by nothing
const body = await req.json() as CreateUserInput;
// Right: validated at the boundary, type derived from the schema
const body = CreateUserSchema.parse(await req.json());
type CreateUserInput = z.infer<typeof CreateUserSchema>;- Validate at every trust boundary: HTTP request bodies and query params,
process.env,JSON.parseresults,localStorage, third-party API responses, and untyped database driver rows. - Derive the TypeScript type from the schema (
z.inferand equivalents) so the two can't drift; don't hand-maintain a parallelinterface. - Server-side validation stays required regardless of what the client
validates — see
skills/dry-and-cor/SKILL.md; the client is not a trust boundary and a shared type is not a check.
Step 4 — The three escape hatches
anyturns off checking for everything that value touches, and it spreads through assignments. Useunknowninstead and narrow with atypeof/in/instanceofcheck or a type predicate —unknownforces the narrowing thatanyskips.asshould be reachable only when you genuinely know more than the compiler (areadonlywidening, a well-understood DOM cast) and carries a comment saying why it's sound.as any as Tandas unknown as Tare the same thing with more steps — treat both as a defect being introduced, not a fix.!(non-null assertion) claims a value can't be null. Prefer an earlyif (!x) throw— same brevity, real runtime guarantee, better error.- A type predicate (
function isUser(v: unknown): v is User) is only as correct as its body; the compiler does not verify the claim, so keep the body an exhaustive check, not atypeof v === 'object'shrug.
Step 5 — Model states, don't accumulate flags
- Discriminated unions beat optional-property soup.
{ status: 'loading' } | { status: 'ok'; data: T } | { status: 'error'; error: E }makes the impossible states (dataanderrorboth set) unrepresentable, andswitchnarrowing gives exhaustiveness for free. - Get exhaustiveness enforced: a
defaultbranch assigning toconst _never: never = valueturns a newly added variant into a compile error instead of a silent fall-through. - Prefer literal unions (
type Role = 'admin' | 'user') toenum— unions are erased and structural, whileenumemits runtime code andconst enumbehaves differently across build setups. - Use
satisfiesto check a config object against a type while keeping its narrow literal inference; a plain: Typeannotation widens it and loses the key/value literals. readonlyandas conston data that shouldn't be mutated communicate more than a comment does.- Type-only imports/exports (
import type { … }) matter underverbatimModuleSyntaxandisolatedModules— a value import of a type can break the emitted module graph.
Step 6 — Generics and inference judgment
- Add a type parameter only to express a relationship the caller cares
about — input type determines output type, or two arguments must match.
A generic that appears in exactly one position is usually a disguised
anyand should be a concrete type orunknown. - Constrain type parameters (
<T extends { id: string }>) instead of asserting inside the function body. - Let inference do the work on locals and return values; annotate exported function signatures and module boundaries, where an accidental inferred change is a breaking change.
- Deeply conditional/mapped type gymnastics that nobody on the team can read is a cost, not a win — a plain overload or an explicit union is often the better engineering call.
Step 7 — Errors, async, and null handling
catch (e)givesunknownunder strict settings, and that's correct — anything can be thrown. Narrow withinstanceof Errorbefore touching.message, and keep a fallback branch for non-Error throws.- Don't type a function
Promise<T>and then return a rejected path that callers can't see — model expected failures in the return type (a result union) or throw a typed error class consistently, but pick one per codebase. ??and?.respect0,'', andfalse;||and truthiness checks don't. Using||for a default on a numeric or boolean field is a real bug, not a style preference.- Watch
voidvsundefinedin callbacks: a() => voidsignature accepts a function returning anything, which is how a floating promise slips into an event handler (seeskills/nodejs/SKILL.md).
Step 8 — Self-check before reporting done
Confirm tsc --noEmit passes — not just that the bundler produced output.
Confirm no any, no unexplained as, and no ! was added; every external
input is parsed by a schema with its type derived from that schema. Confirm
new state shapes use a discriminated union with exhaustiveness enforced
rather than a set of optional flags, and that any new generic parameter
appears in more than one position. Confirm catch blocks narrow unknown
before using the error.
What not to do
- Don't use
any, and don't launder it throughas unknown as T. - Don't
as-cast parsed JSON,req.body, orprocess.envinto a type — validate, then derive the type from the validator. - Don't add
@ts-ignore; use@ts-expect-errorwith a reason, or fix it. - Don't loosen
tsconfig.jsonstrictness to make an error disappear. - Don't use
!where an earlyif (!x) throwgives a real guarantee. - Don't model state as several optional fields when a discriminated union makes the invalid combinations unrepresentable.
- Don't introduce a generic that's used once, and don't write a conditional type where an overload would be readable.
- Don't use
||for defaults on numbers or booleans —??is what you mean. - Don't treat a successful bundle as a passing typecheck.
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.

