
javascript-best-practices
by jcastillotx
My skeleton for app builds
SKILL.md
name: javascript-best-practices description: JavaScript coding standards and best practices. This skill should be used when writing, reviewing, or refactoring JavaScript code. Triggers on tasks involving vanilla JavaScript, DOM manipulation, async operations, or performance optimization. trigger_patterns:
- javascript
- vanilla js
- dom manipulation
- event listener
- promise
- async/await auto_load_with:
- react-best-practices
- nextjs-best-practices
JavaScript Best Practices
Comprehensive coding standards for JavaScript development, optimized for AI agents and LLMs. Contains 24 rules across 8 categories, prioritized by impact.
When to Apply
Reference these guidelines when:
- Writing vanilla JavaScript code
- Implementing async operations and promises
- Handling DOM manipulation
- Optimizing JavaScript performance
- Reviewing code for security issues
- Working with ES modules and modern features
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Performance | CRITICAL | perf- |
| 2 | Async Patterns | CRITICAL | async- |
| 3 | Security | HIGH | security- |
| 4 | Error Handling | HIGH | error- |
| 5 | ES Modules | MEDIUM-HIGH | module- |
| 6 | Data Structures | MEDIUM | data- |
| 7 | DOM Manipulation | MEDIUM | dom- |
| 8 | Modern Features | LOW-MEDIUM | modern- |
Quick Reference
1. Performance (CRITICAL)
perf-avoid-memory-leaks- Clean up event listeners and intervalsperf-dom-batch-updates- Batch DOM updates with DocumentFragmentperf-debounce-throttle- Debounce scroll/resize handlersperf-avoid-layout-thrashing- Separate reads and writes to DOMperf-web-workers- Use Web Workers for heavy computation
2. Async Patterns (CRITICAL)
async-promise-all- Use Promise.all() for parallel operationsasync-promise-allsettled- Use allSettled() when some can failasync-error-boundaries- Handle promise rejections properlyasync-avoid-nested-promises- Flatten with async/awaitasync-cancellation- Use AbortController for cancellable requests
3. Security (HIGH)
security-no-innerhtml- Use textContent instead of innerHTMLsecurity-no-eval- Never use eval() or new Function()security-sanitize-user-input- Sanitize before DOM insertionsecurity-csp-compliance- Write CSP-compliant code
4. Error Handling (HIGH)
error-custom-errors- Create custom Error classeserror-async-try-catch- Wrap async operations in try-catcherror-global-handler- Implement window.onerror handler
5. ES Modules (MEDIUM-HIGH)
module-named-exports- Prefer named exports for tree-shakingmodule-barrel-files- Avoid barrel files in performance-critical codemodule-dynamic-imports- Use dynamic imports for code splitting
6. Data Structures (MEDIUM)
data-map-over-object- Use Map for dynamic key collectionsdata-set-for-uniqueness- Use Set for unique value collectionsdata-immutable-updates- Use spread operator for immutability
7. Modern Features (LOW-MEDIUM)
modern-optional-chaining- Use ?. for safe property access
How to Use
Read individual rule files for detailed explanations and code examples.
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です