msw
Skill15 starsChanged 15 days agoMITView on GitHub
Version-aware Mock Service Worker (MSW) guidance. Use when the task is to configure MSW in Node or a browser, write or fix MSW HTTP or GraphQL handlers and responses, validate request contracts through MSW behavior, control worker/server lifecycle and unhandled requests, diagnose MSW interception or matching, apply passthrough or bypass behavior, isolate concurrent MSW handlers, or migrate between MSW major versions.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- anivar/msw-skilltheir own version, first seen Nov 3, 2026
- thongdn-it/react-agent-skillstheir own version, first seen Nov 1, 2026
- PyModel/react-frontend-skillstheir own version, first seen Sep 19, 2026
- osabiohq/osabiotheir own version, first seen Mar 25, 2026
- Aver005/agent-skillstheir own version, first seen Feb 14, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- PyModel/react-frontend-skills★ 23same name
- osabiohq/osabio★ 15same name
- thongdn-it/react-agent-skills★ 5same name
- anivar/msw-skill★ 2same name
- Aver005/agent-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository53 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-repoSkill
- architectSkill
- codebase-designSkill
- code-reviewSkill
- commitSkill
- create-prSkill
- create-verification-skillSkill
- debugSkill
- frontendSkill
- implementSkill
- playwrightSkill
- react-hook-form-auditSkill
- react-hook-formSkill
- reactSkill
- refactorSkill
- researchSkill
- resolving-merge-conflictsSkill
- specSkill
- tailwindSkill
- tanstack-querySkill
- testSkill
- typescriptSkill
- zodSkill
- auditSkill
- neovimSkill
- shell-envSkill
- teachSkill
- tilSkill
- atomic-note-to-mocSkill
- close-daySkill
- create-noteSkill
- goalsSkill
- import-goodreadsSkill
- import-meetingsSkill
- ingestSkill
- memory-recallSkill
- process-inboxSkill
- projectSkill
- save-sessionSkill
- todays-focusSkill
- vault-auditSkill
- vaultSkill
- weekly-reviewSkill
- careerSkill
- check-communicationSkill
- deslopifySkill
- standupSkill
- blogSkill
- broSkill
- docsSkill
- talkSkill
- tweet-todaySkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Treat MSW as the network boundary, not as the owner of the test runner, UI waiting strategy, or client cache.
- Distinctive: line 25
Do not infer syntax from "MSW" alone.
- Distinctive: line 61
Complete when: every active branch has loaded its reference and the examples match the installed major.
- Distinctive: line 66
Keep reusable happy-path handlers as the baseline.
- Distinctive: line 72
Use real application requests as evidence.
- Distinctive: line 81
Run the narrowest request or test that proves interception, then the affected test suite and repository checks.
- Distinctive: line 94
Add delay only when latency, loading, cancellation, or race behavior is the scenario under test.
- Distinctive: line 96
Use real timers by default.
- Distinctive: line 101
Prefer observable application outcomes over assertions that merely record that a request occurred.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mock Service Worker
Treat MSW as the network boundary, not as the owner of the test runner, UI waiting strategy, or client cache.
Workflow
1. Detect the installed contract
Inspect manifests, lockfiles, package-manager output, imports, and node_modules/msw/package.json
when available. Record the exact MSW version, its engines and peer requirements, module system,
test runner, and whether interception runs in Node, a browser, or both.
Do not infer syntax from "MSW" alone. Classify the installed major before editing:
- v1 uses
rest,(req, res, ctx), and response composition; - v2 uses Fetch API request/response primitives and
HttpResponse, with most handlers and utilities exported frommsw; - v3 moves handlers and utilities to designated entrypoints, makes GraphQL link-first, and renames unhandled-request configuration.
Complete when: the exact package contract and every affected runtime are known.
2. Trace ownership
Identify the real outgoing request, method, resolved URL, body, headers, and GraphQL operation. Name which layer owns each concern:
- MSW owns interception, matching, mocked network outcomes, request-contract simulation, and interception diagnostics;
testowns behavioral scope and the observation boundary;- the runner owns hooks, environments, timers, and concurrency syntax;
- the consuming data library owns retries, deduplication, cache lifetime, and cache isolation;
- the UI-testing library owns waiting for visible asynchronous outcomes.
Complete when: the request can be described independently of the client that sent it, and no neighboring owner's configuration is being smuggled into the MSW change.
3. Load the relevant branch
| Priority | Load when | Reference |
| 1 — Required | Adding or changing Node/browser setup, lifecycle hooks, worker script handling, unhandled-request policy, or concurrent-test isolation | references/setup-and-lifecycle.md |
| 1 — Required | Adding or changing HTTP handlers, matching, precedence, request parsing, HttpResponse, errors, streaming, passthrough, or bypass behavior | references/http-handlers-and-responses.md |
| 1 — Required | Adding or changing GraphQL operation matching, variables, errors, links, or batched queries | references/graphql.md |
| 1 — Required | Typing HTTP params/body/responses, GraphQL variables/results, or reusable handler/resolver factories | references/typescript.md |
| 1 — Required | Requests are not intercepted, the wrong handler wins, an unhandled warning appears, or lifecycle evidence is needed | references/debugging.md |
| 1 — Required | Upgrading MSW, mixed-major syntax exists, or Node/TypeScript/module requirements may change | references/migration.md |
Complete when: every active branch has loaded its reference and the examples match the installed major.
4. Implement the smallest network description
Keep reusable happy-path handlers as the baseline. Add scenario-specific runtime overrides at the closest test or development boundary. Match the protocol contract precisely and return the outcome the consumer must observe. When request validity matters, parse the real request and return the same class of response the service would produce for invalid input; do not turn the resolver into a spy assertion.
Use real application requests as evidence. Keep mock data and state only as faithful as the tested contract requires; do not recreate application business logic in handlers. Add abstraction only after handlers share meaningful response policy, not merely similar syntax.
Complete when: the intended request matches one known handler and produces one observable network outcome.
5. Verify
Run the narrowest request or test that proves interception, then the affected test suite and repository checks. For browser setup, verify worker registration, scope, and startup ordering. For Node setup, verify process lifecycle and handler cleanup. Use lifecycle events or strict unhandled configuration when matching is uncertain.
Compose with test when tests are added or changed. Invoke the consuming data-library owner for
cache, retry, stale-data, or request-deduplication behavior instead of prescribing cache clearing.
Complete when: setup, handler selection, response behavior, and cleanup are proven in each affected runtime.
Guardrails
- Add delay only when latency, loading, cancellation, or race behavior is the scenario under test.
- Choose the runner environment from the behavior and installed stack; MSW does not require JSDOM.
- Use real timers by default. Configure fake timers only for a runner-specific test that needs them.
- Choose relative, absolute, wildcard, regular-expression, or custom URL predicates from the actual request origin and matching contract; absolute URLs are not a universal requirement.
- Reset runtime handlers after isolated tests. Reset client caches only when the owning data library requires it for the behavior being tested.
- Prefer observable application outcomes over assertions that merely record that a request occurred; use lifecycle events only when a one-way request has no consumer-visible effect.
Handoff
Report the detected MSW version, Node/browser boundary, handlers and lifecycle changed, unhandled request policy, focused and broader verification, official documentation consulted, and any behavior left to the runner or consuming data library.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

