javascript_skill

This skill helps you write robust production JavaScript by applying pragmatic rules for async error handling performance and testing.
  • JavaScript

1

GitHub Stars

4

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill matthewharwood/fantasy-phonics --skill javascript

  • README.md6.3 KB
  • SKILL.md37.3 KB
  • STYLE_GUIDE.md4.7 KB
  • V8_OPTIMIZATION.md19.0 KB

Overview

This skill codifies 30 pragmatic rules for production JavaScript focused on async patterns, V8-friendly object design, memory management, testing, error handling, and performance. It is written to apply across vanilla JavaScript and web components, helping teams avoid common runtime, concurrency, and optimization pitfalls. Use it as a checklist when writing, refactoring, or hardening browser-side JavaScript for production.

How this skill works

The rules inspect common failure modes and prescribe concrete patterns: explicit promise rejection handling, time-bounded and cancellable async flows, controlled concurrency, and cleanup registries for timers/listeners. It also recommends V8-friendly initialization of object shapes, immutability practices, and memory-leak prevention patterns. Practical code snippets and small classes (PromisePool, RateLimiter, CleanupRegistry, Poller) illustrate how to adopt the rules in real projects.

When to use it

  • Building web components or vanilla JS UIs that must be robust and memory-safe
  • Implementing networked features where timeouts, retries, and cancellation matter
  • Optimizing hot code paths for V8 performance and avoiding hidden-class deoptimizations
  • Writing tests and error boundaries to contain failures and capture diagnostics
  • Managing large concurrent batches or rate-limited external APIs

Best practices

  • Always handle promise rejections and provide contextual errors or Result types
  • Abort or cancel long-running async work when components unmount or users navigate away
  • Initialize object properties up front to keep consistent hidden-class shapes
  • Limit concurrency via batching or a promise pool to avoid resource exhaustion
  • Register and run cleanup logic for timers, intervals, listeners, and polling loops
  • Prefer immutable updates and structuredClone where appropriate to prevent shared-mutable bugs

Example use cases

  • A search component that cancels previous fetches with AbortController on each query
  • A data-sync worker that uses a RateLimiter to avoid hitting API rate limits
  • A dashboard rendering thousands of objects with factory-created shapes for V8 optimization
  • A game UI using a CleanupRegistry to remove listeners and timers when switching scenes
  • A background poller that can be started and stopped without leaking timers or promises

FAQ

Initialize all expected properties in constructors or factory functions so objects share the same shape; avoid adding new properties later.

When should I prefer cancellation vs. simple timeouts?

Use cancellation (AbortController or cancellable abstractions) when the operation should stop immediately on unmount/navigation; use timeouts to bound operations that may hang.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
javascript skill by matthewharwood/fantasy-phonics | VeilStrat