agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/languages/javascript/SKILL.md

javascript

Skill15 starsChanged 43 days agoMITView on GitHub

Expert modern JavaScript (ES2024+) assistance covering closures, async/await, promises, modules, event loop concurrency, and DOM manipulation. Use when writing frontend or Node.js code, designing clean asynchronous flows, or modernizing legacy JavaScript.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use debugging and architecture.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 3 projects that use this

  • AnthropicSkill

    architecture

    Create or evaluate an architecture decision record (ADR). Use when choosing between technologies (e.g., Kafka vs SQS), documenting a design decision with trade-offs and consequences, reviewing a system design proposal, or designing a new component from requirements and constraints.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always Use Strict Equality (===): Avoid implicit type coercion bugs by using === and !==.

    line 160
  2. Very specific:

    Use const by Default and let for Reassignment: Never use legacy function-scoped var.

    line 161
  3. Very specific:

    Use eval() or new Function(): Dynamic code evaluation opens critical remote code execution (RCE) vectors.

    line 169

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

JavaScript

Modern JavaScript development with ES6+ features, async patterns, and best practices.

When to Use

  • Universal Full-Stack Web Development: The foundational language of the web, executing across browsers, Node.js, Bun, Deno, and Edge workers.
  • Event-Driven Asynchronous Backends: Serving high-concurrency microservices, real-time WebSockets, and serverless functions.
  • Interactive Browser User Interfaces: Manipulating the DOM, capturing browser events, and orchestrating client-side component state.
  • Cross-Platform Scripting & Tooling: Building developer tools, CLI scripts, and build plugins with npm/npx.

Quick Start

// Modern async function with error handling
async function fetchData(url) {
  try {
    const response = await fetch(url);
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return await response.json();
  } catch (error) {
    console.error("Fetch failed:", error);
    throw error;
  }
}

Core Concepts

Event Loop & Microtask Concurrency

JavaScript is single-threaded; asynchronous operations queue callbacks across Macrotasks and Microtasks:

console.log("1: Synchronous start");

setTimeout(() => console.log("4: Macrotask (setTimeout)"), 0);

Promise.resolve().then(() => console.log("3: Microtask (Promise)"));

console.log("2: Synchronous end");
// Output Order: 1 -> 2 -> 3 -> 4

Modern ECMAScript (ES2024+) Features

Leverages modern language primitives for concise, safe data handling:

// Structured Clone for deep copying
const original = { user: { name: "Alice" }, tags: new Set(["admin"]) };
const deepCopy = structuredClone(original);

// Array grouping (Object.groupBy)
const inventory = [
  { name: "Apples", category: "Fruit" },
  { name: "Carrots", category: "Vegetable" },
  { name: "Bananas", category: "Fruit" },
];
const grouped = Object.groupBy(inventory, (item) => item.category);

// Safe Object hasOwn
if (Object.hasOwn(original, "user")) {
  console.log("User property exists safely");
}

Async / Await with Concurrent Promise.allSettled

Handles batch asynchronous requests safely without failing fast on single errors:

async function fetchUserDashboard(userId) {
  const results = await Promise.allSettled([
    fetch(`/api/users/${userId}`).then((r) => r.json()),
    fetch(`/api/users/${userId}/notifications`).then((r) => r.json()),
  ]);

  const user = results[0].status === "fulfilled" ? results[0].value : null;
  const notifications =
    results[1].status === "fulfilled" ? results[1].value : [];
  return { user, notifications };
}

Common Patterns

Async/Await Best Practices

Problem: Managing multiple async operations efficiently.

Solution:

// Parallel execution
async function fetchAllData(ids) {
  const promises = ids.map((id) => fetchData(id));
  return Promise.all(promises);
}

// Sequential with error handling
async function processItems(items) {
  const results = [];
  for (const item of items) {
    try {
      results.push(await processItem(item));
    } catch (error) {
      results.push({ error: error.message, item });
    }
  }
  return results;
}

// AbortController for cancellation
async function fetchWithTimeout(url, ms = 5000) {
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), ms);

  try {
    return await fetch(url, { signal: controller.signal });
  } finally {
    clearTimeout(timeout);
  }
}

Modules

Problem: Structuring modular, reusable code without polluting global namespace scope.

Solution:

// Named exports (preferred)
export const API_URL = "https://api.example.com";
export function fetchUser(id) {
  /* ... */
}
export class UserService {
  /* ... */
}

// Re-exports
export { default as Button } from "./Button.js";
export * from "./utils.js";

// Dynamic imports
const module = await import(`./features/${feature}.js`);

Best Practices

Do:

  • Always Use Strict Equality (===): Avoid implicit type coercion bugs by using === and !==.
  • Use const by Default and let for Reassignment: Never use legacy function-scoped var.
  • Adopt Native ESM Modules: Use import and export statements; deprecate CommonJS require() in modern projects.
  • Handle Rejected Promises with try...catch: Always wrap await calls in error handling blocks to avoid unhandled rejection crashes.

Don't:

  • Block the Event Loop: Never execute heavy synchronous loops or CPU-intensive math on the main thread; offload to Web Workers.
  • Pollute global prototypes: Never modify Array.prototype or Object.prototype.
  • Use eval() or new Function(): Dynamic code evaluation opens critical remote code execution (RCE) vectors.

Troubleshooting

ErrorCauseSolution
Cannot read property of undefinedAccessing nested property on null/undefinedUse optional chaining ?.
Uncaught (in promise)Unhandled promise rejectionAdd .catch() or try/catch
X is not a functionCalling undefined methodCheck if method exists before calling

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.