Skip to content
Back to skills

Javascript Best Practices

ASecurity

For a maintainable JavaScript implementation: - Use `camelCase` for variables and functions, `PascalCase` for classes, and `UPPER_SNAKE` for constants. - Keep one main entity per file. Put the public named exports in `index.js`, and order imports as external packages, internal modules, then relative modules. - Throw `Error` objects rather than strings, and handle rejected promises at the boundary that can recover or report them. - Add JSDoc to public APIs, explaining the reason for non-obviou...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentjavascriptjavaapi

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill javascript-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Javascript Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Javascript Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-javascript-best-practices-agent-skills-standard/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-javascript-best-practices-agent-skills-standard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
For a maintainable JavaScript implementation:

- Use `camelCase` for variables and functions, `PascalCase` for classes, and `UPPER_SNAKE` for constants.
- Keep one main entity per file. Put the public named exports in `index.js`, and order imports as external packages, internal modules, then relative modules.
- Throw `Error` objects rather than strings, and handle rejected promises at the boundary that can recover or report them.
- Add JSDoc to public APIs, explaining the reason for non-obvious decisions.
- Encapsulate mutable state, replace magic numbers with named `const` values, and use guard clauses to avoid deep nesting. Prefer pure functions with no hidden side effects.

Example:

```js
const MAX_RETRIES = 3;

/**
 * Retries an operation so transient failures do not fail the request immediately.
 * @param {() => Promise<unknown>} operation
 * @returns {Promise<unknown>}
 */
export async function retry(operation) {
  if (typeof operation !== 'function') {
    throw new Error('operation must be a function');
  }

  for (let attempt = 0; attempt < MAX_RETRIES; attempt += 1) {
    try {
      return await operation();
    } catch (error) {
      if (attempt === MAX_RETRIES - 1) {
        throw error instanceof Error ? error : new Error(String(error));
      }
    }
  }
}
```

Files in this skill

  • eval-1.baseline.md815 B
  • eval-1.with-skill.md1.3 KB
  • eval-2.baseline.md988 B
  • eval-2.with-skill.md1 KB
  • eval-3.baseline.md865 B
  • eval-3.with-skill.md1.1 KB
  • trigger-1.md149 B
  • trigger-2.md119 B
  • trigger-3.md111 B
  • trigger-4.md109 B
  • trigger-5.md99 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.