agentleFS
amirrezaalastiamirrezaalasti/codescribe/skills/coding/javascript-best-practices/SKILL.md

javascript-best-practices

Skill2 starsChanged 4 months agoMITView on GitHub

Write modern JavaScript with ESM, clear async flows, and solid module boundaries for Node and the browser. Use when writing or reviewing JavaScript, Node scripts, frontend JS without TypeScript, or when the user asks for JS style, async/await, or module structure.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Async done right: Prefer async/await. Use Promise.all for independent work.

    line 31
  2. Very specific:

    Immutability by default: Prefer const; avoid mutating shared objects unexpectedly.

    line 32
  3. Distinctive:

    Node vs browser: Do not import Node-only APIs into browser bundles (and vice versa) without an explicit boundary.

    line 35
  4. Very specific:

    Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …).

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

JavaScript Best Practices

Defaults

ConcernDefault
ModulesESM (import/export) unless the repo is CommonJS
Asyncasync/await; avoid mixed callback + promise styles
Equality=== / !==
Lint/formatProject ESLint + Prettier (or whatever is already configured)
RuntimeMatch engines / Node LTS used by the repo

Instructions

  1. Follow the repo. Respect existing module system, bundler, and lint rules.
  2. Small modules with clear exports. One primary responsibility per file; named exports for libraries, default export only when the project convention requires it.
  3. Async done right. Prefer async/await. Use Promise.all for independent work; never leave floating promises without handling. Propagate errors or handle at the boundary.
  4. Immutability by default. Prefer const; avoid mutating shared objects unexpectedly. Use structured cloning / spreads when updating state-like data.
  5. Validate at edges. Parse and validate external input (HTTP, CLI, env) before use.
  6. Avoid magic. Named constants over unexplained numbers/strings; no deep optional chaining chains that hide bugs (a?.b?.c?.d).
  7. Node vs browser. Do not import Node-only APIs into browser bundles (and vice versa) without an explicit boundary.
  8. Tag unfinished or risky work. Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …). Never leave silent stubs. End with an Open follow-ups table so the developer must check P0/P1 before ship.

Error handling

async function loadUser(id) {
  const res = await fetch(`/api/users/${id}`);
  if (!res.ok) {
    throw new Error(`loadUser failed: ${res.status}`);
  }
  return res.json();
}

Anti-patterns

  • Mixing then chains with async/await in the same flow without reason
  • Swallowing errors in empty catch
  • Relying on == coercion
  • Giant god-files with unrelated helpers
  • Silent console.log debugging left in production paths

Additional resources

  • references/checklist.md

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.