Skip to content
Skills Library
Programming · Building & coding

stackblitz-sdk-patterns

/stackblitz-sdk-patterns

Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter".

Licence
MIT
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter".

Triggers from the description

WebContainer SDK patternsmanage WebContainer lifecycleStackBlitz runtime adapter

Arguments

/stackblitz-sdk-patterns [project-path] [runtime-module]
Original author description

Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter".

How it works

  1. Overview
  2. Prerequisites
  3. Tool Discipline
  4. Current Contract
  5. Authentication
  6. Workflow
  7. Approval Boundaries
  8. Output
  9. Error Handling
  10. Examples
Original SKILL.md headings · 65 lines, 531 words
SKILL.md preview
---
name: stackblitz-sdk-patterns
description: >-
  Design a durable WebContainer lifecycle adapter for filesystem, process, event, preview, and teardown operations. Use when multiple UI components need WebContainer access or an integration has race-prone boot and cleanup logic. Trigger with "WebContainer SDK patterns", "manage WebContainer lifecycle", or "StackBlitz runtime adapter".
argument-hint: "[project-path] [runtime-module]"
allowed-tools: Read, Glob, Grep, WebFetch, Write, Edit
version: 1.7.0
author: Jeremy Longshore <jeremy@intentsolutions.io>
license: MIT
tags:
- saas
- stackblitz
- architecture
- webcontainers
model: inherit
effort: medium
compatibility: Designed for Claude Code
---
# WebContainer Lifecycle Adapter

## Overview

This skill creates or reviews one application-owned boundary around WebContainer startup and capabilities. The adapter makes boot idempotent, exposes explicit runtime states, tracks event unsubscriptions and processes, and prevents UI components from independently manipulating a shared instance.

## Prerequisites

- A named repository and the components that currently own runtime behavior
- The installed `@webcontainer/api` type definitions as the local API authority
- Expected mount, process, preview, export, and disposal use cases

## Tool Discipline

Use `Read`, `Glob`, and `Grep` to map imports, boot calls, process ownership, filesystem mutations, event subscriptions, and teardown paths. Use `WebFetch` only for current official StackBlitz or WebContainers documentation. Use `Write` or `Edit` after proposing the adapter boundary and compatibility impact.

## Current Contract

- Cache the boot promise, not only the resolved instance, so concurrent callers cannot race into two boots.
- Model at least idle, booting, ready, failed, and disposed states; make invalid transitions visible.
- Retain the unsubscribe function returned by `on()` and the handles returned by `spawn()`.
- Treat filesystem writes and `export()` as explicit data operations with caller-owned paths and size bounds.
- `teardown()` invalidates the instance, processes, and filesystem; call it only at the permanent owner boundary.
- Prefer adding preview instrumentation in the served application; use `setPreviewScript` only after reviewing its advanced-feature warning and compatibility risk.

## Authentication

The adapter may accept already-resolved configuration but must not expose secret values through state, logs, errors, or browser storage. Initialize commercial keys and organization auth before adapter boot through the dedicated preflight layer.

## Workflow

1. Inventory every WebContainer import, boot call, event listener, process handle, filesystem writer, and teardown call.
2. Define the adapter's state machine and minimum methods from observed consumers.
3. Centralize a single boot promise and make failed startup recoverable only through an explicit reset or disposal policy.
4. Wrap spawn with exit, output-bound, cancellation, and ownership metadata.
5. Wrap subscriptions so each consumer can unsubscribe and the owner can perform final cleanup.
6. Add focused concurrency, failure, HMR, and teardown tests before migrating consumers incrementally.

## Approval Boundaries

Do not migrate all consumers, change persistent/export behavior, terminate active processes, or alter production preview instrumentation without explicit scope. Show the compatibility plan and rollback before replacing an existing runtime singleton.

## Output

Return the lifecycle inventory, proposed state machine and API, migrated call sites, concurrency and cleanup evidence, authentication boundary, compatibility risks, and rollback procedure.

## Error Handling

| Condition | Response |
|---|---|
| Concurrent callers race | Share one boot promise and test simultaneous acquisition. |
| Process output never closes | Apply cancellation and output bounds; retain the process handle. |
| A consumer tears down globally | Move teardown to the permanent owner and give consumers scoped unsubscribe methods. |
| Installed types differ from docs | Follow the pinned local types and record the planned version review. |

## Examples

Given three React components that each call `boot()`, replace them with one tested adapter whose cached promise owns the runtime while components receive scoped filesystem, process, and subscription capabilities.

## Resources

- [Official StackBlitz and WebContainers references](references/official-docs.md)
- [WebContainer API reference](https://webcontainers.io/api)
- [API versioning and support](https://webcontainers.io/guides/api-support)
Files in this package (2)
  • SKILL.md 5 KB
  • references/official-docs.md 1 KB

Versions

The database has no other skills named stackblitz-sdk-patterns.

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 3c96ae5b9146 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100stackblitz-debug-bundle
    Produce a privacy-safe WebContainer diagnostic bundle with browser capability, isolation-header, lifecycle, event, process-exit, dependency, and resource evidence. Use when an incident needs a shareable artifact rather than ad hoc console screenshots. Trigger with "StackBlitz…
  • 100stackblitz-common-errors
    Diagnose WebContainer startup, isolation, Service Worker, dependency, process, preview, and browser failures from evidence before changing code or headers. Use when a StackBlitz runtime or embed fails, hangs, or behaves differently across browsers. Trigger with "StackBlitz…
  • 90runtime-adapter-authoring
    Create or review an adapter that connects shared application logic to a runtime-specific API. Use when supporting a new host, platform, provider, filesystem, database, or external service.
  • 95zoom-video-sdk-flutter
    Zoom Video SDK for Flutter. Use when building custom video session apps in Flutter with flutter_zoom_videosdk, event-driven architecture, session lifecycle handling, and mobile platform integration patterns.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.