Agent skill
js-modern
Write modern JavaScript and TypeScript — ES6+ features, async/await, modules, destructuring, optional chaining, TypeScript types, and modern tooling. Use when writing JavaScript/TypeScript for BigCommerce themes, apps, or headless storefronts.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/js-modern
SKILL.md
Modern JavaScript & TypeScript
Before writing code
Fetch live docs: Web-search site:developer.mozilla.org javascript for MDN JavaScript reference. Check https://www.typescriptlang.org/docs/ for TypeScript documentation.
ES6+ Features
Arrow Functions
Concise function syntax with lexical this:
const add = (a, b) => a + b;- Implicit return for single expressions
- No own
this,arguments,super, ornew.target
Template Literals
String interpolation and multi-line strings:
`Hello, ${name}!`- Tagged templates for DSLs
Destructuring
Extract values from objects/arrays:
const { name, price } = product;const [first, ...rest] = items;- Default values:
const { name = 'Unknown' } = product; - Nested:
const { address: { city } } = customer;
Spread / Rest
- Spread:
[...arr1, ...arr2],{ ...obj1, ...obj2 } - Rest:
function(...args) {},const { a, ...rest } = obj;
Modules (ES Modules)
import { func } from './module.js';export const value = 42;/export default class {}- Dynamic:
const mod = await import('./lazy.js');
Optional Chaining & Nullish Coalescing
obj?.property?.nested— short-circuits toundefinedif any part is nullishvalue ?? defaultValue— returns right side only if left isnull/undefined(not falsy)
Async Patterns
Promises
new Promise((resolve, reject) => { ... }).then(),.catch(),.finally()Promise.all(),Promise.allSettled(),Promise.race(),Promise.any()
Async/Await
async function fetchData() { const data = await fetch(url); }- Error handling with try/catch
- Parallel:
const [a, b] = await Promise.all([fetchA(), fetchB()]);
Fetch API
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
const result = await response.json();
TypeScript
Type Annotations
let name: string = 'Product';function getPrice(id: number): Promise<number> { ... }const product: Product = { ... };
Interfaces
interface Product {
id: number;
name: string;
price: number;
variants?: Variant[];
}
Type Utilities
Partial<T>— all properties optionalRequired<T>— all properties requiredPick<T, K>— subset of propertiesOmit<T, K>— exclude propertiesRecord<K, V>— key-value mappingReturnType<T>— extract return type of function
Generics
function fetchResource<T>(url: string): Promise<T> {
return fetch(url).then(res => res.json());
}
const product = await fetchResource<Product>('/api/products/1');
Enums
enum OrderStatus {
Pending = 'pending',
Shipped = 'shipped',
Completed = 'completed',
}
Discriminated Unions
type ApiResponse<T> =
| { status: 'success'; data: T }
| { status: 'error'; message: string };
Modern Array Methods
map,filter,reduce,find,findIndexsome,every— boolean checksflat,flatMap— array flatteningArray.from(),Array.isArray()Object.entries(),Object.fromEntries(),Object.keys(),Object.values()structuredClone()— deep clone
For BigCommerce Specifically
Stencil Theme JS
- ES6 modules bundled with webpack
- jQuery available (Cornerstone ships it)
- Use
PageManagerlifecycle for page-specific code - Access injected server data via
this.context
Catalyst / Next.js
- TypeScript by default
- React components with hooks
- Server Components + Client Components
- Type-safe GraphQL queries
App Development
- Node.js backend with Express/Fastify
- TypeScript for API type safety
- JWT handling with
jsonwebtokenlibrary
Best Practices
- Use
constby default,letwhen reassignment is needed, nevervar - Use async/await over raw Promises for readability
- Use TypeScript for all non-trivial projects
- Use optional chaining to simplify null checks
- Use destructuring for cleaner function signatures
- Handle errors at appropriate levels (don't swallow errors)
- Use
===instead of==for comparisons - Use ESLint + Prettier for consistent code style
Fetch MDN and TypeScript docs for exact syntax, browser compatibility, and new features before implementing.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?