Comprehensive JavaScript style and best practices guide based on Google's official JavaScript Style Guide, designed for AI agents and LLMs. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
Writing new JavaScript or ES6+ code
Structuring modules and managing imports/exports
Adding JSDoc type annotations and documentation
Reviewing code for naming and style consistency
Refactoring existing JavaScript code
Rule Categories by Priority
Priority
Category
Impact
Prefix
1
Module System & Imports
CRITICAL
module-
2
Language Features
CRITICAL
lang-
3
Type Safety & JSDoc
HIGH
type-
4
Naming Conventions
HIGH
naming-
5
Control Flow & Error Handling
MEDIUM-HIGH
control-
6
Functions & Parameters
MEDIUM
func-
7
Objects & Arrays
MEDIUM
data-
8
Formatting & Style
LOW
format-
Quick Reference
1. Module System & Imports (CRITICAL)
module-avoid-circular-dependencies - Prevent loading failures from circular imports
module-file-extension-in-imports - Include .js extension in import paths
module-named-exports-over-default - Prefer named exports for consistency
module-no-duplicate-imports - Import from same file only once
module-no-import-aliasing - Keep original export names
module-source-file-structure - Follow standard file structure order
2. Language Features (CRITICAL)
lang-const-over-let-over-var - Use const by default, never var
lang-es6-classes-over-prototypes - Use class syntax over prototype manipulation
lang-explicit-semicolons - Always use explicit semicolons
lang-no-eval - Never use eval or Function constructor
lang-no-modify-builtins - Never modify built-in prototypes
lang-no-non-standard-features - Use only standard ECMAScript features
lang-no-primitive-wrappers - Never use primitive wrapper objects
lang-no-with-statement - Never use the with statement
3. Type Safety & JSDoc (HIGH)
type-cast-with-parentheses - Use parentheses for type casts
type-enum-annotations - Annotate enums with static literal values
type-explicit-nullability - Use explicit nullability modifiers
type-jsdoc-required-for-exports - Require JSDoc for exported functions
func-arrow-functions-for-nested - Prefer arrow functions for nested functions
func-arrow-parentheses - Always use parentheses around arrow params
func-default-parameters - Use default parameters instead of conditionals
func-rest-parameters-over-arguments - Use rest parameters over arguments
func-spread-over-apply - Use spread operator instead of apply
7. Objects & Arrays (MEDIUM)
data-array-literals-over-constructor - Use array literals over Array constructor
data-destructuring-for-multiple-values - Use destructuring for multiple properties
data-no-mixing-quoted-unquoted-keys - Never mix quoted and unquoted keys
data-object-literals-over-constructor - Use object literals over constructor
data-spread-over-concat-slice - Use spread over concat and slice
data-trailing-commas - Use trailing commas in multi-line literals
8. Formatting & Style (LOW)
format-braces-required - Always use braces for control structures
format-column-limit - Limit lines to 80 characters
format-one-statement-per-line - Place one statement per line
format-single-quotes - Use single quotes for string literals
format-two-space-indent - Use two-space indentation
How to Use
Read individual reference files for detailed explanations and code examples:
Section definitions - Category structure and impact levels
Rule template - Template for adding new rules
Full Compiled Document
For a complete compiled guide with all rules, see AGENTS.md.
Reference Files
File
Description
AGENTS.md
Complete compiled guide with all rules
references/_sections.md
Category definitions and ordering
assets/templates/_template.md
Template for new rules
metadata.json
Version and reference information
1---2name: js-google3description: Google JavaScript Best Practices4---5# Google JavaScript Best Practices67Comprehensive JavaScript style and best practices guide based on Google's official JavaScript Style Guide, designed for AI agents and LLMs. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.89## When to Apply1011Reference these guidelines when:12- Writing new JavaScript or ES6+ code13- Structuring modules and managing imports/exports14- Adding JSDoc type annotations and documentation15- Reviewing code for naming and style consistency16- Refactoring existing JavaScript code1718## Rule Categories by Priority1920| Priority | Category | Impact | Prefix |21|----------|----------|--------|--------|22| 1 | Module System & Imports | CRITICAL | `module-` |23| 2 | Language Features | CRITICAL | `lang-` |24| 3 | Type Safety & JSDoc | HIGH | `type-` |25| 4 | Naming Conventions | HIGH | `naming-` |26| 5 | Control Flow & Error Handling | MEDIUM-HIGH | `control-` |27| 6 | Functions & Parameters | MEDIUM | `func-` |28| 7 | Objects & Arrays | MEDIUM | `data-` |29| 8 | Formatting & Style | LOW | `format-` |3031## Quick Reference3233### 1. Module System & Imports (CRITICAL)3435- [`module-avoid-circular-dependencies`](references/module-avoid-circular-dependencies.md) - Prevent loading failures from circular imports36- [`module-file-extension-in-imports`](references/module-file-extension-in-imports.md) - Include .js extension in import paths37- [`module-named-exports-over-default`](references/module-named-exports-over-default.md) - Prefer named exports for consistency38- [`module-no-duplicate-imports`](references/module-no-duplicate-imports.md) - Import from same file only once39- [`module-no-import-aliasing`](references/module-no-import-aliasing.md) - Keep original export names40- [`module-source-file-structure`](references/module-source-file-structure.md) - Follow standard file structure order4142### 2. Language Features (CRITICAL)4344- [`lang-const-over-let-over-var`](references/lang-const-over-let-over-var.md) - Use const by default, never var45- [`lang-es6-classes-over-prototypes`](references/lang-es6-classes-over-prototypes.md) - Use class syntax over prototype manipulation46- [`lang-explicit-semicolons`](references/lang-explicit-semicolons.md) - Always use explicit semicolons47- [`lang-no-eval`](references/lang-no-eval.md) - Never use eval or Function constructor48- [`lang-no-modify-builtins`](references/lang-no-modify-builtins.md) - Never modify built-in prototypes49- [`lang-no-non-standard-features`](references/lang-no-non-standard-features.md) - Use only standard ECMAScript features50- [`lang-no-primitive-wrappers`](references/lang-no-primitive-wrappers.md) - Never use primitive wrapper objects51- [`lang-no-with-statement`](references/lang-no-with-statement.md) - Never use the with statement5253### 3. Type Safety & JSDoc (HIGH)5455- [`type-cast-with-parentheses`](references/type-cast-with-parentheses.md) - Use parentheses for type casts56- [`type-enum-annotations`](references/type-enum-annotations.md) - Annotate enums with static literal values57- [`type-explicit-nullability`](references/type-explicit-nullability.md) - Use explicit nullability modifiers58- [`type-jsdoc-required-for-exports`](references/type-jsdoc-required-for-exports.md) - Require JSDoc for exported functions59- [`type-template-parameters`](references/type-template-parameters.md) - Always specify template parameters60- [`type-typedef-for-complex-types`](references/type-typedef-for-complex-types.md) - Use typedef for complex object types6162### 4. Naming Conventions (HIGH)6364- [`naming-constant-case-for-constants`](references/naming-constant-case-for-constants.md) - Use CONSTANT_CASE for immutable values65- [`naming-descriptive-over-brief`](references/naming-descriptive-over-brief.md) - Prefer descriptive names over brevity66- [`naming-file-naming-conventions`](references/naming-file-naming-conventions.md) - Use lowercase with dashes or underscores67- [`naming-lowercamelcase-for-methods`](references/naming-lowercamelcase-for-methods.md) - Use lowerCamelCase for methods and variables68- [`naming-no-dollar-prefix`](references/naming-no-dollar-prefix.md) - Avoid dollar sign prefix in identifiers69- [`naming-uppercamelcase-for-classes`](references/naming-uppercamelcase-for-classes.md) - Use UpperCamelCase for classes7071### 5. Control Flow & Error Handling (MEDIUM-HIGH)7273- [`control-comment-empty-catch`](references/control-comment-empty-catch.md) - Document empty catch blocks74- [`control-for-of-over-for-in`](references/control-for-of-over-for-in.md) - Prefer for-of over for-in75- [`control-strict-equality`](references/control-strict-equality.md) - Use strict equality except for null checks76- [`control-switch-default-last`](references/control-switch-default-last.md) - Always include default case in switch77- [`control-throw-error-objects`](references/control-throw-error-objects.md) - Always throw Error objects7879### 6. Functions & Parameters (MEDIUM)8081- [`func-arrow-functions-for-nested`](references/func-arrow-functions-for-nested.md) - Prefer arrow functions for nested functions82- [`func-arrow-parentheses`](references/func-arrow-parentheses.md) - Always use parentheses around arrow params83- [`func-default-parameters`](references/func-default-parameters.md) - Use default parameters instead of conditionals84- [`func-rest-parameters-over-arguments`](references/func-rest-parameters-over-arguments.md) - Use rest parameters over arguments85- [`func-spread-over-apply`](references/func-spread-over-apply.md) - Use spread operator instead of apply8687### 7. Objects & Arrays (MEDIUM)8889- [`data-array-literals-over-constructor`](references/data-array-literals-over-constructor.md) - Use array literals over Array constructor90- [`data-destructuring-for-multiple-values`](references/data-destructuring-for-multiple-values.md) - Use destructuring for multiple properties91- [`data-no-mixing-quoted-unquoted-keys`](references/data-no-mixing-quoted-unquoted-keys.md) - Never mix quoted and unquoted keys92- [`data-object-literals-over-constructor`](references/data-object-literals-over-constructor.md) - Use object literals over constructor93- [`data-spread-over-concat-slice`](references/data-spread-over-concat-slice.md) - Use spread over concat and slice94- [`data-trailing-commas`](references/data-trailing-commas.md) - Use trailing commas in multi-line literals9596### 8. Formatting & Style (LOW)9798- [`format-braces-required`](references/format-braces-required.md) - Always use braces for control structures99- [`format-column-limit`](references/format-column-limit.md) - Limit lines to 80 characters100- [`format-one-statement-per-line`](references/format-one-statement-per-line.md) - Place one statement per line101- [`format-single-quotes`](references/format-single-quotes.md) - Use single quotes for string literals102- [`format-two-space-indent`](references/format-two-space-indent.md) - Use two-space indentation103104## How to Use105106Read individual reference files for detailed explanations and code examples:107108- [Section definitions](references/_sections.md) - Category structure and impact levels109- [Rule template](assets/templates/_template.md) - Template for adding new rules110111## Full Compiled Document112113For a complete compiled guide with all rules, see [AGENTS.md](AGENTS.md).114115## Reference Files116117| File | Description |118|------|-------------|119| [AGENTS.md](AGENTS.md) | Complete compiled guide with all rules |120| [references/_sections.md](references/_sections.md) | Category definitions and ordering |121| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |122| [metadata.json](metadata.json) | Version and reference information |
Run npx skillmds@latest add comeonoliver/js-google in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Google JavaScript Best Practices It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.