Claude Code skill pack for StackBlitz (18 skills)
Installation
Open Claude Code and run this command:
/plugin install stackblitz-pack@claude-code-plugins-plus
Use --global to install for all projects, or --project for current project only.
What It Does
> 18 production-ready Claude Code skills for StackBlitz WebContainers -- real browser-based Node.js runtime code.
Skills (18)
'CI testing for WebContainer apps with Playwright browser tests.
StackBlitz Ci Integration
Overview
CI testing for WebContainer apps with Playwright browser tests.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'Fix WebContainer and StackBlitz errors: COOP/COEP, SharedArrayBuffer,.
StackBlitz Common Errors
Error Reference
SharedArrayBuffer is not defined
Cause: Missing cross-origin isolation headers.
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Fix: Add both headers to your server. In Vite: server.headers config.
Failed to boot WebContainer
Cause: Only one WebContainer instance allowed per page.
// BAD: Multiple boot calls
const wc1 = await WebContainer.boot();
const wc2 = await WebContainer.boot(); // Fails!
// GOOD: Singleton pattern
let instance: WebContainer | null = null;
async function getWC() {
if (!instance) instance = await WebContainer.boot();
return instance;
}
npm install hangs or fails
Cause: Large dependency tree or network issue in WebContainer.
// Use --prefer-offline and minimal deps
const proc = await wc.spawn('npm', ['install', '--prefer-offline']);
const code = await proc.exit;
if (code !== 0) {
console.error('Install failed, retrying...');
const retry = await wc.spawn('npm', ['install']);
await retry.exit;
}
server-ready event never fires
Cause: Application not listening on a port.
// Ensure your app calls listen()
// app.listen(3000) -- required for server-ready event
// Also check process exit code for crashes
wc.on('error', (err) => console.error('WC error:', err));
File operations fail with ENOENT
Cause: Parent directory doesn't exist.
// Create parent directories first
await wc.fs.mkdir('/src/components', { recursive: true });
await wc.fs.writeFile('/src/components/Button.tsx', content);
Quick Diagnostic
// Check WebContainer state
async function diagnose(wc: WebContainer) {
try {
await wc.fs.readdir('/');
console.log('FS: OK');
} catch { console.error('FS: FAILED'); }
try {
const proc = await wc.spawn('node', ['-v']);
await proc.exit;
console.log('Node: OK');
} catch { console.error('Node: FAILED'); }
}
Error Handling
| Error | Retryable | Action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Missing COOP/COEP | No | Fix server headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Multiple boot | No | Use singleton pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| npm install fail | Yes | Retry once, then report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENOENT | No | Create parent dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Process crash | Yes | Restart process |
| Error | Cause | Solution |
|---|---|---|
| Embed shows loading forever | Missing template files | Ensure package.json is included |
clickToLoad not working |
SDK version mismatch | Update @stackblitz/sdk |
| GitHub embed 404 | Wrong repo path | Use owner/repo/path/to/subdir format |
Resources
- StackBlitz SDK
-
'StackBlitz pricing tiers: free embedding, WebContainer API commercial.
ReadGrepStackBlitz Cost Tuning
Overview
StackBlitz pricing tiers: free embedding, WebContainer API commercial licensing.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
Issue Cause Solution Configuration error Wrong setup Check WebContainer docs Build failure Missing deps Run npm install Resources
Next Steps
See related skills for more patterns.
'Collect WebContainer diagnostic info: boot state, file system, process.
StackBlitz Debug Bundle
Overview
Collect WebContainer diagnostic info: boot state, file system, process list.
Instructions
Step 1: Check Boot State
async function diagnoseWebContainer(wc: WebContainer) {
const report: Record<string, any> = {};
// File system check
try {
const entries = await wc.fs.readdir('/');
report.filesystem = { status: 'ok', rootEntries: entries.length };
} catch (e: any) {
report.filesystem = { status: 'error', message: e.message };
}
// Node.js check
try {
const proc = await wc.spawn('node', ['-e', 'console.log(JSON.stringify({version: process.version, arch: process.arch}))']);
let output = '';
proc.output.pipeTo(new WritableStream({ write(data) { output += data; } }));
await proc.exit;
report.node = JSON.parse(output);
} catch (e: any) {
report.node = { status: 'error', message: e.message };
}
// Memory check
try {
const proc = await wc.spawn('node', ['-e', 'console.log(JSON.stringify(process.memoryUsage()))']);
let output = '';
proc.output.pipeTo(new WritableStream({ write(data) { output += data; } }));
await proc.exit;
report.memory = JSON.parse(output);
} catch { report.memory = 'unavailable'; }
return report;
}
Step 2: Check Browser Support
function checkBrowserSupport() {
return {
sharedArrayBuffer: typeof SharedArrayBuffer !== 'undefined',
crossOriginIsolated: window.crossOriginIsolated,
serviceWorker: 'serviceWorker' in navigator,
userAgent: navigator.userAgent,
};
}
Error Handling
| Check | Expected | Failed Action |
|---|---|---|
| SharedArrayBuffer | defined | Add COOP/COEP headers |
| crossOriginIsolated | true | Check all headers present |
| Node.js version | v18+ | WebContainer ships its own |
| Root FS entries | > 0 | Re-mount files |
Resources
Next Steps
For resource limits, see stackblitz-rate-limits.
'Deploy WebContainer apps to Vercel, Netlify with proper COOP/COEP headers.
StackBlitz Deploy Integration
Overview
Deploy WebContainer apps to Vercel, Netlify with proper COOP/COEP headers.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'Boot a WebContainer, mount files, install npm packages, and run a dev.
StackBlitz Hello World
Overview
Boot a WebContainer, mount a file system tree, install dependencies with npm, and start a dev server -- all running inside the browser tab. No backend server needed.
Prerequisites
@webcontainer/apiinstalled (seestackblitz-install-auth)- Cross-origin isolation headers configured
- Modern browser (Chrome 90+, Firefox 90+, Safari 16.4+)
Instructions
Step 1: Define File System Tree
import { WebContainer, FileSystemTree } from '@webcontainer/api';
const files: FileSystemTree = {
'package.json': {
file: {
contents: JSON.stringify({
name: 'wc-hello',
scripts: { start: 'node index.js', dev: 'nodemon index.js' },
dependencies: { express: '^4.18.0' },
}),
},
},
'index.js': {
file: {
contents: `
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello from WebContainer!'));
app.listen(3000, () => console.log('Server running on port 3000'));
`.trim(),
},
},
src: {
directory: {
'utils.js': { file: { contents: 'module.exports = { greet: (n) => "Hello " + n };' } },
},
},
};
Step 2: Boot and Mount
const wc = await WebContainer.boot();
await wc.mount(files);
console.log('Files mounted. Installing dependencies...');
Step 3: Install Dependencies
const installProcess = await wc.spawn('npm', ['install']);
// Stream install output
installProcess.output.pipeTo(new WritableStream({
write(data) { console.log(data); },
}));
const installCode = await installProcess.exit;
if (installCode !== 0) throw new Error(`npm install failed: exit ${installCode}`);
console.log('Dependencies installed.');
Step 4: Start Dev Server
const serverProcess = await wc.spawn('npm', ['start']);
serverProcess.output.pipeTo(new WritableStream({
write(data) { console.log(data); },
}));
// Listen for server-ready event
wc.on('server-ready', (port, url) => {
console.log(`Server ready at ${url} (port ${port})`);
// Display in iframe
document.querySelector('iframe')!.src = url;
});
Output
added 57 packages in 3s
Dependencies installed.
Server running on port 3000
Server ready at https://xxx.webcontainer.io (port 3000)
Error Handling
| Error | Cause | Solution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
npm install hangs |
Large dependency tree | Use --prefer-offline or fewer deps |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Error | Cause | Solution |
|---|---|---|
SharedArrayBuffer is not defined |
Missing COOP/COEP headers | Add cross-origin isolation headers |
Failed to boot |
Multiple instances | Only one WebContainer per page |
Not in secure context |
HTTP instead of HTTPS | Use HTTPS or localhost |
Resources
Next Steps
Proceed to stackblitz-hello-world for your first WebContainer project.
'Configure local development for WebContainer applications with hot reload.
StackBlitz Local Dev Loop
Overview
Set up a Vite-based development environment for WebContainer applications with cross-origin headers, hot module replacement, and Vitest for testing file system operations.
Instructions
Step 1: Vite Project with WebContainers
npm create vite@latest wc-app -- --template vanilla-ts
cd wc-app
npm install @webcontainer/api
Step 2: Configure Vite Headers
// vite.config.ts
import { defineConfig } from 'vite';
export default defineConfig({
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
},
},
});
Step 3: Test WebContainer Operations
// tests/webcontainer.test.ts
import { describe, it, expect } from 'vitest';
// Note: WebContainer tests require a browser environment
// Use Playwright for full integration tests
describe('FileSystemTree Builder', () => {
it('creates valid tree from flat paths', () => {
const tree = buildFileTree({
'src/index.ts': 'console.log("hello")',
'package.json': '{"name":"test"}',
});
expect(tree['package.json']).toHaveProperty('file');
expect(tree.src).toHaveProperty('directory');
});
});
function buildFileTree(flatFiles: Record<string, string>) {
const tree: any = {};
for (const [path, contents] of Object.entries(flatFiles)) {
const parts = path.split('/');
let current = tree;
for (let i = 0; i < parts.length - 1; i++) {
if (!current[parts[i]]) current[parts[i]] = { directory: {} };
current = current[parts[i]].directory;
}
current[parts[parts.length - 1]] = { file: { contents } };
}
return tree;
}
Error Handling
| Error | Cause | Solution |
|---|---|---|
| COOP/COEP errors | Missing headers | Add to vite.config.ts |
SharedArrayBuffer undefined |
Not cross-origin isolated | Check response headers |
| Test failures | WebContainer needs browser | Use Playwright for integration |
Resources
Next Steps
Proceed to stackblitz-sdk-patterns for production patterns.
'Optimize WebContainer boot time, file system mounts, and process spawning.
StackBlitz Performance Tuning
Overview
Optimize WebContainer boot time, file system mounts, and process spawning.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'Production checklist for WebContainer apps: headers, browser support,.
StackBlitz Prod Checklist
Overview
Production checklist for WebContainer apps: headers, browser support, fallbacks.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'WebContainer resource limits: memory, CPU, file system size, process.
StackBlitz Rate Limits
Overview
WebContainer resource limits: memory, CPU, file system size, process count.
Instructions
Step 1: WebContainer Resource Limits
| Resource | Limit | Notes |
|---|---|---|
| Memory | ~2GB | Shared with browser tab |
| File system | Ephemeral, in-memory | Lost on page refresh |
| Processes | Multiple concurrent | Each consumes memory |
| Network | HTTP only | No raw TCP/UDP sockets |
| npm packages | Most work | Native addons not supported |
Step 2: Handle Memory Pressure
// Monitor memory usage inside WebContainer
const proc = await wc.spawn('node', ['-e', `
setInterval(() => {
const mem = process.memoryUsage();
const mbUsed = Math.round(mem.heapUsed / 1024 / 1024);
if (mbUsed > 500) console.warn('High memory: ' + mbUsed + 'MB');
}, 5000);
`]);
Step 3: Optimize File System Size
// Mount only essential files -- skip test files, docs, etc.
const productionFiles: FileSystemTree = {
'package.json': { file: { contents: minimalPackageJson } },
src: { directory: { /* only source files */ } },
// Skip: tests/, docs/, .git/, large assets
};
await wc.mount(productionFiles);
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Tab crashes | OOM | Reduce mounted files, fewer deps |
| Slow npm install | Large deps | Use --prefer-offline, fewer packages |
| Process killed | Memory limit | Monitor with memoryUsage() |
Resources
Next Steps
For security, see stackblitz-security-basics.
'Production architecture for WebContainer-powered browser IDEs and playgrounds.
StackBlitz Reference Architecture
Overview
Production architecture for WebContainer-powered browser IDEs and playgrounds.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'Production patterns for WebContainer API: file system operations, process.
StackBlitz SDK Patterns
Overview
Production patterns for the WebContainer API: singleton boot, file system CRUD, process spawning and management, jsh interactive shell, and the StackBlitz SDK for embedding projects.
Instructions
Step 1: Singleton WebContainer Instance
import { WebContainer } from '@webcontainer/api';
let instance: WebContainer | null = null;
export async function getWebContainer(): Promise<WebContainer> {
if (!instance) {
instance = await WebContainer.boot();
}
return instance;
}
// Teardown
export async function teardownWebContainer() {
if (instance) {
instance.teardown();
instance = null;
}
}
Step 2: File System Operations
const wc = await getWebContainer();
// Write file
await wc.fs.writeFile('/src/app.ts', 'export const hello = "world";');
// Read file
const content = await wc.fs.readFile('/src/app.ts', 'utf-8');
// Read directory
const entries = await wc.fs.readdir('/src', { withFileTypes: true });
entries.forEach(entry => {
console.log(`${entry.name} (${entry.isDirectory() ? 'dir' : 'file'})`);
});
// Create directory
await wc.fs.mkdir('/src/components', { recursive: true });
// Delete file
await wc.fs.rm('/src/old.ts');
// Delete directory
await wc.fs.rm('/dist', { recursive: true });
// Watch for changes
wc.fs.watch('/src', { recursive: true }, (event, filename) => {
console.log(`${event}: ${filename}`);
});
Step 3: Process Management
// Spawn a process
const proc = await wc.spawn('node', ['script.js']);
// Stream stdout
const reader = proc.output.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break;
console.log(value);
}
// Write to stdin
const writer = proc.input.getWriter();
await writer.write('user input\n');
await writer.close();
// Wait for exit
const exitCode = await proc.exit;
// Kill a process
proc.kill();
Step 4: jsh Interactive Shell
// jsh is WebContainer's built-in shell
const jshProcess = await wc.spawn('jsh', {
terminal: { cols: 80, rows: 24 },
});
// Connect to xterm.js
import { Terminal } from 'xterm';
const terminal = new Terminal();
terminal.open(document.getElementById('terminal')!);
jshProcess.output.pipeTo(new WritableStream({
write(data) { terminal.write(data); },
}));
terminal.onData((data) => {
const writer = jshProcess.input.getWriter();
writer.write(data);
writer.releaseLock();
});
Step 5: StackBlitz SDK (Embedding)
import sdk from '@stackblitz/sdk';
// Embed an existing project
sdk.embedProjectId('container', &'Secure WebContainer deployments: CSP headers, sandbox isolation, input.
StackBlitz Security Basics
Overview
Secure WebContainer deployments: CSP headers, sandbox isolation, input validation.
Instructions
Step 1: WebContainer Security Model
WebContainers run in the browser sandbox -- no access to host filesystem, network is limited to HTTP, and all code runs in the user's browser tab. Key security points:
// WebContainers are inherently sandboxed:
// - No file system access to host
// - No raw network sockets
// - Memory isolated to browser tab
// - Cross-origin isolation via COOP/COEP headers
Step 2: Validate User Input
// If users can provide code to run in WebContainer, validate:
function sanitizeFileTree(tree: FileSystemTree): FileSystemTree {
const sanitized: FileSystemTree = {};
for (const [name, entry] of Object.entries(tree)) {
// Block path traversal
if (name.includes('..') || name.startsWith('/')) continue;
// Block sensitive files
if (name === '.env' || name.endsWith('.key')) continue;
sanitized[name] = entry;
}
return sanitized;
}
Step 3: Content Security Policy
Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; frame-src https://*.webcontainer.io;
Security Checklist
- [ ] COOP/COEP headers set correctly
- [ ] User-provided code sandboxed in WebContainer
- [ ] No secrets passed to WebContainer file system
- [ ] CSP headers configured
- [ ] Input validation on file paths
Resources
Next Steps
For production, see stackblitz-prod-checklist.
'Migrate between WebContainer API versions and StackBlitz SDK updates.
StackBlitz Upgrade Migration
Overview
Migrate between WebContainer API versions and StackBlitz SDK updates.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
'WebContainer lifecycle events: server-ready, port changes, error handling.
StackBlitz Webhooks Events
Overview
WebContainer lifecycle events: server-ready, port changes, error handling.
Instructions
Refer to the WebContainer API documentation for detailed guidance.
See the core workflow skills for implementation patterns.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Configuration error | Wrong setup | Check WebContainer docs |
| Build failure | Missing deps | Run npm install |
Resources
Next Steps
See related skills for more patterns.
Ready to use stackblitz-pack?
Related Plugins
supabase-pack
Complete Supabase integration skill pack with 30 skills covering authentication, database, storage, realtime, edge functions, and production operations. Flagship+ tier vendor pack.
vercel-pack
Complete Vercel integration skill pack with 30 skills covering deployments, edge functions, preview environments, performance optimization, and production operations. Flagship+ tier vendor pack.
clay-pack
Complete Clay integration skill pack with 30 skills covering data enrichment, waterfall workflows, AI agents, and GTM automation. Flagship+ tier vendor pack.
cursor-pack
Complete Cursor integration skill pack with 30 skills covering AI code editing, composer workflows, codebase indexing, and productivity features. Flagship+ tier vendor pack.
exa-pack
Complete Exa integration skill pack with 30 skills covering neural search, semantic retrieval, web search API, and AI-powered discovery. Flagship+ tier vendor pack.
firecrawl-pack
Complete Firecrawl integration skill pack with 30 skills covering web scraping, crawling, markdown conversion, and LLM-ready data extraction. Flagship+ tier vendor pack.