JavaScript
Writes, debugs, and reviews JavaScript: async and the event loop, coercion, closures, dates, Unicode, regex, and modern ES2023+ APIs. Use when JS throws…
by clawic★ 23 GitHub stars
Install JavaScript in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
User preferences and memory live in ~/Clawic/data/javascript/ (see setup.md on first use, memory-template.md for the file format). If you have data at an old location (~/javascript/ or ~/clawic/javascript/), move it to ~/Clawic/data/javascript/, and say in one line that you moved it and from where.
Configuration
User-dependent variables. Defaults apply until the user states a preference; store them in ~/Clawic/data/javascript/config.yaml.
| Variable | Type | Default | Effect |
|---|---|---|---|
| runtime_target | node | browser | both | node | Selects which platform file applies by default (node.md vs browser.md) and which floor gates advice |
| node_floor | number (Node major) | from package.json engines, else 22 |
Gates every recommendation against the feature-floor table in modern.md; flags any API above the floor |
| module_system | esm | cjs | dual | esm | Switches module guidance and import/export examples in modern.md; dual activates the dual-package hazard checks |
| browser_floor | text (e.g. "Safari 16+", "last 2 years") | none | When set, gates syntax and API advice for browser-targeted code the way node_floor gates Node |
Preference areas to record as the user reveals them:
- tooling — package manager, bundler, test runner, lint/format stack — affects which commands and config examples are offered
- conventions — style (semicolons, functional vs imperative iteration), error-handling shape (exceptions vs result values) — affects generated code and review verdicts
- platform — Deno/Bun/edge runtimes, TypeScript presence, monorepo layout — affects which floors and module advice apply
- safety posture — how proactively to flag legacy patterns (
var,==, callback APIs) in review vs only on request
When To Use
- Debugging JavaScript: wrong values, NaN, TypeErrors, ordering surprises, async bugs, timezone shifts
- Writing or reviewing JS (Node or browser) for correctness and modern idioms
- Choosing data structures (Object/Map/Array/Set), copy semantics, iteration strategy, or error-handling shape
- Deciding whether an ES2020+ feature is safe for the target runtime
- Diagnosing memory growth, leaks, slow code, or an unresponsive event loop
- Not for TypeScript type-system design or framework internals — this is the core language
Quick Reference
| Situation | Go to |
|---|---|
| TypeError/ReferenceError, NaN appearing, value undefined after await, works-in-dev-only, heisenbug | debug.md |
| Promise/await bug, rejection handling, cancellation, concurrency limits, races | async.md |
| Throwing, catching, custom errors, cause chains, global error hooks, serializing errors | errors.md |
== surprise, truthiness, implicit conversion, ?? vs || |
coercion.md |
| Array/Object/Map/Set choice, copying, sorting, iteration traps | collections.md |
| ES2020+ syntax semantics, feature floors, modules (ESM/CJS), classes, generators/iterators | modern.md |
| Memory grows, listener/timer leaks, WeakMap/WeakRef, heap snapshots | memory-leaks.md |
| Slow code, jank, benchmarks, GC pressure, workers | performance.md |
Regex wrong matches, stateful lastIndex, catastrophic backtracking, Unicode flags |
regex.md |
| JSON precision loss, Date/Map round-trips, reviver/replacer, canonicalization | json.md |
| Env vars, process exit, signals, streams, Buffer, child processes | node.md |
| DOM events, storage, script loading, fetch response handling | browser.md |
Anything else (numbers, dates, strings, this, timers) |
Sections below |
Core Rules
===always; the only defensible==is the idiomx == null— it matches both null and undefined in one check. Never expand it to two comparisons.- Float equality is a band, not
===:Math.abs(a - b) <= Number.EPSILON * Math.max(1, Math.abs(a), Math.abs(b)). Worked:0.1 + 0.2 - 0.3≈ 5.6e-17, inside the band (EPSILON ≈ 2.2e-16). Money never touches floats: integer minor units. - Every promise gets a handler attached synchronously — a rejection with no handler when the microtask queue drains crashes Node (default since Node >=15) and fires
unhandledrejectionin browsers. - Mutation is opt-in: default to
toSorted/toReversed/withand spread;structuredCloneonly when depth is real. Runtime floors for all of these:modern.md. - Durations from
performance.now()(monotonic); wall-clock timestamps fromDate.now(). Never subtract twoDate.now()calls for benchmarks — NTP can step it backwards mid-measurement. - Sequential vs parallel is a decision you write down:
for...of+ await = sequential;Promise.all(arr.map(f))= parallel, fail-fast, and it does NOT cancel the losers. .lengthcounts UTF-16 code units, not characters:"😀".length === 2. Slice user-visible text withIntl.Segmenter, never by index.- Check the feature-floor table in
modern.mdbefore shipping ES2023+ APIs — onetoSortedcall breaks Node 18 at runtime, not at bui
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- _meta.json
- async.md
- browser.md
- coercion.md
- collections.md
- debug.md
- errors.md
- json.md
- memory-leaks.md
- memory-template.md
- modern.md
- node.md
- performance.md
- regex.md
- setup.md
FAQ
What does the JavaScript skill do?
Writes, debugs, and reviews JavaScript: async and the event loop, coercion, closures, dates, Unicode, regex, and modern ES2023+ APIs. Use when JS throws TypeError or "undefined is not a function", a promise never settles or a rejection goes unhandled, NaN or [object Object] appears, dates shift by a day, sorting or equality misbehaves, memory grows, a regex hangs, JSON loses precision, a Node process won't exit or ignores signals, or fetch doesn't reject on a 404; also when choosing data structures, handling errors, profiling slow code, or checking whether a feature is safe for a target Node or browser version. Covers Node and browser runtime edges. Not for TypeScript type-system design or framework internals.
How do I install the JavaScript skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the JavaScript skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…