agentleFS
metarhiametarhia/metaskills/skills/js-conventions/SKILL.md

js-conventions

Skill57 starsChanged 9 months agoMITView on GitHub

Apply Metarhia JavaScript style. Use when writing or editing .js, .mjs, .ts files (with certain corrections for typescript), formatting code, or when the user asks about code style or linting.

The file

Show its rules and text

We split this skill into the rules it gives an agent

45 rules. About 0 are common, 21 are distinctive, and 24 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 24

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use following conventions for JavaScript and TypeScript code.

    line 8
  2. Very specific:

    Add to dev dependencies in package.json if not added:

    line 12
  3. Very specific:

    Add scripts in package.json if not added:

    line 15
  4. Very specific:

    Before and after code analysis with AI run npm run lint and npm t

    line 18
  5. Very specific:

    Use npm run fix if errors/warnings detected to auto-fix when possible

    line 19
  6. Distinctive:

    Use single quotes and semicolons

    line 23
  7. Distinctive:

    Keep max line length 80 (ignore URLs)

    line 24
  8. Distinctive:

    Use trailing commas in multiline arrays, objects, and params

    line 25
  9. Distinctive:

    Keep one empty line between semantic blocks

    line 26
  10. Distinctive:

    Follow Prettier and eslint-config-metarhia for spacing, braces, and indentation

    line 27
  11. Very specific:

    Use camelCase for variables and parameters

    line 31
  12. Very specific:

    Use UpperCamelCase for classes and types

    line 32
  13. Very specific:

    Use UPPER_SNAKE_CASE for constants

    line 33
  14. Very specific:

    Use new with capitalized constructor names

    line 34
  15. Very specific:

    Use error in catch blocks, not err

    line 35
  16. Very specific:

    Use short names (e, i) only in short one-line callbacks

    line 36
  17. Very specific:

    Use descriptive names in multiline callbacks (event, index, item)

    line 37
  18. Very specific:

    Use boolean prefixes: is, has, can, should

    line 38
  19. Distinctive:

    Use singular names for entities and plural names for collections

    line 39
  20. Very specific:

    Use verb names for functions and handlers (parse, create, handle, on)

    line 40
  21. Very specific:

    Prefer const, minimize let, never use var

    line 45
  22. Distinctive:

    Prefer arrow functions (except prototype/class methods)

    line 46
  23. Very specific:

    Do not mutate input parameters.

    line 47
  24. Distinctive:

    Keep functions small and single-purpose

    line 48
  25. Very specific:

    Prefer explicit loops (for, for..of) in hot paths

    line 50
  26. Distinctive:

    Use array methods when they improve readability

    line 51
  27. Very specific:

    Use === and !== only

    line 52
  28. Distinctive:

    Keep return types consistent

    line 53
  29. Distinctive:

    Avoid nested ternaries and deep callback nesting

    line 54
  30. Very specific:

    Use iteration methods like .map, .filter, .reduce if it is good for code semantic

    line 57
  31. Distinctive:

    Keep object shapes stable: same keys, types, and key order

    line 62
  32. Distinctive:

    Use shape mutations only for metaprogramming

    line 64
  33. Very specific:

    Use null for empty reference types.

    line 65
  34. Distinctive:

    Avoid array destructuring in assignments and loops.

    line 66
  35. Distinctive:

    Keep hot functions monomorphic: stable arg count, types, and return types

    line 67
  36. Distinctive:

    Avoid reading the same property from many unrelated object shapes

    line 68
  37. Distinctive:

    Prefer string or number literals for status/codes.

    line 69
  38. Distinctive:

    Keep objects that share a property to the same shape.

    line 70
  39. Very specific:

    Prefer fixed property access (obj.x) over dynamic keys (obj[key])

    line 71
  40. Distinctive:

    Keep arrays dense, avoid holes and mixed element kinds

    line 72
  41. Very specific:

    Keep try/catch, spread/rest away from hot loops

    line 76
  42. Very specific:

    Use Map for dynamic key dictionaries, plain objects for fixed schemas

    line 77
  43. Very specific:

    Use Set for big and dynamic collections, prefer arrays for short and stable

    line 78
  44. Very specific:

    Use Object.create(null) for pure dictionaries

    line 79
  45. Distinctive:

    Use typed arrays for numeric and binary workloads

    line 80

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

JavaScript Code Style

Use following conventions for JavaScript and TypeScript code.

Preparations

  • Add to dev dependencies in package.json if not added:
    • eslint-config-metarhia
    • eslint, prettier
  • Add scripts in package.json if not added:
    • "lint": "eslint . && prettier --check "/*.js" "/.json" "**/.md" "*/.ts""
    • "fix": "eslint . --fix && prettier --write "/*.js" "/.json" "**/.md" "*/.ts""
  • Before and after code analysis with AI run npm run lint and npm t
  • Use npm run fix if errors/warnings detected to auto-fix when possible

Formatting

  • Use single quotes and semicolons
  • Keep max line length 80 (ignore URLs)
  • Use trailing commas in multiline arrays, objects, and params
  • Keep one empty line between semantic blocks
  • Follow Prettier and eslint-config-metarhia for spacing, braces, and indentation

Naming

  • Use camelCase for variables and parameters
  • Use UpperCamelCase for classes and types
  • Use UPPER_SNAKE_CASE for constants
  • Use new with capitalized constructor names
  • Use error in catch blocks, not err
  • Use short names (e, i) only in short one-line callbacks
  • Use descriptive names in multiline callbacks (event, index, item)
  • Use boolean prefixes: is, has, can, should
  • Use singular names for entities and plural names for collections
  • Use verb names for functions and handlers (parse, create, handle, on)
  • Include units in numeric names (timeoutMs, sizeBytes) except options

Best practices

  • Prefer const, minimize let, never use var
  • Prefer arrow functions (except prototype/class methods)
  • Do not mutate input parameters; avoid arguments
  • Keep functions small and single-purpose
  • Decompose long expressions into intermediate variables
  • Prefer explicit loops (for, for..of) in hot paths
  • Use array methods when they improve readability
  • Use === and !== only
  • Keep return types consistent
  • Avoid nested ternaries and deep callback nesting
  • Self-documented and self-descriptive code: do not add obvious comments, code should be clear without comments
  • Use iteration methods like .map, .filter, .reduce if it is good for code semantic
  • Try to avoid .forEach if callback operates with outer context

Optimizations

  • Keep object shapes stable: same keys, types, and key order
  • Change shape only in constructors and creational patterns; avoid mix-ins
  • Use shape mutations only for metaprogramming
  • Use null for empty reference types; use undefined for empty primitives
  • Avoid array destructuring in assignments and loops; object destructuring is ok
  • Keep hot functions monomorphic: stable arg count, types, and return types
  • Avoid reading the same property from many unrelated object shapes
  • Prefer string or number literals for status/codes; avoid mixing primitives with objects in one variable
  • Keep objects that share a property to the same shape; avoid polymorphic hotspots
  • Prefer fixed property access (obj.x) over dynamic keys (obj[key])
  • Keep arrays dense, avoid holes and mixed element kinds
  • Initialize object fields in constructor/factory once and in one order
  • Set field to null or undefined; avoid delete
  • Move reusable callbacks outside loops
  • Keep try/catch, spread/rest away from hot loops
  • Use Map for dynamic key dictionaries, plain objects for fixed schemas
  • Use Set for big and dynamic collections, prefer arrays for short and stable
  • Use Object.create(null) for pure dictionaries
  • Use typed arrays for numeric and binary workloads
  • Reduce GC pressure: reuse arrays, objects, and buffers when safe

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.