JavaScript Best Practices
A guide for idiomatic JavaScript patterns focusing on maintainability and quality.
Install
mkdir -p .claude/skills/javascript-best-practices && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10150" && unzip -o skill.zip -d .claude/skills/javascript-best-practices && rm skill.zipInstalls to .claude/skills/javascript-best-practices
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Idiomatic JavaScript patterns and conventions for maintainable code.Key capabilities
- →Standardize naming conventions
- →Enforce error handling
- →Implement modular exports
- →Apply JSDoc standards
How it works
Defines strict patterns for naming, module exports, and error management to ensure encapsulation and purity.
Inputs & outputs
When to use JavaScript Best Practices
- →Review JavaScript code quality
- →Standardize error handling in async code
- →Enforce JSDoc documentation standards
- →Implement modular code structures
About this skill
JavaScript Best Practices
Priority: P1 (OPERATIONAL)
Conventions and patterns for writing maintainable JavaScript.
Implementation Guidelines
- Naming:
camelCase(vars/funcs),PascalCase(classes),UPPER_SNAKE(constants). - Errors: Throw
Errorobjects only. Handle all async errors. - Comments: JSDoc for APIs. Explain "why" not "what".
- Files: One entity per file.
index.jsfor exports. - Modules: Named exports only. Order: Ext -> Int -> Rel.
Anti-Patterns
- No Globals: Encapsulate state.
- No Magic Numbers: Use
const. - No Nesting: Guard clauses/early returns.
- No Defaults: Use named exports.
- No Side Effects: Keep functions pure.
Code
// Constants
const STATUS = { OK: 200, ERROR: 500 };
// Errors
class APIError extends Error {
constructor(msg, code) {
super(msg);
this.code = code;
}
}
// Async + JDoc
/** @throws {APIError} */
export async function getData(id) {
if (!id) throw new APIError('Missing ID', 400);
const res = await fetch(`/api/${id}`);
if (!res.ok) throw new APIError('Failed', res.status);
return res.json();
}
Reference & Examples
For module patterns and project structure: See references/REFERENCE.md.
Related Topics
language | tooling
When not to use it
- →Legacy codebases with conflicting styles
Limitations
- →Requires strict adherence to patterns
How it compares
It mandates early returns and pure functions as core constraints rather than optional style suggestions.
Compared to similar skills
JavaScript Best Practices side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| JavaScript Best Practices (this skill) | 0 | 6mo | No flags | Beginner |
| dependency-upgrade | 26 | 5mo | Review | Intermediate |
| typescript-review | 39 | 2mo | No flags | Intermediate |
| accessibility-compliance | 45 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by HoangNguyen0403
View all by HoangNguyen0403 →You might also like
dependency-upgrade
wshobson
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
typescript-review
metabase
Review TypeScript and JavaScript code changes for compliance with Metabase coding standards, style violations, and code quality issues. Use when reviewing pull requests or diffs containing TypeScript/JavaScript code.
accessibility-compliance
wshobson
Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.
typescript-write
metabase
Write TypeScript and JavaScript code following Metabase coding standards and best practices. Use when developing or refactoring TypeScript/JavaScript code.
reviewing-nextjs-16-patterns
djankies
Review code for Next.js 16 compliance - security patterns, caching, breaking changes. Use when reviewing Next.js code, preparing for migration, or auditing for violations.
validate-typescript
BerryKuipers
Run TypeScript compiler type-checking (tsc --noEmit) to validate type safety and catch type errors. Works with any TypeScript project. Returns structured output with error counts, categories (type/syntax/import errors), and affected files. Used for quality gates and pre-commit validation.