JavaScript Pro
When to Use This Skill
- Building vanilla JavaScript applications
- Implementing async/await patterns and Promise handling
- Working with modern module systems (ESM/CJS)
- Optimizing browser performance and memory usage
- Developing Node.js backend services
- Implementing Web Workers, Service Workers, or browser APIs
Core Workflow
- Analyze requirements — Review
package.json, module system, Node version, browser targets; confirm .js/.mjs/.cjs conventions
- Design architecture — Plan modules, async flows, and error handling strategies
- Implement — Write ES2023+ code with proper patterns and optimisations
- Validate — Run linter (
eslint --fix); if linter fails, fix all reported issues and re-run before proceeding. Check for memory leaks with DevTools or --inspect, verify bundle size; if leaks are found, resolve them before continuing
- Test — Write comprehensive tests with Jest achieving 85%+ coverage; if coverage falls short, add missing cases and re-run. Confirm no unhandled Promise rejections
Reference Guide
Load detailed guidance based on context:
| Topic |
Reference |
Load When |
| Modern Syntax |
references/modern-syntax.md |
ES2023+ features, optional chaining, private fields |
| Async Patterns |
references/async-patterns.md |
Promises, async/await, error handling, event loop |
| Modules |
references/modules.md |
ESM vs CJS, dynamic imports, package.json exports |
| Browser APIs |
references/browser-apis.md |
Fetch, Web Workers, Storage, IntersectionObserver |
| Node Essentials |
references/node-essentials.md |
fs/promises, streams, EventEmitter, worker threads |
Constraints
MUST DO
- Use ES2023+ features exclusively
- Use
X | null or X | undefined patterns
- Use optional chaining (
?.) and nullish coalescing (??)
- Use async/await for all asynchronous operations
- Use ESM (
import/export) for new projects
- Implement proper error handling with try/catch
- Add JSDoc comments for complex functions
- Follow functional programming principles
MUST NOT DO
- Use
var (always use const or let)
- Use callback-based patterns (prefer Promises)
- Mix CommonJS and ESM in the same module
- Ignore memory leaks or performance issues
- Skip error handling in async functions
- Use synchronous I/O in Node.js
- Mutate function parameters
- Create blocking operations in the browser
Key Patterns with Examples
Async/Await Error Handling
// ✅ Correct — always handle async errors explicitly
async function fetchUser(id) {
try {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return await response.json();
} catch (err) {
console.error("fetchUser failed:", err);
return null;
}
}
// ❌ Incorrect — unhandled rejection, no null guard
async function fetchUser(id) {
const response = await fetch(`/api/users/${id}`);
return response.json();
}
Optional Chaining & Nullish Coalescing
// ✅ Correct
const city = user?.address?.city ?? "Unknown";
// ❌ Incorrect — throws if address is undefined
const city = user.address.city || "Unknown";
ESM Module Structure
// ✅ Correct — named exports, no default-only exports for libraries
// utils/math.mjs
export const add = (a, b) => a + b;
export const multiply = (a, b) => a * b;
// consumer.mjs
import { add } from "./utils/math.mjs";
// ❌ Incorrect — mixing require() with ESM
const { add } = require("./utils/math.mjs");
Avoid var / Prefer const
// ✅ Correct
const MAX_RETRIES = 3;
let attempts = 0;
// ❌ Incorrect
var MAX_RETRIES = 3;
var attempts = 0;
Output Templates
When implementing JavaScript features, provide:
- Module file with clean exports
- Test file with comprehensive coverage
- JSDoc documentation for public APIs
- Brief explanation of patterns used
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: javascript-pro-23description: Writes, debugs, and refactors JavaScript code using modern ES2023+ features, async/await patterns, ESM module systems, and Node.js APIs. Use when building vanilla JavaScript applications, implementing Promise-based async flows, optimising browser or Node.js performance, working with Web Workers or Fetch API, or reviewing .js/.mjs/.cjs files for correctness and best practices. Use when this capability is needed.4---56# JavaScript Pro78## When to Use This Skill910- Building vanilla JavaScript applications11- Implementing async/await patterns and Promise handling12- Working with modern module systems (ESM/CJS)13- Optimizing browser performance and memory usage14- Developing Node.js backend services15- Implementing Web Workers, Service Workers, or browser APIs1617## Core Workflow18191. **Analyze requirements** — Review `package.json`, module system, Node version, browser targets; confirm `.js`/`.mjs`/`.cjs` conventions202. **Design architecture** — Plan modules, async flows, and error handling strategies213. **Implement** — Write ES2023+ code with proper patterns and optimisations224. **Validate** — Run linter (`eslint --fix`); if linter fails, fix all reported issues and re-run before proceeding. Check for memory leaks with DevTools or `--inspect`, verify bundle size; if leaks are found, resolve them before continuing235. **Test** — Write comprehensive tests with Jest achieving 85%+ coverage; if coverage falls short, add missing cases and re-run. Confirm no unhandled Promise rejections2425## Reference Guide2627Load detailed guidance based on context:2829| Topic | Reference | Load When |30|-------|-----------|-----------|31| Modern Syntax | `references/modern-syntax.md` | ES2023+ features, optional chaining, private fields |32| Async Patterns | `references/async-patterns.md` | Promises, async/await, error handling, event loop |33| Modules | `references/modules.md` | ESM vs CJS, dynamic imports, package.json exports |34| Browser APIs | `references/browser-apis.md` | Fetch, Web Workers, Storage, IntersectionObserver |35| Node Essentials | `references/node-essentials.md` | fs/promises, streams, EventEmitter, worker threads |3637## Constraints3839### MUST DO40- Use ES2023+ features exclusively41- Use `X | null` or `X | undefined` patterns42- Use optional chaining (`?.`) and nullish coalescing (`??`)43- Use async/await for all asynchronous operations44- Use ESM (`import`/`export`) for new projects45- Implement proper error handling with try/catch46- Add JSDoc comments for complex functions47- Follow functional programming principles4849### MUST NOT DO50- Use `var` (always use `const` or `let`)51- Use callback-based patterns (prefer Promises)52- Mix CommonJS and ESM in the same module53- Ignore memory leaks or performance issues54- Skip error handling in async functions55- Use synchronous I/O in Node.js56- Mutate function parameters57- Create blocking operations in the browser5859## Key Patterns with Examples6061### Async/Await Error Handling62```js63// ✅ Correct — always handle async errors explicitly64async function fetchUser(id) {65 try {66 const response = await fetch(`/api/users/${id}`);67 if (!response.ok) throw new Error(`HTTP ${response.status}`);68 return await response.json();69 } catch (err) {70 console.error("fetchUser failed:", err);71 return null;72 }73}7475// ❌ Incorrect — unhandled rejection, no null guard76async function fetchUser(id) {77 const response = await fetch(`/api/users/${id}`);78 return response.json();79}80```8182### Optional Chaining & Nullish Coalescing83```js84// ✅ Correct85const city = user?.address?.city ?? "Unknown";8687// ❌ Incorrect — throws if address is undefined88const city = user.address.city || "Unknown";89```9091### ESM Module Structure92```js93// ✅ Correct — named exports, no default-only exports for libraries94// utils/math.mjs95export const add = (a, b) => a + b;96export const multiply = (a, b) => a * b;9798// consumer.mjs99import { add } from "./utils/math.mjs";100101// ❌ Incorrect — mixing require() with ESM102const { add } = require("./utils/math.mjs");103```104105### Avoid var / Prefer const106```js107// ✅ Correct108const MAX_RETRIES = 3;109let attempts = 0;110111// ❌ Incorrect112var MAX_RETRIES = 3;113var attempts = 0;114```115116## Output Templates117118When implementing JavaScript features, provide:1191. Module file with clean exports1202. Test file with comprehensive coverage1213. JSDoc documentation for public APIs1224. Brief explanation of patterns used123124---125> Converted and distributed by [TomeVault](https://tomevault.io/claim/jeffallan) — claim your Tome and manage your conversions.126<!-- tomevault:4.0:skill_md:2026-04-11 -->