agentleFS
shreyam1008shreyam1008/shre-skills/skills/javascript/SKILL.md

javascript

Skill0 starsChanged 48 days agoMITView on GitHub

Implements or debugs JavaScript/TypeScript language behavior, async work, data transformations, and runtime memory. Use for JS/TS logic issues; React rendering and UI design have separate workflows.

We split this skill into the rules it gives an agent

15 rules. 0 are common, 3 are distinctive, and 12 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 12

    Very specific

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

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

    Use ===/!==; avoid == (coercion surprises).

    line 14
  2. Very specific:

    Prefer pure functions and immutable updates ({...obj}, [...arr], .map/.filter/.reduce) over in-place mutation of shared data.

    line 15
  3. Very specific:

    Use modules (import/export).

    line 17
  4. Very specific:

    Prefer for...of / array methods over index loops.

    line 18
  5. Very specific:

    Prefer async/await; always handle rejection (try/catch or .catch).

    line 22
  6. Very specific:

    Run independent work concurrently with Promise.all.

    line 23
  7. Distinctive:

    Never leave a floating promise where errors matter — await it or explicitly handle it.

    line 24
  8. Very specific:

    Don't mix await inside a forEach (it won't wait).

    line 25
  9. Very specific:

    Prefer copying array methods (toSorted, toReversed, toSpliced, with).

    line 42
  10. Very specific:

    Use Intl for dates/numbers/currency formatting, not hand-rolled string math.

    line 43
  11. Distinctive:

    Don't allocate in hot loops.

    line 47
  12. Very specific:

    Remove event listeners/observers/timers on teardown to avoid leaks.

    line 50
  13. Very specific:

    Use WeakMap for object-keyed metadata that must not retain its keys.

    line 51
  14. Very specific:

    Keep strict on; avoid any — use unknown and narrow.

    line 55
  15. Distinctive:

    Prefer the platform/standard library before adding a dependency.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 9 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

JavaScript

Modern JS is expressive and fast — most footguns come from async handling, mutation, and equality/coercion surprises. Prefer clarity and immutability; let the engine optimize.

Language baseline

  • const by default, let when reassigning, never var.
  • Use ===/!==; avoid == (coercion surprises). Know that NaN !== NaN (use Number.isNaN).
  • Prefer pure functions and immutable updates ({...obj}, [...arr], .map/.filter/.reduce) over in-place mutation of shared data.
  • Optional chaining ?. and nullish coalescing ?? (distinct from ||, which also catches 0/"").
  • Use modules (import/export); no global leakage. Keep imports at the top.
  • Prefer for...of / array methods over index loops; Map/Set over object-as-dict for dynamic keys.

Async done right

  • Prefer async/await; always handle rejection (try/catch or .catch).
  • Run independent work concurrently with Promise.all; use Promise.allSettled when partial failure is acceptable.
  • Never leave a floating promise where errors matter — await it or explicitly handle it.
  • Don't mix await inside a forEach (it won't wait). Use for...of with await, or map to promises + Promise.all.
  • Cancel stale fetches and signal-aware event listeners with AbortController. Cancel timers with clearTimeout / clearInterval (or an explicit signal-aware wrapper).
// parallel, not serial
const [user, posts] = await Promise.all([getUser(id), getPosts(id)]);

// cancellable fetch
const ac = new AbortController();
const res = await fetch(url, { signal: ac.signal });

Data & correctness

  • Validate/parse external data at the boundary (a schema lib like Zod, or explicit checks) — don't trust shapes.
  • Keep untrusted text out of code/HTML sinks: prefer textContent; sanitize rich HTML with a reviewed sanitizer before innerHTML or insertAdjacentHTML. A TrustedHTML value is safe only if its policy actually validates/sanitizes input; the type alone does not sanitize. Avoid eval and string-form timers. Enforce Trusted Types with CSP where feasible.
  • Beware floating-point money math; use integer minor units or a decimal lib.
  • Prefer copying array methods (toSorted, toReversed, toSpliced, with); copy-then-mutate only for compatibility. Use structuredClone only for cloneable values and handle DataCloneError at untrusted boundaries.
  • Use Intl for dates/numbers/currency formatting, not hand-rolled string math.

Performance & memory

  • Don't allocate in hot loops; hoist constants and reused objects out.
  • Debounce/throttle high-frequency events (scroll, resize, input); use requestAnimationFrame for visual updates.
  • Offload heavy CPU work to a Web Worker to keep the main thread responsive (see web-performance and wasm-rust).
  • Remove event listeners/observers/timers on teardown to avoid leaks; detached DOM nodes held by closures leak.
  • Use WeakMap for object-keyed metadata that must not retain its keys. Reserve WeakRef for recomputable, best-effort values—collection timing is deliberately nondeterministic.

TypeScript (when present)

  • Keep strict on; avoid any — use unknown and narrow. Type the boundary, infer internally.
  • Model invalid states out of existence with unions; use exhaustive switch with a never default.
  • Explicit return types on exported functions; avoid unsafe assertions (as).

Tooling hygiene

  • Lint + format (ESLint + Prettier/Biome) and run in CI.
  • Prefer the platform/standard library before adding a dependency; check bundle cost.

Reference

  • MDN JavaScript reference; "JavaScript guide".
  • GoogleChrome/modern-web-guidance-src (JS/DOM guides).
  • MDN: AbortController, copying array methods, WeakMap/WeakRef, innerHTML, and Trusted Types CSP.
  • TC39 proposals; "You Don't Know JS" (Kyle Simpson); web.dev performance guides.

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.