Skip to main content
skill CX Codex

javascript-expert · personamanagmentlayer — Claude Code skill: what it does, how to install

javascript-expert — a skill that makes the assistant work as a seasoned JavaScript developer across ES2024+, Node.js and npm, so the code it writes stays in one style.

Apache-2.0 197 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill javascript-expert -a claude-code
Open on GitHub

What javascript-expert does

The skill frames the assistant as a JavaScript developer fluent in ES2024+, Node.js and the npm ecosystem. What it actually carries is a set of code patterns. Custom error classes, and a Result object for the cases where throwing gets in the way. Immutable updates written with pipe and currying. Parallel calls through Promise.all where a failed request falls back to an empty array, a timeout wrapper around Promise.race, a retry helper.

Style rules arrive as a numbered list: strict mode, const and let over var, arrow callbacks, template literals, destructuring, default parameters. One class example shows private #listeners fields on an EventEmitter, with an unsubscribe function returned from on.

Tool access stays narrow. The skill may read, write and edit files, glob and grep the project, and call Bash only for node, npm, npx, bun and deno, so arbitrary shell commands are out of reach. It expects node >=18.0.0 and npm >=8.0.0; the fetch samples lean on a runtime that ships it globally.

What it helps with

  • swap thrown exceptions for custom error classes and a Result object
  • turn mutating helpers into pure functions with pipe and currying
  • run several requests in parallel with a timeout and retries
  • move a class from closures to private # fields
  • strip var and string concatenation out of a legacy file

Example prompts for the agent

  • Refactor orders.js to use const and template literals, no var.
  • Write fetchAll() with Promise.all so a failing request returns an empty array.
  • Rewrite this EventEmitter class with a private #listeners field and an unsubscribe function.

How to install javascript-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill javascript-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/javascript-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/javascript-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about javascript-expert

How do I install javascript-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill javascript-expert -a claude-code. The skill lands at ~/.claude/skills/javascript-expert/SKILL.md.

What does javascript-expert do?

It gives the agent a JavaScript developer role plus worked patterns for error handling, functional style, async code and classes with private fields, along with a list of style rules.

Which Node.js and npm versions does it need?

Requirements are node >=18.0.0 and npm >=8.0.0. On an older runtime some of the fetch examples will not run.

Source text

SKILL.md · Apache-2.0
---
name: javascript-expert
version: 1.1.0
description: >-
  Expert-level JavaScript development with modern ES2024+ features, Node.js, npm ecosystem,
  and best practices. Use when the user mentions ECMAScript, ES2024, Node.js, npm, or web,
  or when the task involves Modern JavaScript, Node.js Development, Modern Tooling, or
  Functional Programming.
category: languages
author: PCL Team
license: Apache-2.0
tags:
  - javascript
  - js
  - ecmascript
  - es2024
  - node
  - npm
  - web
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(node:*, npm:*, npx:*, bun:*, deno:*)
  - Glob
  - Grep
requirements:
  node: '>=18.0.0'
  npm: '>=8.0.0'
---

# JavaScript Expert

You are an expert JavaScript developer with deep knowledge of modern ECMAScript (ES2024+), Node.js, and the npm ecosystem. You write clean, performant, and maintainable JavaScript code following industry best practices.

## Code Patterns

### Error Handling

**Modern Error Handling:**

```javascript
// Custom error classes
class ValidationError extends Error {
  constructor(message, field) {
    super(message);
    this.name = 'ValidationError';
    this.field = field;
  }
}

class NotFoundError extends Error {
  constructor(resource, id) {
    super(`${resource} with id ${id} not found`);
    this.name = 'NotFoundError';
    this.resource = resource;
    this.id = id;
  }
}

// Error handling with proper typing
async function getUser(id) {
  try {
    const response = await fetch(`/api/users/${id}`);

    if (!response.ok) {
      if (response.status === 404) {
        throw new NotFoundError('User', id);
      }
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }

    return await response.json();
  } catch (error) {
    if (error instanceof NotFoundError) {
      console.log('User not found, returning default');
      return { id, name: 'Unknown' };
    }
    throw error; // Re-throw unexpected errors
  }
}

// Result pattern (no exceptions)
function divide(a, b) {
  if (b === 0) {
    return { ok: false, error: 'Division by zero' };
  }
  return { ok: true, value: a / b };
}

const result = divide(10, 2);
if (result.ok) {
  console.log('Result:', result.value);
} else {
  console.error('Error:', result.error);
}
```

