typescript-best-practices
Skill2 starsChanged 8 months agoMITView on GitHub
Use when TypeScript needs focused type-safety, API, or error-handling guidance.
Files
TypeScript best practices
Apply the type-system-discipline principle skill first.
| Rule | Summary |
| Discriminated unions | Model variants with a kind literal discriminant so impossible states can't be represented. No optional-field bags. |
| Branded types | Brand primitives with & { readonly __brand: "X" } so they can't be mixed up. Validate once at the boundary. |
| Constructive modeling | Build the shape so the illegal value can't be constructed. [T, ...T[]] for non-empty, [T, T][] for even length, start plus duration for a range. Not a runtime guard, not a wish for refinement types. |
| Simplest total type | Keep T[] while every operation on it stays total. Strengthen to NonEmpty<T> only where the loose type forces !, a cast, or a "should never happen" throw. |
unknown over any | External data is unknown. |
| Schemas before guards | Before hand-writing a property-by-property type guard, use the repository's runtime schema library and infer the type from the schema, such as z.infer. |
No as casts | Every as is a runtime crash waiting. Cast only after validation. |
| Narrowing hierarchy | Discriminant switch > in operator > typeof/instanceof > user-defined type guard > as. |
| Type guards | Must verify the claim. A lying guard is worse than as because the bug hides behind a name that says it's safe. Name them isX or hasX. |
| Exhaustiveness | Inline const _exhaustive: never = x; in default arms so the compiler errors when a new variant is added. |
satisfies over as | Validates the value without widening literal types. |
| Boundary validation | Parse where data crosses in, into a named domain type. Record<string, unknown> (however spelled) stops at that parse. Trust types inside. See the boundary-discipline principle skill. |
| Schema-derived types | Reach for Pick/Omit/Parameters/ReturnType/Awaited/typeof before declaring a new interface. |
| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
| Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak/disposable checks, and verify UI in a running build. Mock only what you can't run locally. |
| Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No console.log in shipped code. |
Examples: references/patterns.md.
Other versions66 projects use a version of this.
Word for word · 0
None found.
Edited · 50
- backnotprop/pstack★ 3.3k90% same
- jtaroreh/agystack★ 12888% same
- uzairansaruzi/p3-stack★ 12695% same
- dsebban/skills★ 7184% same
- overextended/skills★ 2222% same
- Scino/fstack★ 1886% same
- creedants/pstack-t3★ 1791% same
- korallis/skills-collection★ 1488% same
- kkgogogo17/pi-pstack★ 985% same
- mariusflorescu/pstack-t3★ 983% same
40 more not listed
Wrote their own version · 16
- baekenough/oh-my-customcode★ 42same name
- TheOnlyFusionCube/potetos-for-everyone★ 18same name
- DavidTeju/shared-skills★ 9same name
- flpbalada/fb-skills★ 8same name
- robconery/kolea★ 7same name
- kelesmert/turnlens★ 4same name
- Spardutti/claude-skills★ 3same name
- amirrezaalasti/codescribe★ 2same name
- LuisUrrutia/skills★ 2same name
- maxatwork/skills★ 1same name
6 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.
Used alongsideProjects with it also use setup-pstack, poteto-help 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 21 projects that use this
ianclearySkillpoteto-help
Guides users through pstack setup, /poteto-mode, and picking the skill, playbook, or principle for a task. Type /poteto-help with a question.
Also in 8 projects that use this
alexnthnzSkillin-your-own-words
Restate in your own words what you think the user's goals are and what problem they're trying to solve. Use for /keel:in-your-own-words.
Also in 8 projects that use this
juancamiloqhzSkillprinciple-explain-the-number
Apply before you trust, report, or act on a number you measured: a speedup, a regression, a throughput, a latency, or an eval result. Find what limits it, and rule out that it measured something other than the work you think.
Also in 15 projects that use this
Xia-AtaraxiaSkillmake-bot-ui
Builds a small web page whose buttons wake an agent over a webhook: a local server keeps the sender key server-side and POSTs JSON to a webhook-triggered routine, and the page is exposed on the existing Tailscale node. Use for \"make a bot UI\", \"a dashboard with buttons that trigger the agent\", \"wake the bot from a page\", handing a webhook sender key to the server without pasting it in chat, or putting that UI on the tailnet. Not for general frontend work - use principle-frontend; not for tailnet health or reachability - use tailscale.
Also in 14 projects that use this
Xia-AtaraxiaSkillbenchmark-checklist
Vets performance measurements for the limiter, tuning, physical limits, errors, repeatability, relevance, and proof that timed work happened. It applies to 'check this benchmark', 'report this speedup', measured regressions, and choosing a library or configuration from numbers. It reports spread and gaps before drawing a conclusion. Not for general testing policy or choosing test oracles - use principle-testing.
Also in 15 projects that use this
In this repository93 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/code-simplifier.mdcCursor rule
- .cursor/rules/tdd-verification.mdcCursor rule
- ckm:banner-designSkill
- ckm:brandSkill
- ckm:designSkill
- ckm:design-systemSkill
- ckm:slidesSkill
- ckm:ui-stylingSkill
- ui-ux-pro-maxSkill
- mission-control-agent-integrationSkill
- agent-watchdogSkill
- architectSkill
- arenaSkill
- automate-meSkill
- babysitSkill
- before-and-afterSkill
- blast-radiusSkill
- broSkill
- code-structureSkill
- create-verification-skillSkill
- deslopSkill
- evidence-driven-testingSkill
- factory-babysit-prSkill
- factory-collectSkill
- factory-human-digestSkill
- factory-lookbackSkill
- factory-recoverSkill
- factory-review-prsSkill
- factory-shipSkill
- factorySkill
- factory-watchdogSkill
- figure-it-outSkill
- fix-ciSkill
- fix-merge-conflictsSkill
- get-pr-commentsSkill
- greploop-appsSkill
- greploopSkill
- howSkill
- interrogateSkill
- maintain-verification-skillSkill
- make-pr-easy-to-reviewSkill
- mission-control-budget-controlSkill
- mission-control-deliverySkill
- mission-control-heartbeatSkill
- mission-control-record-memorySkill
- mission-control-register-agentSkill
- mission-control-request-approvalSkill
- mission-control-run-loggingSkill
- mission-control-submit-deliverableSkill
- mission-control-task-lifecycleSkill
- new-featureSkill
- no-commentsSkill
- plan-arbiterSkill
- poteto-modeSkill
- principle-attack-the-premiseSkill
- principle-boundary-disciplineSkill
- principle-build-the-leverSkill
- principle-encode-lessons-in-structureSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

