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.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- debuggingSkill
- nextjs-app-routerSkill
- nextjs-data-fetchingSkill
- python-best-practicesSkill
- python-testingSkill
- react-best-practicesSkill
- tagged-code-commentsSkill
- typescript-best-practicesSkill
- create-skillSkill
- revise-skillSkill
- academic-paperSkill
- latex-scientific-writingSkill
- paper-abstractSkill
- paper-conclusionSkill
- paper-discussionSkill
- paper-introductionSkill
- paper-literature-reviewSkill
- paper-methodsSkill
- paper-peer-reviewSkill
- paper-related-workSkill
- paper-resultsSkill
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
- Very specific: line 31
Async done right: Prefer async/await. Use Promise.all for independent work.
- Very specific: line 32
Immutability by default: Prefer const; avoid mutating shared objects unexpectedly.
- Distinctive: line 35
Node vs browser: Do not import Node-only APIs into browser bundles (and vice versa) without an explicit boundary.
- Very specific: line 36
Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …).
≈ “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.
Files
JavaScript Best Practices
Defaults
| Concern | Default |
| Modules | ESM (import/export) unless the repo is CommonJS |
| Async | async/await; avoid mixed callback + promise styles |
| Equality | === / !== |
| Lint/format | Project ESLint + Prettier (or whatever is already configured) |
| Runtime | Match engines / Node LTS used by the repo |
Instructions
- Follow the repo. Respect existing module system, bundler, and lint rules.
- Small modules with clear exports. One primary responsibility per file; named exports for libraries, default export only when the project convention requires it.
- Async done right. Prefer
async/await. UsePromise.allfor independent work; never leave floating promises without handling. Propagate errors or handle at the boundary. - Immutability by default. Prefer
const; avoid mutating shared objects unexpectedly. Use structured cloning / spreads when updating state-like data. - Validate at edges. Parse and validate external input (HTTP, CLI, env) before use.
- Avoid magic. Named constants over unexplained numbers/strings; no deep optional chaining chains that hide bugs (
a?.b?.c?.d). - Node vs browser. Do not import Node-only APIs into browser bundles (and vice versa) without an explicit boundary.
- Tag unfinished or risky work. Use the global
tagged-code-commentsconvention (🔴 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
thenchains withasync/awaitin the same flow without reason - Swallowing errors in empty
catch - Relying on
==coercion - Giant god-files with unrelated helpers
- Silent
console.logdebugging left in production paths
Additional resources
- references/checklist.md
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.

