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.
38 other projects use a version of this.
Adopted by
Most recently taken up by
- PickleBoxer/pstacktheir own version, first seen Oct 6, 2026
- uzairansaruzi/p3-stacktheir own version, first seen Oct 5, 2026
- backnotprop/pstacktheir own version, first seen Oct 4, 2026
- LuisUrrutia/skillstheir own version, first seen Oct 4, 2026
- creedants/pstack-t3their own version, first seen Oct 3, 2026
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
Used with
Projects with it also use make-bot-ui, setup-pstack 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.
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 8 projects that use this
shishivSkillsetup-pstack
Configure pstack delegation against the active Pi host. Use for /skill:setup-pstack, "configure pstack models", or checking delegation readiness.
Also in 14 projects that use this
TheOnlyFusionCubeSkillprinciple-attack-the-premise
Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.
Also in 10 projects that use this
TheOnlyFusionCubeSkillprinciple-test-behavior-not-implementation
Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.
Also in 10 projects that use this
shishivSkillprinciple-never-block-on-the-human
Apply when tempted to ask 'should I do X?' on reversible work. Proceed, present the result, let the human course-correct after the fact; reserve confirmation for irreversible actions.
Also in 19 projects that use this
finograficSkillfigure-it-out
Design an auditable playbook when no narrower one fits: a large migration, an ambitious multi-part change, or work a human reviews after stepping away. Scales rigor to the task, runs a hypothesis loop, and logs decisions via show-me-your-work. Use for /figure-it-out, 'figure it out', a large migration, or when no narrower playbook applies.
Also in 20 projects that use this
- +6 more from shishiv
Other versions38 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 38
- backnotprop/pstack★ 991same name
- uzairansaruzi/p3-stack★ 129same name
- jtaroreh/agystack★ 58same name
- baekenough/oh-my-customcode★ 43same name
- shrimpwtf/oh-my-pstack★ 31same name
- korallis/skills-collection★ 18same name
- DavidTeju/shared-skills★ 9same name
- ofershap/typescript-best-practices★ 9same name
- flpbalada/fb-skills★ 8same name
- painhardcore/pstack★ 6same name
28 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 14 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 14 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.