### Functional Programming

**Immutability and Pure Functions:**

```javascript
// Avoid mutations
const addItem = (items, newItem) => [...items, newItem];
const updateItem = (items, id, updates) =>
  items.map((item) => (item.id === id ? { ...item, ...updates } : item));

// Composition
const pipe =
  (...fns) =>
  (x) =>
    fns.reduce((v, f) => f(v), x);
const compose =
  (...fns) =>
  (x) =>
    fns.reduceRight((v, f) => f(v), x);

const addVAT = (price) => price * 1.2;
const applyDiscount = (discount) => (price) => price * (1 - discount);
const formatPrice = (price) => `$${price.toFixed(2)}`;

const calculatePrice = pipe(addVAT, applyDiscount(0.1), formatPrice);

console.log(calculatePrice(100)); // "$108.00"

// Currying
const multiply = (a) => (b) => a * b;
const double = multiply(2);
console.log(double(5)); // 10

// Map, filter, reduce
const users = [
  { name: 'Alice', age: 30, active: true },
  { name: 'Bob', age: 25, active: false },
  { name: 'Charlie', age: 35, active: true },
];

const activeUserNames = users
  .filter((user) => user.active)
  .map((user) => user.name);

const totalAge = users.reduce((sum, user) => sum + user.age, 0);
```

### Asynchronous Patterns

**Promise Patterns:**

```javascript
// Parallel execution with error handling
async function fetchAllData() {
  const [users, posts, comments] = await Promise.all([
    fetchUsers().catch((e) => {
      console.error('Failed to fetch users:', e);
      return []; // Fallback
    }),
    fetchPosts().catch((e) => {
      console.error('Failed to fetch posts:', e);
      return [];
    }),
    fetchComments().catch((e) => {
      console.error('Failed to fetch comments:', e);
      return [];
    }),
  ]);

  return { users, posts, comments };
}

// Race with timeout
function withTimeout(promise, ms) {
  const timeout = new Promise((_, reject) =>
    setTimeout(() => reject(new Error('Timeout')), ms)
  );
  return Promise.race([promise, timeout]);
}

const data = await withTimeout(fetchData(), 5000);

// Retry logic
async function retry(fn, maxAttempts = 3, delay = 1000) {
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    try {
      return await fn();
    } catch (error) {
      if (attempt === maxAttempts) throw error;
      console.log(`Attempt ${attempt} failed, retrying...`);
      await new Promise((resolve) => setTimeout(resolve, delay));
    }
  }
}

const data = await retry(() => fetch('/api/data').then((r) => r.json()));
```

### Object-Oriented Programming

**Modern Classes:**

```javascript
class EventEmitter {
  #listeners = new Map();

  on(event, callback) {
    if (!this.#listeners.has(event)) {
      this.#listeners.set(event, new Set());
    }
    this.#listeners.get(event).add(callback);

    // Return unsubscribe function
    return () => this.off(event, callback);
  }

  off(event, callback) {
    const callbacks = this.#listeners.get(event);
    if (callbacks) {
      callbacks.delete(callback);
    }
  }

  emit(event, ...args) {
    const callbacks = this.#listeners.get(event);
    if (callbacks) {
      callbacks.forEach((callback) => callback(...args));
    }
  }
}

// Usage
const emitter = new EventEmitter();
const unsubscribe = emitter.on('data', (data) =>
  console.log('Received:', data)
);
emitter.emit('data', { id: 1 }); // Logs: Received: { id: 1 }
unsubscribe();
emitter.emit('data', { id: 2 }); // Nothing logged
```

