Typescript
When your agent starts coding, you gotta let it cook
npx -y skills add ndisisnd/cook --skill typescriptAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
TypeScript 5.x language standards for type safety, narrowing, generics, modules, and async code. Use for TypeScript implementation or review work; load refs only for tooling, testing, or security-specific tasks.
SKILL.md
6.7 KB, as published. Nobody here has run it
TypeScript Standards
Default load: this file only. Pull refs/tooling.md, refs/testing.md, or refs/security.md only when the task explicitly needs that depth.
Priority: P0 — Type Correctness
Type Annotations
- Explicit params and return types on all public declarations. Infer locals.
- Avoid
any. Preferunknown, generics, or a narrowly-scoped escape hatch with a comment when interop forces it. - Never use the
Functiontype. Use a typed signature:() => void.
Interfaces vs Types
interfacefor object shapes that describe APIs — supports declaration merging.typefor unions, intersections, mapped types, and conditional types.
Strict Mode
strict: truein tsconfig. On existing repos, migrate incrementally:strictNullChecks→noImplicitAny→strictFunctionTypes. Never flipstrict: truein one step.- Avoid non-null assertion (
!). Use narrowing (typeof,instanceof, if-checks) instead. ?.and??for null safety — use narrowing, not!.
Enums
- Literal unions or
as constobjects. No runtimeenum.
Generics
- Use generics for reusable, type-safe code. Constrain with
extendswhere appropriate.
Type Guards
- Use
typeof,instanceof, and predicate functions (x is T) to narrow types.
Utility Types
- Prefer built-ins:
Partial,Required,Pick,Omit,Record,Readonly,NonNullable. - Prefer
satisfiesfor object literals that must conform to a contract without widening the inferred type.
Immutability
readonlyon arrays and object properties. Useas constandsatisfiesfor const assertions.
Discriminated Unions
- Use a stable discriminant such as
kindortypeto narrow safely. Switch on the discriminant.
type Result<T> = { kind: 'ok'; data: T } | { kind: 'err'; error: Error };
Branded Types
- Use brands only when structurally identical values such as IDs or units are easy to mix up across boundaries.
type UserId = string & { readonly __brand: 'UserId' };
function createUserId(id: string): UserId { return id as UserId; }
Exhaustiveness
- Use
neverin switchdefaultto catch unhandled union members at compile time.
Priority: P0 — Boundary Safety
External Data
- Treat data from I/O boundaries as untrusted until it is parsed, validated, and narrowed.
- Prefer schema-based validation at API and persistence boundaries when the project already uses a validator. Load
refs/security.mdfor concrete API/auth guidance.
Dangerous Sinks
- Never interpolate untrusted input into SQL, shell commands, HTML, filesystem paths, or externally-sourced URLs.
- Use parameterized queries, safe child-process APIs, output sanitization, and origin allowlists where the sink requires them.
Secrets
- Never hardcode secrets, tokens, or credentials in source.
- Never log secrets or raw auth tokens.
Priority: P1 — Code Conventions
Naming
PascalCase: classes, types, interfaces.camelCase: variables, functions, methods.UPPER_SNAKE_CASE: static constants only.
Functions
- Arrow functions for callbacks and inline logic. Function declarations for top-level exports.
- Always type return values on public API functions.
Modules
- Prefer named exports unless a framework or file convention requires a default export.
import typefor interfaces and types — zero runtime overhead.- Keep import grouping consistent with the repo. Load
refs/tooling.mdwhen changing lint enforcement.
Async
- Prefer
async/await. UsePromise.all()only for independent work that can safely run in parallel. try/catchwithcatch (e: unknown)— narrow before use. Avoid.then().catch()chains.
Classes
- Use explicit visibility when it protects internal state or materially improves readability. Avoid redundant
publicchurn unless the repo standard requires it. - Favor composition over inheritance. Constructor injection with interfaces — not singletons.
Optional Chaining
?.and??over manual null checks.
Priority: P1 — Verification
After editing any .ts/.tsx file:
- Use TypeScript diagnostics from the editor, LSP, or MCP tooling when available.
- Run the repo's typecheck command (
tsc --noEmit,pnpm typecheck, or equivalent). - Run the repo's lint and test commands for the changed surface. Use auto-fix only when the repo already expects it.
Fallback when no LSP tooling is configured: run the repo's typecheck command directly.
Inspect inferred types before adding annotations that may fight the compiler. Check references before large renames or signature changes.
Anti-Patterns
- Broad
anyusage whenunknown, generics, or a local escape hatch would work Functiontype — use a typed signature() => void- Runtime
enum— use literal unions oras const - Non-null assertion
!— use narrowing - Default exports where the framework or file convention does not require them
require()— use ES6import- Empty interfaces — use
typeor a non-empty interface - Unsafe mock casts — use
jest.Mocked<T>oras unknown as T @ts-ignore— use@ts-expect-error(self-documents intent; fails if the error disappears)- Global
eslint-disable— suppress per-line; fix root cause - Atomic
strict: trueflip on an existing repo — migrate incrementally starting withstrictNullChecks eval,Functionconstructor, or string literals as timer callbacks- Shell string interpolation with untrusted input (
execSync(\cmd ${userInput}`)`) - Unvalidated externally-sourced URLs passed to network or redirect APIs
- Plaintext secrets in code, tests, fixtures, or Git
References
Load only what the current task requires:
- tooling — configuring tsconfig, ESLint, Jest, Vitest, build pipeline, or CI
- testing — writing, debugging, or reviewing tests
- security — input validation, authentication, JWT, secrets, or API security
Do not load refs for ordinary type-shape, refactor, or local implementation tasks.