agentleFS
alexderzalexderz/agentic-toolbox/skills/lang-js-ts/SKILL.md

lang-js-ts

Skill5 starsChanged 47 days agoMITView on GitHub

use this when writing, reviewing, or testing JavaScript or TypeScript — *.ts, *.tsx, *.js, *.mjs, *.cjs, tsconfig, package.json. TypeScript-strict wins when tsconfig exists. do not use for HTML/CSS-only (lang-web-markup) or Python.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the lockfile's package manager (pnpm / npm / yarn).

    line 21
  2. Distinctive:

    Do not add a second test runner or a second linter.

    line 30
  3. Very specific:

    Do not empty-catch. Log or wrap with context, then rethrow or return a typed error the caller expects.

    line 46
  4. Distinctive:

    No shared mutable state across requests without a documented store.

    line 53
  5. Very specific:

    Avoid Promise.all on untrusted-length lists without a bound.

    line 55
  6. Distinctive:

    Test through the public API.

    line 60
  7. Distinctive:

    Use the runner already in the repo (node:test, vitest, jest).

    line 63
  8. Distinctive:

    No string-built SQL, HTML, or shell.

    line 78
  9. Very specific:

    Do not store tokens in localStorage.

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

JavaScript / TypeScript

One skill for both. TS-strict is the default when tsconfig.json exists; JS is the same rules minus the type checker. No scripts/. Not a React/Next/Vue skill. Process skills that may load with this one: load-with list. Whether .tsx loads this skill or lang-web-markup: map.

Iron law

any is a bug. Untrusted data is parsed at the boundary. Promises are not fire-and-forget.

Tooling / verify

Use the lockfile's package manager (pnpm / npm / yarn). Typical:

# names vary — run what package.json scripts already define
npm test
npx tsc --noEmit   # when tsconfig exists
npx eslint .       # when eslint is already in the tree

Do not add a second test runner or a second linter. Read the full output.

Idioms a linter misses

  • const default, let when reassigned. No var. No implicit globals.
  • ===. ?? for nullish; do not use || when 0 or '' is valid.
  • Named exports. Default exports only if the file already does.
  • ESM if the package is ESM. Do not mix require and import without an existing pattern.
  • Functions that return a Promise are async or clearly chained. Callers await or return the promise. No floating promises.
  • Narrow with predicates / discriminated unions, not as T.
  • unknown at untrusted boundaries, then narrow. Never as any.

Errors

  • Do not empty-catch. Log or wrap with context, then rethrow or return a typed error the caller expects.
  • Node: do not process.exit from a library.
  • Map HTTP / network failures to a small error union, not a raw any.

Concurrency

  • No shared mutable state across requests without a documented store.
  • AbortSignal for cancellable I/O when the caller can cancel.
  • Avoid Promise.all on untrusted-length lists without a bound.
  • Worker threads / child processes: structured messages, no string eval.

Testing

  • Test through the public API. Mock only at process boundaries (network, clock, RNG, fs).
  • One behavior per test. Names say the expected outcome.
  • Use the runner already in the repo (node:test, vitest, jest). Do not add another.

PR review

  • New as / any / @ts-ignore: reject unless the comment names the invariant and the escape is local.
  • New dependency: why not std or an existing dep?
  • Async path: every rejection handled.
  • Bundle / Node surface: no secrets in client code.

Security

  • Validate untrusted input at the boundary. Use the schema library the repo already has; do not invent a second one.
  • No string-built SQL, HTML, or shell. Parameterize / use APIs.
  • Browser: no innerHTML / dangerouslySetInnerHTML / postMessage of untrusted data. Same sink class. target=_blank needs rel="noopener noreferrer".
  • Node: no eval, new Function, or child_process with a concatenated string. path joins stay inside an allowlisted root.
  • Do not store tokens in localStorage.

Always

  • strict stays on. New files match existing tsconfig.
  • Quote-free equality and nullish rules above.
  • Tests for the new branch.

Ask first

  • Disabling a strict flag.
  • Adding a runtime schema library the repo does not use.
  • Introducing a new test runner or bundler.
  • any in a public .d.ts.

Never

  • any, as unknown as T, empty catch {}.
  • eval / new Function / document.write.
  • String-building SQL, HTML, or shell.
  • Pinning a future TS / Node version the repo is not on.

Red flags

  • "I'll type this as any and fix later"
  • "The frontend already validated it"
  • "JSON.parse is fine, we control the server"
  • "It's just a quick child_process.exec"

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.