js-best-practices
Installation
SKILL.md
JavaScript & TypeScript Best Practices
You already know JS and TS, so skip generic advice. This skill only records the rules that are easy to get wrong. It sits on top of the core principles; it doesn't repeat them.
Setup (keep it cheap)
- Core principles: if
references/coding-principles-and-best-practices/SKILL.mdisn't already in this conversation, read it once. It defines precedence, the conflict ranking, the writing workflow and when to ask, the general checklist, Git review scope and the review format. Don't re-read it on later invocations in the same conversation. - Project profile: run
node <folder-containing-this-SKILL.md>/scripts/js-profile.mjs <dir-of-the-file-you're-working-on>. It prints the cached profile from<projectRoot>/.agents/js-project-profile.md, and only re-inspects the config (package.json, tsconfig, lint/test config) when that config has changed. Use the printed profile instead of opening those files yourself. Skip this step if the profile is already in this conversation and you haven't changed any config.- In a monorepo each package gets its own profile; the package manager, shared tooling and root scripts come from the workspace root.
- "No package.json found" → it's a standalone snippet; state your assumptions (runtime, ESM/CJS, TS or not).
- Node unavailable → read package.json and tsconfig directly, once.
- Learn as you go: when you discover a convention the config can't show (folder layering, error model, naming, test style) or the user corrects you, add one short bullet under
## Learned conventionsin the profile. Keep that section under ~15 lines; it's read on every invocation. If the code contradicts a bullet, the code wins: fix or remove the bullet.
The profile file is meant to be committed, so the team shares the learned conventions.
The profile decides syntax availability (target/engines), module system, which libraries to reuse and which commands to verify with.