agentleFS
boazsegevboazsegev/omoya/skills/programming-javascript/SKILL.md

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
  1. Very specific:

    Write ESM with named exports.

    line 10
  2. Very specific:

    Use arrow functions for callbacks, named function declarations at top level.

    line 15
  3. Distinctive:

    Document public APIs with JSDoc: exact parameters, defaults, return value, thrown errors, and whether inputs are mutated or retained.

    line 18
  4. Very specific:

    Use async/await; do not mix .then() chains into the same function.

    line 22
  5. Very specific:

    Use Promise.all for independent work, Promise.allSettled when partial failure is acceptable.

    line 24
  6. Very specific:

    Never block the event loop with synchronous I/O or long CPU loops on a request path.

    line 25
  7. Very specific:

    Use interface for extensible object shapes, type for unions and intersections.

    line 32
  8. Very specific:

    Keep object shapes stable: initialize every field in the constructor in a fixed order.

    line 36
  9. Distinctive:

    Keep hot call sites monomorphic: same argument types and shapes every call.

    line 37
  10. Very specific:

    Use typed arrays for bulk numeric data.

    line 39
  11. Very specific:

    Never pass user input to eval, new Function, string timers, vm or dynamic import().

    line 44
  12. Very specific:

    Run processes with execFile/spawn(file, args), never exec with an interpolated string.

    line 45
  13. Very specific:

    Avoid nested or overlapping regex quantifiers ((a+)+) on user input.

    line 47
  14. Very specific:

    Use the runtime's test runner (bun test, node --test).

    line 53

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Programming JavaScript

Language

  • Write ESM with named exports. const by default, let only for reassignment, never var.
  • End statements with explicit ;; never rely on automatic semicolon insertion.
  • Compare with ===/!==. Use ?. and ?? for absent values; || also replaces 0, '' and false.
  • Numbers are doubles: integers are exact only up to Number.MAX_SAFE_INTEGER; use BigInt beyond, and never compare money or fractions with raw float ===.
  • Iterate arrays with for...of or array methods, never for...in.
  • Use arrow functions for callbacks, named function declarations at top level; use #private fields for class privacy.
  • Naming: camelCase values and functions, PascalCase classes and types, SCREAMING_SNAKE_CASE true constants, is/has/can booleans.
  • 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.all for independent work, Promise.allSettled when 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 in finally. Pair open with close; make close safe to call twice.
  • Validate external input once at the module boundary; trust it internally afterwards.

TypeScript

  • Enable strict. Never use any; take unknown and narrow. Give public functions explicit return types.
  • Use interface for extensible object shapes, type for 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 delete properties later (assign undefined).
  • 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, vm or dynamic import(); dispatch through an allowlisted object instead.
  • Run processes with execFile/spawn(file, args), never exec with an interpolated string.
  • Merge or set untrusted keys only through an allowlist; reject __proto__, constructor, prototype; use Map or Object.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, never Math.random.
  • Contain paths by canonicalizing both sides with fs.realpath, then reject when path.relative(base, target) is absolute or starts with ... String-prefix checks on path.resolve are 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.

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.