stackblitz-core-workflow-a
Build a browser-based code editor with WebContainers: file tree, editor, terminal, and preview. Use when creating interactive coding environments, building educational tools, or embedding development environments in web apps. Trigger: "webcontainer IDE", "browser IDE", "stackblitz editor", "code playground".
What this skill does
# StackBlitz Core Workflow A: Browser IDE
## Overview
Build a complete browser-based IDE using WebContainers: file explorer, code editor (Monaco/CodeMirror), integrated terminal (xterm.js + jsh), and live preview iframe. This is the architecture behind bolt.new.
## Instructions
### Step 1: HTML Layout
```html
<div id="app">
<div id="file-tree"></div>
<div id="editor"></div>
<div id="terminal"></div>
<iframe id="preview"></iframe>
</div>
```
### Step 2: Boot and Mount Project
```typescript
import { WebContainer, FileSystemTree } from '@webcontainer/api';
const files: FileSystemTree = {
'package.json': {
file: { contents: JSON.stringify({
name: 'playground', type: 'module',
scripts: { dev: 'vite' },
dependencies: { vite: '^5.0.0' },
}) },
},
'index.html': {
file: { contents: '<!DOCTYPE html><html><body><div id="app"></div><script type="module" src="/src/main.js"></script></body></html>' },
},
src: { directory: {
'main.js': { file: { contents: 'document.getElementById("app").innerHTML = "<h1>Hello!</h1>";' } },
}},
};
const wc = await WebContainer.boot();
await wc.mount(files);
```
### Step 3: File Tree with Live Updates
```typescript
async function renderFileTree(path = '/') {
const entries = await wc.fs.readdir(path, { withFileTypes: true });
const tree = document.getElementById('file-tree')!;
for (const entry of entries) {
if (entry.name === 'node_modules') continue;
const fullPath = `${path}${path === '/' ? '' : '/'}${entry.name}`;
const el = document.createElement('div');
el.textContent = entry.isDirectory() ? `๐ ${entry.name}` : `๐ ${entry.name}`;
el.onclick = async () => {
if (!entry.isDirectory()) {
const content = await wc.fs.readFile(fullPath, 'utf-8');
editor.setValue(content); // Monaco editor
currentFile = fullPath;
}
};
tree.appendChild(el);
}
}
```
### Step 4: Save Editor Changes to WebContainer
```typescript
let currentFile = '/src/main.js';
// Monaco editor onChange
editor.onDidChangeModelContent(async () => {
const content = editor.getValue();
await wc.fs.writeFile(currentFile, content);
// Vite HMR will auto-reload the preview
});
```
### Step 5: Terminal + Preview
```typescript
// Terminal
const jsh = await wc.spawn('jsh', { terminal: { cols: 80, rows: 12 } });
jsh.output.pipeTo(new WritableStream({
write(data) { terminal.write(data); },
}));
// Install and start dev server
const install = await wc.spawn('npm', ['install']);
await install.exit;
await wc.spawn('npm', ['run', 'dev']);
// Preview iframe
wc.on('server-ready', (port, url) => {
document.getElementById('preview')!.src = url;
});
```
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Preview blank | Server not ready yet | Wait for `server-ready` event |
| HMR not working | Vite not running | Check npm install succeeded |
| File tree empty | Mount failed | Verify FileSystemTree structure |
## Resources
- [WebContainer Tutorial](https://webcontainers.io/tutorial/2-setting-up-webcontainers)
- [bolt.new Source](https://github.com/stackblitz/bolt.new)
- [Add Interactivity](https://webcontainers.io/tutorial/7-add-interactivity)
## Next Steps
For embedding and sharing projects, see `stackblitz-core-workflow-b`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.