javascript-language-patterns
Modern JavaScript (ES2022+) patterns for clean, maintainable code.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
JavaScript Language Patterns
Priority: P0 (CRITICAL)
Modern JavaScript standards for clean, maintainable code.
Implementation Guidelines
-
Variables:
constdefault.letif needed. Novar. - Functions: Arrows for callbacks. Declarations for top-level.
-
Async:
async/await+try/catch. -
Objects: Destructuring, Spread
..., Optional Chain?., Nullish??. -
Strings: Template literals
${}. -
Arrays:
map,filter,reduce. No loops. -
Modules: ESM
import/export. Export only what is necessary. -
Classes: Use
#privatefields for true privacy.
Anti-Patterns
-
No
var: Block scope only. -
No
==: Strict===. -
No
new Object(): Use literals{}. - No Callbacks: Promisify everything.
- No Mutation: Immutability first.
Code
// Modern Syntax
const [x, ...rest] = items;
const name = user?.profile?.name ?? 'Guest';
// Async
async function getUser(id) {
try {
const res = await fetch(`/api/${id}`);
return res.json();
} catch (err) {
console.error(err);
throw err;
}
}
// Class + Private
class Service {
#key;
constructor(k) {
this.#key = k;
}
}
Reference & Examples
For advanced patterns and functional programming: See references/REFERENCE.md.
Related Topics
best-practices | tooling
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!