stackblitz-local-dev-loop
Establish a reproducible local development and browser-test loop for a WebContainer host, including isolation-header assertions, single-boot behavior under HMR, and cleanup checks. Use when a StackBlitz integration works manually but lacks dependable regression coverage. Trigger with "test WebContainers locally", "StackBlitz dev loop", or "WebContainer Playwright test".
Allowed Tools
Provided by Plugin
stackblitz-pack
Production StackBlitz workflows for WebContainer lifecycle, embeds, testing, diagnostics, capacity, and security (10 skills)
Installation
This skill is included in the stackblitz-pack plugin:
/plugin install stackblitz-pack@claude-code-plugins-plus
Click to copy
Instructions
WebContainer Local Development Loop
Overview
This skill turns a manually tested WebContainer host into a repeatable local loop. It separates pure file-tree and state-machine tests from browser integration tests that require SharedArrayBuffer, Service Workers, WebAssembly, and real response headers.
Prerequisites
- A named host application with an existing test framework or permission to add focused coverage
- A supported desktop browser available to the project's browser-test runner
- The repository's normal local HTTPS or localhost convention
Tool Discipline
Use Read, Glob, and Grep to locate runtime construction, HMR boundaries, response headers, unit tests, and browser tests. Use WebFetch only for current official StackBlitz or WebContainers documentation. Use Write or Edit for minimal user-requested tests and configuration.
Current Contract
- Unit-test pure transformations such as flat-files-to-
FileSystemTreewithout booting WebContainers. - Test actual boot, process, Service Worker, and preview behavior in a real browser runner rather than a DOM-only simulator.
- Assert the final document is a secure context and
crossOriginIsolatedbefore boot. - Preserve one boot promise across HMR; a module reload must not create a second concurrent instance.
- Exercise disposal separately from HMR so
teardown()does not invalidate an instance still owned by the current page.
Authentication
Use synthetic public dependencies by default. If the browser test requires licensed or private-package access, bind credentials through the CI secret store, restrict the test environment, redact logs, and skip with an explicit reason when authorized credentials are unavailable.
Workflow
- Map pure logic, browser-only logic, startup ownership, and deployment-header ownership.
- Add fast unit tests for file-tree validation, state transitions, path policy, and bounded log formatting.
- Add one browser smoke test that verifies isolation, boots once, mounts a synthetic fixture, observes a zero-exit command, and reaches preview readiness.
- Trigger the repository's HMR path and confirm the boot owner remains singular.
- Exercise navigation/disposal and confirm listeners and processes are released without breaking a surviving owner.
- Run the narrow test first, then the project's normal lint, typecheck, and browser-test gates.
Approval Boundaries
Do not weaken browser security flags, disable isolation checks, commit credentials, or make a flaky integration test silently optional. Changes to shared CI browsers, production headers, or licensed secrets require explicit authorization.
Output
Return the test-layer map, exact assertions, browsers exercised, commands run, HMR and cleanup evidence, skips with reasons, changed files, and remaining platform limitations.
Error Handling
| Condition | Response |
|---|---|
| DOM simulator cannot boot | Move runtime behavior to a real browser test; keep only pure logic in unit tests. |
| HMR causes a second boot | Hoist and cache the boot promise at the application's stable ownership boundary. |
| CI lacks isolation | Inspect the served response and proxy chain; do not launch with unsafe browser flags. |
| Browser support differs | Record the exact supported/beta behavior rather than declaring universal compatibility. |
Examples
Given a Vite host with Playwright, add a pure FileSystemTree unit test and one Chromium smoke test that asserts crossOriginIsolated, observes one boot, receives a preview URL, and cleans up after navigation.