agentleFS
LuisUrrutiaLuisUrrutia/skills/typescript-best-practices/SKILL.md

typescript-best-practices

Skill2 starsChanged 57 days agoMITView on GitHub

Use when implementing or reviewing TypeScript code, including type contracts and compiler or module configuration.

38 other projects use a version of this.

Adopted by

Most recently taken up by

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.
  • eryzerzSkill

    make-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

  • shishivSkill

    setup-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

  • TheOnlyFusionCubeSkill

    principle-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

  • TheOnlyFusionCubeSkill

    principle-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

  • shishivSkill

    principle-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

  • finograficSkill

    figure-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

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is 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.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the simplest types that make the required operations safe.

    line 8
  2. Very specific:

    Parse untrusted values: Treat incoming untyped data as unknown.

    line 25
  3. Distinctive:

    Run the repository's checker against the changed files and affected consumers.

    line 54

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TypeScript best practices

Use the simplest types that make the required operations safe. Preserve the task's implementation or inspection scope and the repository's public contracts.

Keep types honest

  • Strengthen types where an operation needs it. An empty collection can have a valid result or explicit absence; introduce a non-empty representation only when the contract requires one. Use discriminated unions for dependent fields and compiler-checked exhaustiveness for closed variants. Keep independently optional fields optional. Brand primitives where mixing identities or units causes a concrete error; a brand alone proves no runtime constraint.
  • Use the authoritative contract. Infer from the existing schema or generated source when it owns the same contract. Keep stable public interfaces independent of private implementation details. Preserve legitimate callers and documented states, including ones absent from today's call sites. A generic must express a real relationship; letting a caller choose an unchecked return type proves nothing. Prefer inference over redundant annotations or elaborate type machinery.
  • Parse untrusted values. Treat incoming untyped data as unknown; reuse the project's validator and validate at the boundary that owns the contract. An annotation, generated client type, as, satisfies, or generic argument does not validate runtime data. Use satisfies to check static compatibility, not to repair a mismatch. Do not silence a real mismatch with any, !, double casts, suppression, or weaker compiler settings. Isolate a necessary assertion at a justified boundary and test the invariant it relies on; as const is not a claim that arbitrary input has been validated.
  • Check a predicate's whole promise. A declared value is T must justify both branches: true means T, false excludes T. Property presence or one checked field rarely proves a whole object. Assertion functions need the same scrutiny for the guarantee they claim after returning.
  • Keep guarantees valid until use. readonly and as const do not freeze runtime objects. Mutation through aliases, callbacks, or across an await can invalidate narrowing or a non-empty collection. Preserve ownership, capture a stable value, or recheck at the relevant transition.
  • Represent absence accurately. Arbitrary dictionary keys and array indices can be missing, even with Record<string, T> or a non-empty array. Distinguish omission, explicit undefined, and null when the contract does. strict alone does not enable noUncheckedIndexedAccess or exactOptionalPropertyTypes; do not assume either guarantee or turn a small change into an unrelated configuration migration.
  • Own asynchronous completion. An async function can fit a void callback whose caller ignores its promise. Check whether completion and rejection reach the intended owner. void promise only discards the value. Use error-handling when recovery policy needs design; do not invent a catch-and-log policy here.

Verify the contract

Run the repository's checker against the changed files and affected consumers; transpilation is not type checking. For changed type contracts, check valid and invalid uses with assertions that actually fail on regression. A type alias evaluating to false is not a failing test. Exercise runtime boundary behavior separately. Keep formatting and enforceable style in existing tooling.

For compiler, import/export, or package changes, read compiler-and-modules.md. For requested upstream maintenance, read upstream-updates.md.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.