JA

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.zip

Installs 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.
68 charsno explicit “when” trigger
Beginner

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

You give it
JavaScript source code
You get back
Idiomatic, maintainable code structure

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 Error objects only. Handle all async errors.
  • Comments: JSDoc for APIs. Explain "why" not "what".
  • Files: One entity per file. index.js for 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.

SkillInstallsUpdatedSafetyDifficulty
JavaScript Best Practices (this skill)06moNo flagsBeginner
dependency-upgrade265moReviewIntermediate
typescript-review392moNo flagsIntermediate
accessibility-compliance452moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

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.

26240

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.

39178

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.

45132

typescript-write

metabase

Write TypeScript and JavaScript code following Metabase coding standards and best practices. Use when developing or refactoring TypeScript/JavaScript code.

30114

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.

11106

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.

589

Search skills

Search the agent skills registry