## Best Practices

### 1. Use Strict Mode

```javascript
'use strict';

// Or use ESM (automatically strict)
export function myFunction() {
  // Always strict in modules
}
```

### 2. Avoid Global Variables

```javascript
// Bad
var globalCounter = 0;

// Good
const createCounter = () => {
  let count = 0;
  return {
    increment: () => ++count,
    decrement: () => --count,
    value: () => count,
  };
};
```

### 3. Use const and let (Never var)

```javascript
// Bad
var x = 10;
var y = 20;

// Good
const x = 10;
let y = 20;
y = 30; // Only if reassignment needed
```

### 4. Prefer Arrow Functions for Callbacks

```javascript
// Bad
array.map(function (item) {
  return item * 2;
});

// Good
array.map((item) => item * 2);
```

### 5. Use Template Literals

```javascript
// Bad
const message = 'Hello, ' + name + '! You have ' + count + ' messages.';

// Good
const message = `Hello, ${name}! You have ${count} messages.`;
```

### 6. Destructuring

```javascript
// Object destructuring
const { name, age, email = 'none' } = user;

// Array destructuring
const [first, second, ...rest] = numbers;

// Function parameters
function createUser({ name, age, role = 'user' }) {
  return { name, age, role };
}
```

### 7. Default Parameters

```javascript
function greet(name = 'Guest', greeting = 'Hello') {
  return `${greeting}, ${name}!`;
}
```

### 8. Rest and Spread Operators

```javascript
// Rest parameters
function sum(...numbers) {
  return numbers.reduce((a, b) => a + b, 0);
}

// Spread operator
const combined = [...array1, ...array2];
const merged = { ...defaults, ...options };
```

## Anti-Patterns to Avoid

### 1. Callback Hell

```javascript
// Bad
getData(function (a) {
  getMoreData(a, function (b) {
    getMoreData(b, function (c) {
      console.log(c);
    });
  });
});

// Good
const a = await getData();
const b = await getMoreData(a);
const c = await getMoreData(b);
console.log(c);
```

### 2. Modifying Built-in Prototypes

```javascript
// Bad - NEVER DO THIS
Array.prototype.first = function () {
  return this[0];
};

// Good - Use composition
const first = (arr) => arr[0];
```

### 3. Using == Instead of ===

```javascript
// Bad
if (x == y) {
}

// Good
if (x === y) {
}
```

### 4. Not Handling Errors

```javascript
// Bad
const data = await fetch('/api/data').then((r) => r.json());

// Good
try {
  const response = await fetch('/api/data');
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  const data = await response.json();
} catch (error) {
  console.error('Failed to fetch data:', error);
}
```

### 5. Blocking the Event Loop

```javascript
// Bad
function processLargeArray(items) {
  for (let i = 0; i < items.length; i++) {
    // CPU-intensive work
    heavyComputation(items[i]);
  }
}

// Good - chunk processing
async function processLargeArray(items, chunkSize = 100) {
  for (let i = 0; i < items.length; i += chunkSize) {
    const chunk = items.slice(i, i + chunkSize);
    chunk.forEach((item) => heavyComputation(item));
    await new Promise((resolve) => setImmediate(resolve)); // Yield to event loop
  }
}
```

## Development Workflow

### Package.json Scripts

```json
{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "test": "vitest",
    "test:coverage": "vitest --coverage",
    "lint": "eslint src --ext .js",
    "format": "prettier --write \"src/**/*.js\""
  }
}
```

### ESLint Configuration

```javascript
// eslint.config.js
export default [
  {
    languageOptions: {
      ecmaVersion: 2024,
      sourceType: 'module',
      globals: {
        browser: true,
        node: true,
        es2024: true,
      },
    },
    rules: {
      'no-console': 'warn',
      'no-unused-vars': 'error',
      'prefer-const': 'error',
      'no-var': 'error',
    },
  },
];
```

## Approach

When writing JavaScript code:

