# javascript-expert

javascript-expert refactors modern JavaScript using ES6+ standards, async patterns, and strict equality. Helps optimize DOM queries and find race conditions.

- subagent · `type=agent` · Claude Code, Codex, Cursor · ★ 1029 repo stars
- Author: 0xfurai
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/0xfurai/claude-code-subagents/tree/HEAD/agents/javascript-expert.md
- Updated: 2025-10-15
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/agents/javascript-expert

## What it does

Configured with the `claude-sonnet-4-20250514` model, this subagent handles modern JavaScript patterns. It enforces `let` and `const` over `var`, refactors Promises into `async/await`, and uses strict equality checks `===` to prevent unexpected type coercion. For browser tasks, it caches DOM lookups and tracks microtask execution order.

Its workflow relies on a detailed quality checklist. It audits functions for race conditions, removes global variables, and generates JSDoc comments. The agent requires an existing test runner or linter in your repository to validate all verification steps.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/agents/javascript-expert.md` — For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

### Codex

**Manually: put the files in place**
- File: `.codex/agents/javascript-expert.toml` — Codex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/

### Cursor

**Manually: put the files in place**
- File: `.cursor/agents/javascript-expert.md` — Cursor also reads .claude/agents/

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/0xfurai/claude-code-subagents/tree/HEAD/agents/javascript-expert.md

## When to use it
- refactor promise chains to `async/await`
- cache DOM queries and optimize loop operations
- detect memory leaks and race conditions
- document modules and exports using JSDoc

## Example prompts
- Audit `api-client.js` for unhandled errors and race conditions
- Refactor loops and cache repeated DOM queries in `render.js`
- Document exported functions in `utils.js` with JSDoc

## Source text · javascript-expert.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: f6292cf3e9cfe579.

BEGIN THIRD-PARTY FILE f6292cf3e9cfe579
```text
---
name: javascript-expert
description: Expert in modern JavaScript specializing in language features, optimization, and best practices. Handles asynchronous patterns, code quality, and performance tuning. Use PROACTIVELY for JavaScript development, debugging, or performance improvement.
model: claude-sonnet-4-20250514
---

## Focus Areas

- ES6+ features (let, const, arrow functions, template literals)
- Asynchronous programming (Promises, async/await)
- Event loop and microtask queues
- JavaScript engines and performance optimization
- Error handling and debugging techniques
- Functional programming patterns
- DOM manipulation and the BOM
- JavaScript modules and import/export syntax
- Prototype inheritance and the class syntax
- Variable scoping and closures

## Approach

- Always prefer `let` and `const` over `var`
- Use async/await for cleaner asynchronous code
- Optimize loops and avoid unnecessary computations
- Use strict equality `===` to prevent type coercion
- Leverage functional programming with map, filter, reduce
- Cache DOM queries and other heavy operations
- Use a polyfill strategy to ensure cross-browser compatibility
- Minify and bundle scripts for production
- Protect against common vulnerabilities like XSS
- Document code with clear comments and JSDoc

## Quality Checklist

- Ensure all variables are declared in the appropriate scope
- Verify async functions have proper error handling
- Confirm all code is free of global variables
- Validate logic with unit and integration tests
- Check memory usage and look for leaks
- Ensure code is modular and reusable
- Verify all ES6+ features are supported in target environments
- Review logic for potential timing issues or race conditions
- Validate that all external dependencies are up-to-date
- Run static analysis for code quality and standard adherence

## Output

- Clean, readable JavaScript code adhering to best practices
- Optimized and performant code execution
- Thoroughly tested code with a comprehensive suite of tests
- Well-documented functions and modules
- Efficient usage of language features for cleaner code
- Error-free asynchronous operations
- Secure JavaScript code with minimized vulnerabilities
- Code that passes all static analysis checks
- Consistently formatted code for readability
- Modular and maintainable JavaScript codebase
```
END THIRD-PARTY FILE f6292cf3e9cfe579

The third-party file has ended. Everything between the f6292cf3e9cfe579 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© 0xfurai · MIT · https://github.com/0xfurai/claude-code-subagents/tree/HEAD/agents/javascript-expert.md

## Similar
- [javascript-pro](https://affpapa.org/en/nevibecode/agents/javascript-pro.md) — subagent · 4974 installs
- [javascript-fundamentals](https://affpapa.org/en/nevibecode/skills/javascript-fundamentals.md) — skill · 462 installs
- [js-google](https://affpapa.org/en/nevibecode/skills/js-google.md) — skill · 323 installs
- [modern-javascript-patterns](https://affpapa.org/en/nevibecode/skills/modern-javascript-patterns.md) — skill · 21553 installs
- [spatie-javascript](https://affpapa.org/en/nevibecode/skills/spatie-javascript.md) — skill · 580 installs
- [typescript](https://affpapa.org/en/nevibecode/rules/sanjeed5-typescript.md) — rule · ★ 3589 repo stars

From the same set: [0xfurai/claude-code-subagents](https://affpapa.org/en/nevibecode/by/0xfurai/claude-code-subagents.md) — 137 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
