programming-javascript
Skill1 starsChanged 6 days agoMITView on GitHub
This skill should be used when writing, reviewing, or refactoring JavaScript or TypeScript code for Node, Bun or other runtimes: language idioms, async correctness, TypeScript strictness, performance, and untrusted-input safety; not browser DOM/CSS or MCP protocol specifics.
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 2 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
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
- Very specific: line 10
Write ESM with named exports.
- Very specific: line 15
Use arrow functions for callbacks, named function declarations at top level.
- Distinctive: line 18
Document public APIs with JSDoc: exact parameters, defaults, return value, thrown errors, and whether inputs are mutated or retained.
- Very specific: line 22
Use async/await; do not mix .then() chains into the same function.
- Very specific: line 24
Use Promise.all for independent work, Promise.allSettled when partial failure is acceptable.
- Very specific: line 25
Never block the event loop with synchronous I/O or long CPU loops on a request path.
- Very specific: line 32
Use interface for extensible object shapes, type for unions and intersections.
- Very specific: line 36
Keep object shapes stable: initialize every field in the constructor in a fixed order.
- Distinctive: line 37
Keep hot call sites monomorphic: same argument types and shapes every call.
- Very specific: line 39
Use typed arrays for bulk numeric data.
- Very specific: line 44
Never pass user input to eval, new Function, string timers, vm or dynamic import().
- Very specific: line 45
Run processes with execFile/spawn(file, args), never exec with an interpolated string.
- Very specific: line 47
Avoid nested or overlapping regex quantifiers ((a+)+) on user input.
- Very specific: line 53
Use the runtime's test runner (bun test, node --test).
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.
Files
Programming JavaScript
Language
- Write ESM with named exports.
constby default,letonly for reassignment, nevervar. - End statements with explicit
;; never rely on automatic semicolon insertion. - Compare with
===/!==. Use?.and??for absent values;||also replaces0,''andfalse. - Numbers are doubles: integers are exact only up to
Number.MAX_SAFE_INTEGER; useBigIntbeyond, and never compare money or fractions with raw float===. - Iterate arrays with
for...ofor array methods, neverfor...in. - Use arrow functions for callbacks, named function declarations at top level; use
#privatefields for class privacy. - Naming:
camelCasevalues and functions,PascalCaseclasses and types,SCREAMING_SNAKE_CASEtrue constants,is/has/canbooleans. - Take several optional settings as one options object with destructured defaults:
function createBuffer({ capacity = 64, grow = true } = {}). Keep required arguments positional. - Document public APIs with JSDoc: exact parameters, defaults, return value, thrown errors, and whether inputs are mutated or retained.
Async and Resources
- Use
async/await; do not mix.then()chains into the same function. - Await or explicitly handle every promise; a floating promise loses its rejection.
- Use
Promise.allfor independent work,Promise.allSettledwhen partial failure is acceptable; bound concurrency for large batches. - Never block the event loop with synchronous I/O or long CPU loops on a request path; yield periodically (
setImmediate,scheduler.yield()) or move work to a worker. - Give every resource (handle, stream, timer, listener,
AbortController) one owner and one release path; release infinally. Pairopenwithclose; makeclosesafe to call twice. - Validate external input once at the module boundary; trust it internally afterwards.
TypeScript
- Enable
strict. Never useany; takeunknownand narrow. Give public functions explicit return types. - Use
interfacefor extensible object shapes,typefor unions and intersections; use string-literal unions for modes.
Performance
- Keep object shapes stable: initialize every field in the constructor in a fixed order; never add or
deleteproperties later (assignundefined). - Keep hot call sites monomorphic: same argument types and shapes every call; keep arrays homogeneous.
- Hoist loop-invariant checks out of hot loops. Keep iterator state minimal without rescanning.
- Use typed arrays for bulk numeric data; transfer or share
ArrayBuffers with workers instead of copying. - Closures retain everything they capture: extract the needed values before creating long-lived callbacks. Drop references, listeners, intervals and subscriptions when done.
Untrusted Input
- Never pass user input to
eval,new Function, string timers,vmor dynamicimport(); dispatch through an allowlisted object instead. - Run processes with
execFile/spawn(file, args), neverexecwith an interpolated string. - Merge or set untrusted keys only through an allowlist; reject
__proto__,constructor,prototype; useMaporObject.create(null)for dictionaries. - Avoid nested or overlapping regex quantifiers (
(a+)+) on user input; cap input length; never compile user-supplied patterns without a linear-time engine. - Generate tokens, IDs and OTPs with
crypto.randomBytes/randomInt/getRandomValues, neverMath.random. - Contain paths by canonicalizing both sides with
fs.realpath, then reject whenpath.relative(base, target)is absolute or starts with... String-prefix checks onpath.resolveare not symlink-safe.
Testing
- Use the runtime's test runner (
bun test,node --test); name tests as behavior sentences; arrange, act, assert. - Mock only at boundaries. Test failure paths by injecting failing dependencies.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-prompt-authoringSkill
- ai-skill-authoringSkill
- ai-tool-writingSkill
- analyzing-securitySkill
- coreSkill
- language-writingSkill
- programming-api-designSkill
- programming-debuggingSkill
- programming-optimizationSkill
- technical-specificationsSkill
- ux-uiSkill
- web-buildSkill
- web-frontendSkill
- web-uxSkill
- web-visual-checkSkill
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
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.

