typescript-best-practices
Skill2 starsChanged 4 months agoMITView on GitHub
Write strict, idiomatic TypeScript with sound types, narrowing, and clear API contracts. Use when writing or refactoring TypeScript, adding types to JS, designing interfaces, fixing type errors, or when the user mentions tsconfig, generics, or typed APIs.
99 other projects use a version of this.
Adopted by
Most recently taken up by
- BabylonSocial/babylontheir own version, first seen Nov 30, 2026
- ngxccc/engineered-skillstheir own version, first seen Nov 29, 2026
- MondayNotAGoodDay/skillstheir own version, first seen Nov 29, 2026
- MarkTripoli/skillstheir own version, first seen Nov 29, 2026
- karanmrn/karanagentskillstheir own version, first seen Nov 29, 2026
- The-Utopia-Studio/skillstheir own version, first seen Nov 29, 2026
Used with
Projects with it also use setup-pstack, make-bot-ui and 10 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.
bnemaSkillsetup-pstack
Configure which Pi models pstack uses per role. Detects available provider/model specs and writes pstack's user configuration. Use for /setup-pstack, "configure pstack models", or changing pstack model choices.
Also in 24 projects that use this
eryzerzSkillmake-bot-ui
Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.
Also in 15 projects that use this
shiwenbin1617Skillketchup-video
Catch the user up like /ketchup, with a short subtitled video of slides for what happened and the waiting calls as text under it. Use for /ketchup-video.
Also in 10 projects that use this
shiwenbin1617Skillstatechart
Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states.
Also in 11 projects that use this
mukcoSkillprinciples
General software engineering principles — DRY, SOLID, YAGNI, KISS, naming, code smells, and refactoring. Language-agnostic. Use alongside language-specific skills.
Also in 4 projects that use this
rohunvoraSkillreframe
This skill should be used when the user is stuck, obvious solutions aren't working, constraints feel impossible, or they keep circling back to bad options. Use when designs keep getting rejected or the user is solving symptoms instead of root causes.
Also in 3 projects that use this
Other versions99 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 99
- Yeachan-Heo/oh-my-claude-sisyphus★ 41ksame name
- Yeachan-Heo/oh-my-claudecode★ 41ksame name
- trpc/trpc★ 41ksame name
- elizaOS/eliza★ 20ksame name
- backnotprop/pstack★ 5.4ksame name
- jtaroreh/agystack★ 142same name
- uzairansaruzi/p3-stack★ 126same name
- BabylonSocial/babylon★ 120same name
- dsebban/skills★ 82same name
- TencentBlueKing/bk-lite★ 77same name
89 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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- debuggingSkill
- javascript-best-practicesSkill
- nextjs-app-routerSkill
- nextjs-data-fetchingSkill
- python-best-practicesSkill
- python-testingSkill
- react-best-practicesSkill
- tagged-code-commentsSkill
- create-skillSkill
- revise-skillSkill
- academic-paperSkill
- latex-scientific-writingSkill
- paper-abstractSkill
- paper-conclusionSkill
- paper-discussionSkill
- paper-introductionSkill
- paper-literature-reviewSkill
- paper-methodsSkill
- paper-peer-reviewSkill
- paper-related-workSkill
- paper-resultsSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 29 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Match existing tsconfig and patterns: Do not loosen strictness to silence errors.
- Very specific: line 30
Model the domain: Prefer precise union types and discriminated unions over optional soup (status: 'ok' | 'error').
- Very specific: line 31
Narrow before use: Use type guards, in checks, and exhaustiveness (switch + never) for unions.
- Distinctive: line 33
Generics when they remove duplication: Add type parameters for reusable containers/helpers.
- Very specific: line 36
Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …).
“Common” is measured: kept by at least 6 in 10 of the 29 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 Best Practices
Defaults
| Concern | Default |
| Strictness | Prefer strict: true (and project-equivalent flags) |
| Modules | ESM + project moduleResolution (often bundler or NodeNext) |
| Types vs interfaces | type for unions/intersections/aliases; interface for object shapes meant to be extended |
any | Avoid; use unknown + narrowing instead |
| Assertion | Prefer narrowing over as casts; never as any unless escaping a known lib bug |
Instructions
- Match existing tsconfig and patterns. Do not loosen strictness to silence errors; fix types or narrow correctly.
- Model the domain. Prefer precise union types and discriminated unions over optional soup (
status: 'ok' | 'error'). - Narrow before use. Use type guards,
inchecks, and exhaustiveness (switch+never) for unions. - Type public APIs thoroughly. Exported functions, hooks, and components should not rely on inference alone when the contract matters to callers.
- Generics when they remove duplication. Add type parameters for reusable containers/helpers; do not invent complex generics for one-off code.
- Avoid unsafe escapes. Limit
!non-null assertions; document why if unavoidable. - Keep runtime and types aligned. Zod/Valibot (or similar) at boundaries when the project uses them — types alone do not validate external data.
- Tag unfinished or risky work. Use the global
tagged-code-commentsconvention (🔴 FIXME(P0):,🟠 TODO(P1):, …). Never leave silent stubs oras anyescapes without a tag. End with an Open follow-ups table so the developer must check P0/P1 before ship.
Patterns
type Result<T> =
| { ok: true; value: T }
| { ok: false; error: string };
function unwrap<T>(r: Result<T>): T {
if (!r.ok) throw new Error(r.error);
return r.value;
}type Shape =
| { kind: "circle"; radius: number }
| { kind: "rect"; width: number; height: number };
function area(s: Shape): number {
switch (s.kind) {
case "circle":
return Math.PI * s.radius ** 2;
case "rect":
return s.width * s.height;
default: {
const _exhaustive: never = s;
return _exhaustive;
}
}
}Anti-patterns
- Widespread
any/as unknown as T - Optional fields for mutually exclusive states instead of discriminated unions
- Overly wide types (
stringwhere a literal union works) - Duplicating runtime validation and types that drift apart
Additional resources
- references/checklist.md
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.

