agentleFS
DulajDilDulajDil/claude-skills-manager/skills/airbnb-javascript-style/SKILL.md

airbnb-javascript-style

Skill1 starsChanged 20 days agoMITView on GitHub

Apply the Airbnb JavaScript/TypeScript style guide when writing, editing, or reviewing JS, JSX, TS, or TSX code — how to write comments (JSDoc for multiline, spacing rules, TODO/FIXME annotations) and the core coding conventions (const over let/var, arrow functions, destructuring, template strings, ES module import/export, camelCase/PascalCase naming, ===, etc.). Use this skill whenever you produce or modify JavaScript or TypeScript, add or reword code comments, do a code review of JS/TS, or the user mentions "Airbnb style", "our JS conventions", "best practices", a linter/eslint config, or asks that new code match the repo's existing style — even if they don't name the guide explicitly. Default to it for any non-trivial JS/TS authoring so the output matches a widely-used, lint-enforced standard.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If an existing file clearly follows a different convention (tabs, var, named function declarations everywhere), consistency within that …

    line 37
  2. Very specific:

    Start every comment with a space: after the // or * so it is readable: // is current tab, never //is current tab.

    line 104
  3. Distinctive:

    Destructure: when reading multiple properties off an object or elements off an array, and return an object (not a positional array) for …

    line 167
  4. Very specific:

    Always wrap arrow params in parentheses, even a single one: (x) => x * x.

    line 181
  5. Distinctive:

    Use an implicit return only for a single side-effect-free expression.

    line 182
  6. Very specific:

    Comparison — always === / !==: Use the boolean shortcut for actual booleans (if (isValid)) but explicit comparisons for strings and …

    line 209

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Airbnb JavaScript & TypeScript Style

This skill makes generated and edited JavaScript/TypeScript match the Airbnb JavaScript Style Guide — the de facto standard enforced by eslint-config-airbnb in a large share of professional codebases. Following it means the code reads the way the rest of such a project reads, and passes the linter without a round of fixups.

The guide has two halves that matter here: how to comment code, and how to write it. Comments come first because that is what most people reach for this skill to get right.

How to use this skill

Apply these conventions by default when authoring or editing .js, .jsx, .ts, or .tsx. The most-used rules are inline below; the references/ files hold the complete rule set with good/bad examples — read the relevant one when a situation is not covered here or when you need to justify a choice.

One judgment call worth making up front: match the file you are already in. If an existing file clearly follows a different convention (tabs, var, named function declarations everywhere), consistency within that file usually beats importing Airbnb style mid-file. Raise the mismatch rather than silently mixing two styles. When starting fresh, or when the user asks for Airbnb/"best practice" style, apply the guide fully.

Comments

The goal of a comment is to explain why, not to restate what the code already says. Prefer clear code and good names over comments that narrate obvious behavior.

Multiline comments use JSDoc-style /** ... */. This is what documents a function's purpose, parameters, and return value.

// good
/**
 * make() returns a new element
 * based on the passed-in tag name
 *
 * @param {string} tag
 * @return {Element} element
 */
function make(tag) {
  // ...
  return element;
}

// bad — a stack of // lines doing a doc comment's job
// make() returns a new element
// based on the passed-in tag name
//
// @param {string} tag
// @return {Element} element
function make(tag) {
  // ...
}

Single-line comments use //, placed on their own line above the code they describe, not trailing on the same line. Leave a blank line before the comment unless it is the first line of its block.

// good
// is current tab
const active = true;

function getType() {
  console.log('fetching type...');

  // set the default type to 'no type'
  const type = this.type || 'no type';
  return type;
}

function getType() {
  // the first line of a block needs no blank line above it
  const type = this.type || 'no type';
  return type;
}

// bad
const active = true; // is current tab

Start every comment with a space after the // or * so it is readable: // is current tab, never //is current tab.

Annotate with // TODO: and // FIXME: so problems and planned work are greppable. FIXME marks something wrong that needs revisiting; TODO marks a solution that still needs to be implemented.

class Calculator extends Abacus {
  constructor() {
    super();

    // FIXME: shouldn't use a global here
    total = 0;

    // TODO: total should be configurable by an options param
    this.total = 0;
  }
}

Full detail — including doc-comment conventions for TypeScript — is in references/comments.md.

Core coding conventions

These are the highest-leverage rules; they cover the large majority of real code. The complete set with reasoning and examples is in references/conventions.md, and TypeScript-specific guidance is in references/typescript.md.

References — const by default, let only to reassign, never var. const prevents accidental reassignment; both const and let are block-scoped, while var is function-scoped and error-prone.

// good
const a = 1;
let count = 1;
if (true) { count += 1; }

// bad
var a = 1;

Declare one variable per statement, and group consts before lets. It keeps diffs clean and makes it obvious which references are reassignable.

Objects and arrays — use literal syntax and modern shorthands. {} and [] over new Object()/new Array(); property/method shorthand; spread ({ ...a, c: 3 }, [...items]) over Object.assign and manual copies.

// good
const atom = {
  value,          // property shorthand, grouped first
  addValue(v) {   // method shorthand
    return atom.value + v;
  },
};
const copy = { ...original, c: 3 };

Destructure when reading multiple properties off an object or elements off an array, and return an object (not a positional array) for multiple return values so call sites are order-independent.

// good
function getFullName({ firstName, lastName }) {
  return `${firstName} ${lastName}`;
}
const [first, second] = arr;

Functions — prefer arrow functions for callbacks; use default params; never mutate or reassign parameters; use rest ...args instead of arguments. Always wrap arrow params in parentheses, even a single one: (x) => x * x. Use an implicit return only for a single side-effect-free expression.

// good
[1, 2, 3].map((x) => x * x);
function handleThings(opts = {}) { /* ... */ }
function concatenateAll(...args) { return args.join(''); }

// bad
[1, 2, 3].map(x => { x * x; });      // missing parens; body doesn't return
function handleThings(opts) { opts = opts || {}; }  // reassigns param

Strings — single quotes; template literals for interpolation and only for interpolation. `How are you, ${name}?` — never 'How are you, ' + name, and never a backtick string with no ${} in it.

Modules — use ES import/export, not require/module.exports. No wildcard imports, imports grouped at the top of the file, one import statement per path, and no file extensions in import paths (./foo, not ./foo.js).

Naming — camelCase for variables, functions, and instances; PascalCase for classes and constructors; UPPERCASE for exported constants. Acronyms stay fully uppercase (SMSContainer, HTTPRequests, not SmsContainer). Avoid single-letter names except short-lived loop/callback indices. A file's default export and its filename should match.

Comparison — always === / !==. Use the boolean shortcut for actual booleans (if (isValid)) but explicit comparisons for strings and numbers (if (name !== ''), if (collection.length > 0)). Prefer ?? over || when you specifically mean "null or undefined" rather than any falsy value. Don't nest ternaries.

Reference files

  • references/comments.md — the complete Comments section: JSDoc conventions, single-line spacing, TODO/FIXME, plus how doc comments work in TypeScript.
  • references/conventions.md — the full core rule set with good/bad examples: references, variables, objects, arrays, destructuring, strings, functions, arrow functions, modules, naming, and comparison operators.
  • references/typescript.md — how the guide maps to TypeScript: types vs JSDoc, interfaces/type aliases, enums, readonly, and what the JS rules mean when the language already gives you types.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.