javascript
/javascript
Przegląda kod JavaScript pod kątem szybkości, rozmiaru paczki i pracy głównego wątku, z regułą, linią i kosztem każdego znaleziska.
- Autor
- workbench-soft ↗
- Repozytorium
- agent-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 13.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 3
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Przegląda kod JavaScript pod kątem szybkości, rozmiaru paczki i pracy głównego wątku, z regułą, linią i kosztem każdego znaleziska.
Wyzwalacze z opisu
Oryginalny opis (EN)
Use when JavaScript or TypeScript is written, sped up or reviewed: "make it faster", "why is this page slow", "the bundle is too big", "ускорь код", "почему страница тормозит". Works out where the code runs, then cuts round trips, bundle size and main thread work: parallel awaits, lazy heavy imports, Map lookups, no request data in module scope. Each review finding gives the rule, the line and its cost.
Jak działa
- 1. Find where the code runs
- 2. Async
- 3. Server
- 4. Data
- 5. Leave alone
- 6. In a review
Podgląd SKILL.md
---
name: javascript
description: 'Use when JavaScript or TypeScript is written, sped up or reviewed: "make it faster", "why is this page slow", "the bundle is too big", "ускорь код", "почему страница тормозит". Works out where the code runs, then cuts round trips, bundle size and main thread work: parallel awaits, lazy heavy imports, Map lookups, no request data in module scope. Each review finding gives the rule, the line and its cost.'
---
# JavaScript
The agent MUST apply these rules to JS and TS where a mistake costs real time
or real data: an extra round trip, a slow first screen, a response that holds
another user's data.
The repo's lint rules and skills MUST beat this file. Rules for React and other
frameworks belong to that framework's skill.
## 1. Find where the code runs
- **Server** the agent MUST treat Node, Bun, Deno, a serverless function and
server rendering as server code.
- **Browser** the agent MUST treat whatever ships in a bundle as browser code.
- **Both** a shared module or a server rendered component MUST follow both
sets of rules.
The async, server and data rules below MUST apply to all of them. Code shipped
to a browser MUST follow these as well:
- **Bundle** for imports, lazy loading and third party scripts, the agent MUST
read [references/bundle.md](references/bundle.md).
- **Browser** for listeners, layout, `localStorage` and idle work, the agent
MUST read [references/browser.md](references/browser.md).
## 2. Async
### Run independent calls together
Calls that don't depend on each other's result SHOULD start at the same time.
```ts
// Bad: 3 round trips, one after another
const user = await getUser(id);
const orders = await getOrders(id);
const prefs = await getPrefs(id);
```
```ts
// Good: 1 round trip
const [user, orders, prefs] = await Promise.all([getUser(id), getOrders(id), getPrefs(id)]);
```
### Start early, await late
A call that depends on one result SHOULD chain only on that promise, so the
rest of the calls go ahead without it.
```ts
const userP = getUser(id);
const ordersP = userP.then((user) => getOrders(user.accountId));
const [user, orders, config] = await Promise.all([userP, ordersP, getConfig()]);
```
On every path, a promise started early MUST be awaited or caught. An early
return that leaves it pending causes an unhandled rejection, and by default Node
exits on one.
### Await where the value is used
- **In the branch** an `await` SHOULD sit where its value is read, so an early
return skips the call.
- **Cheap check first** a fast sync check SHOULD come before an awaited flag:
`if (isAdmin && (await getFlag("export")))`. If the check has side effects or
needs the flag, keep the old order.
```ts
// Bad: loads permissions even when the doc is missing
const perms = await getPerms(userId);
const doc = await getDoc(docId);
if (!doc) return notFound();
```
```ts
// Good
const doc = await getDoc(docId);
if (!doc) return notFound();
const perms = await getPerms(userId);
```
### Loops and failures
- **Loops** an `await` in a loop over independent items SHOULD turn into
`Promise.all(items.map(...))`.
- **Many items** hundreds of them, or an API with a rate limit, SHOULD run
under a concurrency cap such as `p-limit`.
- **Failures** `Promise.all` rejects at the first failure and loses the other
results. If each result matters by itself, the code SHOULD use
`Promise.allSettled` and MUST deal with every `rejected` entry.
## 3. Server
- **Request data** the user, the tenant and the like MUST NOT live in a module
level variable. Concurrent requests share the module, so a response can carry
another user's data. Pass it as an argument, or use `AsyncLocalStorage`.
- **Module scope** it MAY hold what every request shares: config, a database
client, a cache keyed by request data.
```ts
// Bad: request B overwrites the user before request A reads it
let currentUser: User | null = null;
export async function handler(req: Request) {
currentUser = await auth(req);
return render();
}
```
## 4. Data
- **Lookups** repeated lookups by key SHOULD use a `Map` built a single time. A
`find` inside `map` scans the whole array for each item.
- **Membership** checks against a list SHOULD use a `Set`: `allowed.has(id)`.
- **Given arrays** a function MUST NOT reorder an array passed to it. `sort`,
`reverse` and `splice` change the caller's array, React state too. Use
`toSorted`, `toReversed`, `toSpliced` or `with` (Node 20 and up), or copy
first: `[...items].sort(byName)`.
```ts
// Bad: users.find runs once per order
orders.map((order) => ({ ...order, user: users.find((u) => u.id === order.userId) }));
```
```ts
// Good
const userById = new Map(users.map((u) => [u.id, u]));
orders.map((order) => ({ ...order, user: userById.get(order.userId) }));
```
## 5. Leave alone
Unless a profile shows the line is hot, readable code SHOULD NOT be rewritten
for a gain the engine makes by itself:
- **Length** the agent SHOULD NOT cache `items.length` or a property read
inside a loop.
- **Chains** the agent SHOULD NOT merge `.filter().map()` into one loop.
- **Loops** the agent SHOULD NOT swap `forEach` for a `for` loop.
## 6. In a review
- **Each finding** MUST give the rule, the line and the cost: "3 calls in a
row, 1 round trip with `Promise.all`".
- **Speed claims** they SHOULD come with a number: round trips saved, KB off
the bundle, the length of the list.
- **No real cost** a finding like a `find` over 10 items SHOULD shrink to a nit
or be dropped.
Pliki w paczce (3)
- SKILL.md 5 KB
- references/browser.md 2 KB
- references/bundle.md 2 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · workbench-soft/agent-skills | 100 | MIT |
| DaraBoth/skilljmskill | 100 | MIT |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| alexander-danilenko/cortex-claude-code-plugins | 100 | MIT |
| G1Joshi/Agent-Skills | 100 | MIT |
| aj-geddes/unicorn-team | 100 | MIT |
| autocss-com/ai | 90 | MIT |
| clawic/skills | 90 | MIT |
| dkbnull/hello-skill | 86 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki aad665ca83b9 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100audit-bundle-size
Analizuje i zmniejsza bundle JavaScript aplikacji webowej, w tym code splitting i wolne ładowanie początkowe. - 100bundle-size
Przypisuje rozmiar bundle'a JavaScript do importów, które go powiększyły, buduje aplikację esbuildem i generuje raport w formie strony z analityką. - 100bundle-analyzer
Analizuje rozmiar bundli JavaScript i TypeScript, audytuje tree-shaking i zaleca dzielenie kodu: wskazuje ciężkie zależności, zduplikowane pakiety i nieużywane importy oraz podpowiada dynamiczne importy i lazy loading. - 100nextjs-client-audit
Sprawdza dyrektywy use client w Next.js, mierzy kod trafiający do paczki przeglądarki i proponuje bezpieczne poprawki z przykładami przed i po. - 100parallel-async
Skanuje gorące ścieżki repozytorium TypeScript i JavaScript pod kątem zbędnych sekwencyjnych wywołań async i je naprawia. - 100performance-reviewer
Przegląda kod pod kątem wydajności: zapytania N+1, zbędne re-rendery, wycieki pamięci, nieefektywne algorytmy, brakujące indeksy i wzrost rozmiaru bundle'a.