javascript-architect
Architect-level JavaScript guidance — module boundaries and load strategy, async and error-flow design, event-loop budgets, immutability and data-shape decisions, and the runtime split between browser and server. Use when designing application structure or diagnosing coupling, not for syntax.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- javascript-architect
- license
- MIT
- metadata
- { "crusor-path": "website-architect/frontend-development-architect/javascript-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "MDN JavaScript; ECMAScript 2024; Node.js docs", "crusor-triggers": "javascript, modules, async, event-loop, promises, errors, immutability, bundling, esm, cjs", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level JavaScript guidance — module boundaries and load strategy, async and error-flow design, event-loop budgets, immutability and data-shape decisions, and the runtime split between browser and server. Use when designing application structure or diagnosing coupling, not for syntax.
- compatibility
- ES2022+, Node 20+ and evergreen browsers
03 SKILL.md 正文
JavaScript Architecture
JavaScript failures are almost never syntax. They are module boundaries, async flow, and error ownership. Decide those three, and the rest is local.
When to use
- Splitting an application into modules/packages.
- Designing an async flow or an error contract.
- Deciding ESM vs CJS, browser vs server runtime.
- Performance work where the event loop is the suspect.
When NOT to use
- A local refactor with no boundary change.
- Type-shape questions (see
typescript-architect).
Decision 1 — Module boundaries
- One public entry per module (
index.js) exposing a deliberate surface; deep imports are private. - Dependencies point inward:
app → features → domain → util. No cycles — a cycle is two modules sharing a concept they have not named. - A module owns its data and its invariants; callers ask for behaviour, not for raw state to mutate.
- Prefer many small pure modules over one "service" that knows everything.
- Runtime split is explicit: browser-only code never imports Node built-ins, and server-only code never reaches a client bundle.
Decision 2 — Async and error flow
- Every async boundary has an owner: who retries, who cancels, who surfaces.
async/awaitat the boundary, promise combinators for concurrency:Promise.all(fail-fast),allSettled(independent),any(race) — choose deliberately, they are not interchangeable.- Cancellation is part of the contract (
AbortController); a stale response must not overwrite a fresh one. - No floating promises: unhandled rejections are defects.
- Errors are values at module boundaries and thrown only inside; convert once.
- Never swallow:
catch {}is a bug unless a comment states the recovery.
Decision 3 — Event loop and budgets
- Long tasks (>50 ms) are architecture problems: move parsing, sorting and crypto off the critical path or into a worker.
- Chatty async is a waterfall: independent work runs in parallel, dependent work is explicit.
- Avoid per-item timers and per-row listeners; batch, delegate, or observe.
- Timers are not scheduling: prefer
requestIdleCallback/schedulersemantics for deferrable work.
Decision 4 — Data shape
- Immutable at boundaries; mutation stays inside one owner's functions.
- Normalise only when the same entity appears in multiple views; otherwise keep shapes aligned with their producer.
- Validate at trust boundaries (network, storage, user input); inside the app, trust types.
Failure modes at scale
- Barrel files making every import pull the world.
- One global event bus as the integration strategy — boundaries lost, order undefined.
- Async errors surfacing as a blank screen because nobody owned them.
- ESM/CJS dual-loading the same dependency, breaking identity checks.
JSON.parse(JSON.stringify(x))as "deep clone" — drops Dates, Maps, undefined.
Verification receipts
- Dependency graph has no cycles (madge/graph tool, committed output).
node --experimental/ build passes with strict ESM resolution.- A cancellation test: slow request loses to a newer one.
- Bundle analyse: no module pulls a dependency it does not use.
- Long-task profile of the primary interaction.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.