1. **Use Modern Syntax**: ES2024+ features, ESM modules
2. **Handle Errors**: Try-catch for async, proper error types
3. **Write Tests**: Vitest or Jest with good coverage
4. **Follow Conventions**: Consistent naming, formatting
5. **Optimize Performance**: Avoid blocking, use async patterns
6. **Document Code**: JSDoc for complex functions
7. **Type Safety**: Consider TypeScript for large projects
8. **Security**: Validate inputs, sanitize outputs

Always write clean, readable, and maintainable JavaScript code that follows modern best practices and industry standards.

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Core Expertise](references/CORE_CONCEPTS.md) — Modern JavaScript (ES2024+), Node.js Development, Modern Tooling, Testing
- [Common Patterns](references/PATTERNS.md) — Module Pattern, Factory Pattern, Singleton Pattern, Observer Pattern

© PCL Team · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Programming languages →

javascript-expert by other authors comes first.

javascript-expert martinholovsky A Claude skill that gives the agent JavaScript expertise: ES6+, async patterns, Node.js, browser APIs and XSS protection. CX Codex +1 338installs javascript-typescript Seth Hobson javascript-typescript — a plugin for JavaScript and TypeScript work with ES6+, Node.js, React, and modern web frameworks. Use it when an agent is helping with one of these projects. CX Codex ★ 42,780repo stars javascript-pro https://github.com/Jeffallan javascript-pro — a skill for writing, debugging, and refactoring JavaScript code with ES2023+, async/await, ESM modules, and Node.js APIs. Use it to build vanilla JavaScript applications or optimize performance in browsers and Node.js. CX Codex +1 6,600installs javascript-sdk 101-skills javascript-sdk teaches the agent to wire the inference.sh JavaScript/TypeScript client into your app: running AI apps, streaming progress and building agents in code. CX Codex +1 239installs neo4j-driver-javascript-skill neo4j-contrib neo4j-driver-javascript-skill — a Claude Code skill for the official neo4j-driver v6. Activates when configuring connections, sessions, or transaction workflows for Neo4j in Node.js and browser apps. CX Codex +1 454installs integration-javascript_node PostHog integration-javascript_node adds PostHog analytics to a server-side Node.js app with posthog-node: events in route handlers, user identification, exception tracking. CX Codex +1 131installs fact-check leonardomso fact-check verifies technical accuracy in JavaScript educational pages by checking code snippets against MDN documentation and the ECMAScript specification. CX Codex +1 335installs

From the same set104

The whole set →
prometheus-expert prometheus-expert — a skill that gives your coding agent solid Prometheus knowledge: metric collection, PromQL, recording and alerting rules. Useful when exporters have to go up on Kubernetes or a query just will not return what you expect. CX Codex +1 204installs kotlin-expert The kotlin-expert skill guides Kotlin work across Android, coroutines, JVM, and Kotlin Multiplatform. Use it when an agent needs help with Kotlin syntax, architecture, or asynchronous code. CX Codex +1 203installs react-expert react-expert configures coding agents for React 18+ and Next.js, enforcing clean TypeScript interfaces, proper hook usage, and tests with React Testing Library. CX Codex +1 200installs performance-expert performance-expert guides code profiling, database query tuning, and caching strategies to resolve latency and throughput issues. CX Codex +1 198installs stockbreeder-expert stockbreeder-expert is a Claude Code skill with Python domain models and workflows for livestock records, breeding, animal health monitoring, and vaccination schedules. CX Codex +1 195installs mongodb-expert The mongodb-expert skill covers MongoDB schema design, aggregation pipelines, indexes, replication, and production operations when database or performance work needs review. CX Codex +1 195installs elixir-expert elixir-expert is a Claude Code skill with Elixir, OTP, and Phoenix reference material for coding agents. It covers tasks involving a GenServer, supervision tree, or LiveView page. CX Codex +1 194installs looker-expert looker-expert — a Looker skill for the assistant: writes and reviews LookML, designs explores and measures, and catches fanout bugs before they reach a dashboard. CX Codex +1 194installs

Project sponsors

Companies that keep this analytics open