
Modern Javascript Patterns
Give your coding agent a reference playbook for ES6+ syntax, async flows, and functional patterns when you modernize legacy JavaScript or tighten app code.
Overview
Modern JavaScript Patterns is an agent skill most often used in Build (also Ship perf and review-driven refactors) that teaches ES6+ and functional JavaScript patterns for cleaner, maintainable application code.
Install
npx skills add https://github.com/wshobson/agents --skill modern-javascript-patternsWhat is this skill?
- Covers ES6+ pillars: arrow functions, destructuring, spread, modules, iterators, and generators
- Documents Promise chains, async/await, and migration paths off callback-style code
- Includes functional patterns for data transformation and composition
- Aimed at readability, maintainability, and performance-minded refactors
- Use triggers include legacy refactors, async UX, and pipeline-style transforms
Adoption & trust: 13.9k installs on skills.sh; 36.5k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your codebase still mixes callbacks, unclear async, and pre-ES6 habits, and you need an agent to refactor and extend JavaScript without introducing inconsistent modern syntax.
Who is it for?
Solo builders modernizing legacy front-end or Node-adjacent JavaScript, standardizing async code, or asking an agent to implement transforms and small utilities with current syntax.
Skip if: Greenfield projects already locked to Type-only stacks where the agent should follow project types-first rules instead of broad JS pattern tutoring, or pure non-JavaScript backends with no JS surface.
When should I use this skill?
Refactoring legacy JavaScript to modern syntax, implementing functional programming patterns, optimizing JavaScript performance, working with asynchronous operations, or migrating from callbacks to Promises/async-await.
What do I get? / Deliverables
The agent applies documented ES6+ and functional patterns so new and refactored JavaScript reads consistently and handles asynchronous work with Promises or async/await.
- Refactored modules using ES6+ syntax
- Async flows implemented with Promises or async/await
- Composable transformation helpers aligned with documented patterns
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is Build because the skill’s core job is authoring and restructuring application JavaScript, not shipping gates or growth loops. Frontend is the default home for modern JS pattern work even when some examples touch Node-style modules.
Where it fits
Implement a React hook that fetches and normalizes API data using destructuring, spread, and async/await.
Refactor an Express route handler from nested callbacks to async/await with clear error propagation.
Rewrite a hot loop to use immutable updates and functional transforms without accidental mutation bugs.
Align a PR’s JavaScript style with documented module and Promise patterns before merge.
How it compares
Use as a procedural pattern reference during coding, not as a test runner or linter replacement.
Common Questions / FAQ
Who is modern-javascript-patterns for?
Indie and solo developers shipping web or extension code in JavaScript who want their agent to follow ES6+ and functional conventions during implementation and refactors.
When should I use modern-javascript-patterns?
During Build when writing or refactoring UI and client logic; during Ship when optimizing or cleaning up JavaScript after review; whenever you migrate callbacks to Promises or async/await or build data transformation pipelines.
Is modern-javascript-patterns safe to install?
It is instructional documentation for the agent with no built-in shell or network requirements in the skill itself; review the Security Audits panel on this Prism page before adding any repo skill to your agent.
SKILL.md
READMESKILL.md - Modern Javascript Patterns
# Modern JavaScript Patterns Comprehensive guide for mastering modern JavaScript (ES6+) features, functional programming patterns, and best practices for writing clean, maintainable, and performant code. ## When to Use This Skill - Refactoring legacy JavaScript to modern syntax - Implementing functional programming patterns - Optimizing JavaScript performance - Writing maintainable and readable code - Working with asynchronous operations - Building modern web applications - Migrating from callbacks to Promises/async-await - Implementing data transformation pipelines ## ES6+ Core Features ### 1. Arrow Functions **Syntax and Use Cases:** ```javascript // Traditional function function add(a, b) { return a + b; } // Arrow function const add = (a, b) => a + b; // Single parameter (parentheses optional) const double = (x) => x * 2; // No parameters const getRandom = () => Math.random(); // Multiple statements (need curly braces) const processUser = (user) => { const normalized = user.name.toLowerCase(); return { ...user, name: normalized }; }; // Returning objects (wrap in parentheses) const createUser = (name, age) => ({ name, age }); ``` **Lexical 'this' Binding:** ```javascript class Counter { constructor() { this.count = 0; } // Arrow function preserves 'this' context increment = () => { this.count++; }; // Traditional function loses 'this' in callbacks incrementTraditional() { setTimeout(function () { this.count++; // 'this' is undefined }, 1000); } // Arrow function maintains 'this' incrementArrow() { setTimeout(() => { this.count++; // 'this' refers to Counter instance }, 1000); } } ``` ### 2. Destructuring **Object Destructuring:** ```javascript const user = { id: 1, name: "John Doe", email: "john@example.com", address: { city: "New York", country: "USA", }, }; // Basic destructuring const { name, email } = user; // Rename variables const { name: userName, email: userEmail } = user; // Default values const { age = 25 } = user; // Nested destructuring const { address: { city, country }, } = user; // Rest operator const { id, ...userWithoutId } = user; // Function parameters function greet({ name, age = 18 }) { console.log(`Hello ${name}, you are ${age}`); } greet(user); ``` **Array Destructuring:** ```javascript const numbers = [1, 2, 3, 4, 5]; // Basic destructuring const [first, second] = numbers; // Skip elements const [, , third] = numbers; // Rest operator const [head, ...tail] = numbers; // Swapping variables let a = 1, b = 2; [a, b] = [b, a]; // Function return values function getCoordinates() { return [10, 20]; } const [x, y] = getCoordinates(); // Default values const [one, two, three = 0] = [1, 2]; ``` ### 3. Spread and Rest Operators **Spread Operator:** ```javascript // Array spreading const arr1 = [1, 2, 3]; const arr2 = [4, 5, 6]; const combined = [...arr1, ...arr2]; // Object spreading const defaults = { theme: "dark", lang: "en" }; const userPrefs = { theme: "light" }; const settings = { ...defaults, ...userPrefs }; // Function arguments const numbers = [1, 2, 3]; Math.max(...numbers); // Copying arrays/objects (shallow copy) const copy = [...arr1]; const objCopy = { ...user }; // Adding items immutably const newArr = [...arr1, 4, 5]; const newObj = { ...user, age: 30 }; ``` **Rest Parameters:** ```javascript // Collect function arguments function sum(...numbers) { return numbers.reduce((total, num) => total + num, 0); } sum(1, 2, 3, 4, 5); // With regular parameters function greet(greeting, ...names) { re