Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/nedcodes-ok/cursor-doctor/javascriptgit clone --depth 1 https://github.com/nedcodes-ok/cursor-doctorWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01250 | $0.01250 |
| Opus 5 | $0.00625 | $0.00625 |
| Sonnet 5 | $0.00250 | $0.00250 |
| Haiku 4.5 | $0.00125 | $0.00125 |
Grade A, and why
javascript scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
- Default parameters: `function fetch(url, retries = 3)` — but defaults are evaluated left-to-right per call, so `function f(a, b = a * 2)` works and `function f(a = b, b)` doesn't This is a copy
100% identical to javascript — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 46 lines — stays where its author put it; the contents beside it link to each section on GitHub.
JavaScript Rules
Modern Syntax
constby default,letwhen reassignment is needed, nevervar.varis function-scoped and hoisted — it creates bugs thatconst/let(block-scoped) prevent- Arrow functions for callbacks and short functions. Regular
functionfor top-level declarations and methods that needthis. Arrow functions inheritthisfrom the enclosing scope — using them as object methods breaksthisbinding - Template literals over concatenation:
`Hello ${name}`not"Hello " + name. Tagged templates (html`...`) for DSLs and sanitization - Destructure at point of use:
const { name, email } = user— but don't deeply destructure (const { address: { city } } = user) because it obscures the data source and throws on null - Optional chaining (
?.) and nullish coalescing (??) over manual checks.??only catchesnull/undefined, NOT0,"", orfalse— that's the difference from||. If you want to default on all falsy values, use||. If only null/undefined, use??
Async
async/awaitover.then()chains — flatter, readable, debuggable with stack traces..then()loses the call stack on errorstry/catchin async functions catches both sync throws and rejected promises. Butcatchat the right level — wrapping every line in try/catch is noise. Catch where you can handle the error meaningfullyPromise.all()for independent concurrent operations — runs in parallel.Promise.allSettled()when you need all results even if some fail.Promise.all()short-circuits on the first rejection and you lose the other results- Unhandled promise rejections crash Node.js (v15+) and log warnings in browsers. Always handle them: return the promise, await it, or attach
.catch() for await...offor async iterables (streams, paginated APIs). Don'tawaitinside a regularforloop when operations are independent — that serializes them unnecessarily
Functions
- Pure functions where possible: same input → same output, no side effects. Pure functions are testable without mocks, cacheable, and safe to parallelize
- Default parameters:
function fetch(url, retries = 3)— but defaults are evaluated left-to-right per call, sofunction f(a, b = a * 2)works andfunction f(a = b, b)doesn't - Return early to flatten nesting: guard clauses at the top (
if (!user) return null;), happy path at indent level 1 - Named exports for tree-shaking:
export function fetchUser()— default exports can't be tree-shaken by name and make refactoring harder (the import name is arbitrary)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 46 lines · 1,250 tokens per session scan A 1f1a63bc5cae
javascript is a cursor rule published in the GitHub repository nedcodes-ok/cursor-doctor (9 stars, last pushed 5mo ago), licensed MIT. It adds 1,250 tokens to every session, about $0.0063 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to javascript, differing in 0 lines, and is treated as a copy.
Other cursor rules, from other repositories
angular
Angular: signals, standalone components, RxJS patterns.
django
Django: models, views, ORM best practices.
java
Modern Java: records, sealed classes, streams, virtual threads.
javascript
Modern JavaScript: ES2023+, async patterns, common traps.
rust
Rust patterns: ownership, Result types, iterators.
accessibility
Accessibility: semantic HTML, ARIA, keyboard navigation, testing.