Skip to content

feat: Oxide Forge — in-browser Claude code generation, hot-loaded as wasm#39

Merged
niklabh merged 2 commits into
mainfrom
oxide-forge
May 3, 2026
Merged

feat: Oxide Forge — in-browser Claude code generation, hot-loaded as wasm#39
niklabh merged 2 commits into
mainfrom
oxide-forge

Conversation

@niklabh
Copy link
Copy Markdown
Owner

@niklabh niklabh commented May 3, 2026

What's in this PR

Forge runtime (oxide-browser/)

  • src/forge.rs (new, ~1.2k lines): session state, Anthropic SSE streaming,
    template scaffolding, build pipeline with up to 3 auto-retry rounds that
    feed cargo errors back to Claude, artifact path resolution.
  • src/ui.rs: native GPUI Forge page — prompt box, list view of past
    creations, streaming code preview, build console, "Choose folder"
    picker, and "Open in tab" / revise actions.
  • src/lib.rs: wires oxide://forge into the URL router.
  • Default model claude-opus-4-7, override via OXIDE_FORGE_MODEL.
    Output dir defaults to target/forge/, override via OXIDE_FORGE_DIR
    or the in-app folder picker.

Forge knowledge base (forge/skills/oxide-wasm-app/)

Packaged as an agentskills.io-compatible
Agent Skill so the same prompts can be reused from Claude Code,
Cursor, OpenCode, and any other skills-aware client.

  • SKILL.md — terse generation contract with YAML frontmatter (name,
    description).
  • references/CAPABILITIES.md — every public SDK symbol with full
    signatures.
  • references/PATTERNS.md — idiomatic state, layout, and event patterns.
  • references/RECIPES.md — 12 copy-pasteable snippets.
  • forge/README.md — explains the skill layout and how external agents
    can pick it up.
  • forge/DEMO_PROMPTS.md — 10 curated prompts for live demos.
  • forge/templates/base/ — minimal cdylib Cargo scaffold copied for
    every generation; oxide-sdk path is rewritten to an absolute path so
    projects build from any user-selected output folder.

Revision flow

Every creation is persisted in a list view. Selecting one and prompting
again sends the current src/lib.rs back to Claude, which rewrites it,
rebuilds it, and copies the finished <slug>.wasm back into that
creation's folder.

Examples and content

  • examples/gradient-demo/ — reference guest app showcasing canvas + state.
  • content/video/oxide-promo/ — Forge promo site, hyperframes, script,
    design notes, rendered mp4 (≈18 MB), and frame stills used in the
    launch video. Also content/video/video-demo.md writeup.

Docs

  • README.md and claude-hackathon.md updated with the architecture
    diagram, folder-picker / revision flow, and skill layout.

Security

Forge adds no new host privileges. Generated .wasm modules load
through the existing wasmtime linker with the same capability set as any
other guest. The only privileged operation Forge itself performs is
shelling out to host cargo to build the project — an explicit native
developer workflow, not exposed to guests.

Configuration

Env var Default Purpose
ANTHROPIC_API_KEY (required) Claude API auth
OXIDE_FORGE_MODEL claude-opus-4-7 Override model
OXIDE_FORGE_DIR target/forge/ Output dir for generated projects + wasm

Test plan

  • cargo fmt --all && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace
  • cargo build -p oxide-browser
  • cargo build --target wasm32-unknown-unknown --release -p gradient-demo
  • cargo run -p oxide-browser → URL bar → oxide://forge
    • Prompt: "a counter app with + and - buttons" → builds and opens in a new tab
    • Prompt that intentionally references a missing API → confirm
      the auto-retry loop surfaces the error after 3 rounds
    • Select an existing creation, prompt "make the buttons larger" →
      confirm revision rebuilds and reloads the same slug
    • "Choose folder" picker writes the project + <slug>.wasm into
      the selected directory
    • OXIDE_FORGE_DIR=/tmp/forge cargo run -p oxide-browser honors the env var
  • Run a few forge/DEMO_PROMPTS.md prompts end-to-end

Notes for reviewers

  • The video assets in content/video/oxide-promo/renders/ include two
    .mp4 files (~10 MB and ~18 MB). They will be permanent in repo
    history. If you'd prefer them out of git, happy to move them to LFS
    or strip them from this PR before merge.
  • The skill folder is a plain directory with SKILL.md + references/
    per the agentskills.io spec, so symlinking/copying it into
    ~/.claude/skills/ or .cursor/skills/ should "just work" for those
    hosts.

Summary by CodeRabbit

Release Notes

  • New Features

    • Oxide Forge (oxide://forge): Generate WebAssembly applications from natural language prompts with iterative revision and automatic rebuild on failures.
    • Added gradient-demo example application showcasing canvas rendering.
  • Documentation

    • Comprehensive Forge guides including capability references, code patterns, recipes, and demo prompts.
    • Promotional video content and design specifications.
  • Chores

    • Version bumped to 0.6.1 across oxide-browser and oxide-sdk.

niklabh and others added 2 commits April 23, 2026 23:51
… revisions

Restructure the Forge knowledge base into an agentskills.io-compatible
Agent Skill at forge/skills/oxide-wasm-app/ so the same prompts are
reusable from Claude Code, Cursor, and other skills-aware clients.
SYSTEM_PROMPT.md becomes SKILL.md (with YAML frontmatter); CAPABILITIES,
PATTERNS, and RECIPES move under references/.

Forge host changes (oxide-browser/src/forge.rs, ui.rs):
- Build the system prompt by stripping SKILL.md frontmatter and
  concatenating every references/*.md file.
- Persist generations in a list view; selecting an entry and prompting
  again sends the current src/lib.rs back to Claude for a revision and
  copies the rebuilt <slug>.wasm into that creation's folder.
- Add a native "Choose folder" picker (and OXIDE_FORGE_DIR env var) so
  generated projects and wasm artifacts can live outside target/forge/.
- Rewrite the copied oxide-sdk path dependency to an absolute path so
  projects build from any user-selected output folder.
- Default model bumped to claude-opus-4-7 (override via OXIDE_FORGE_MODEL).

Docs and assets:
- Update README.md, claude-hackathon.md, and forge/README.md to describe
  the skill layout, revision flow, and folder picker.
- Add examples/gradient-demo/ as a reference guest app.
- Add content/video/oxide-promo/ with the Forge promo site, hyperframes,
  script, design notes, and rendered mp4 + frame stills.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces Oxide Forge, an AI-native app generation system that enables users to describe WebAssembly applications in plain English via a oxide://forge interface. Claude streams Rust code, which is compiled to WASM and hot-loaded into a new browser tab. The implementation includes core orchestration logic, browser UI integration, a skill-based agent kit with templates and capability documentation, and supporting examples and promotional content.

Changes

Oxide Forge Core Implementation & UI Integration

Layer / File(s) Summary
Module Infrastructure
oxide-browser/src/lib.rs
Exports new forge module to crate public API.
Session & State Management
oxide-browser/src/forge.rs
Implements ForgeState lifecycle (create/revise/snapshot sessions), ForgePhase enum tracking creation progress (streaming, building, success/error states), and session persistence to forge.json.
Anthropic Streaming & Build Orchestration
oxide-browser/src/forge.rs
Drives anthropic Messages API with stream=true, parses server-sent event boundaries/deltas, extracts Rust code blocks, scaffolds isolated Cargo projects from templates, runs cargo build --target wasm32-unknown-unknown --release, and implements auto-retry on build failure (up to 3 attempts with error-informed re-prompting).
System Prompt Assembly
oxide-browser/src/forge.rs
Loads Agent Skill (SKILL.md) by stripping YAML frontmatter and concatenating deterministically-sorted reference documents (CAPABILITIES.md, PATTERNS.md, RECIPES.md) into final system prompt.
Routing & Page Structure
oxide-browser/src/ui.rs
Adds InternalPage::Forge variant, routes oxide://forge URLs, and extends TabState with Forge-specific fields (forge_prompt, forge_session_id).
UI Rendering & Interaction
oxide-browser/src/ui.rs
Implements Forge page layout with creations sidebar (list/select existing sessions), detail panel (code/build log/error display), API-key input field, prompt textarea, and action buttons (Create/Revise/Build/Run-in-new-tab/Delete). Handles keyboard navigation (Enter/Escape/Backspace) for focused inputs and file picker for output-directory selection.
Configuration & Version Bump
.gitignore, oxide-browser/Cargo.toml, oxide-sdk/Cargo.toml
Adds Forge build artifact patterns to .gitignore (/target/forge/, forge/templates/*/target/); bumps oxide-browser and oxide-sdk versions to 0.6.1.

Forge Kit, Templates, Examples & Documentation

Layer / File(s) Summary
Skill Definition & Specification
forge/skills/oxide-wasm-app/SKILL.md
Defines Agent Skill YAML frontmatter, output contract (single fenced Rust src/lib.rs), absolute generation rules (#[no_mangle] exports, import/async/panic constraints, fuel-aware work, stable widget IDs), preferred patterns (UI, fetch, websocket, WebRTC, storage), anti-patterns, and capability proposal comment format.
Capability Catalog
forge/skills/oxide-wasm-app/references/CAPABILITIES.md
Authoritative catalog of oxide-sdk v0.6 public symbols available to guest apps, organized by subsystem (canvas, UI widgets, GPU, logging, HTTP, protobuf, storage, audio, video, WebRTC, WebSocket, MIDI, input, clipboard, time, events, crypto, navigation, files, geolocation, notifications, dynamic modules).
Idiomatic Patterns & Recipes
forge/skills/oxide-wasm-app/references/PATTERNS.md, forge/skills/oxide-wasm-app/references/RECIPES.md
Pattern guidance (state management, immediate-mode UI, fixed timestep, streaming fetch, WebSocket/WebRTC, timers, events, layout sizing, numeric formatting) and copy-pasteable Rust code snippets (counters, drag-and-drop, LLM SSE streaming, WebSocket echo, WebRTC, canvas brush, KV storage, GPU compute, audio, layout, modal, JSON helpers).
Template Project Structure
forge/templates/base/Cargo.toml, forge/templates/base/src/lib.rs
Scaffolding template for generated apps: isolated Cargo workspace, cdylib library configuration, oxide-sdk path dependency, release optimizations (size/LTO/stripping), and minimal boilerplate start_app()/on_frame() entry points.
Kit Documentation & Demo Guidance
forge/README.md, forge/DEMO_PROMPTS.md
Kit overview (directory layout, generation flow, system prompt assembly, bundled references), usage instructions for other agents, update procedure for SDK changes, and 10 structured Forge demo prompts (canvas, counter, Game of Life, whiteboard, streaming chat, WebSocket, WebRTC, GitHub API, GPU Mandelbrot, MIDI synth) with iteration tips.
Example Application
examples/gradient-demo/Cargo.toml, examples/gradient-demo/src/lib.rs, Cargo.toml
Registers examples/gradient-demo as workspace member; implements a responsive gradient palette card grid demo with hero/footer bars and GSAP-like animations, demonstrating oxide-sdk canvas APIs, responsive layout calculation, and color rendering.
Repository Documentation & Planning
README.md, claude-hackathon.md
Updates main README with Opus 4.7 badge, Forge overview, project structure (forge.rs), and "Oxide Forge — AI-native app generation" section describing flow/retry behavior/setup; adds hackathon planning document specifying phases (kit creation, host scaffolding, UI, hot-loading, auto-retry, demo apps), phase-wise deliverables checklist, verification commands, risks/mitigations, and attribution.
Promotional & Video Content
content/video/*
Adds Oxide technical description, HyperFrames composition standards (AGENTS.md, CLAUDE.md, DESIGN.md), promo animation/metadata (index.html with 81-second GSAP timeline, meta.json, hyperframes.json config), promo script, and 3-minute video demo script (Cold open → Acts 1–4 → Close with time-coded visuals/narration/on-screen text).

Sequence Diagram

sequenceDiagram
    actor User
    participant Browser as Browser<br/>(oxide://forge)
    participant ForgeState as ForgeState<br/>(Session Mgmt)
    participant Anthropic as Anthropic<br/>API
    participant Host as Host<br/>(cargo build)
    participant Sandbox as Sandbox<br/>(WASM Runtime)

    User->>Browser: Enter prompt + submit
    Browser->>ForgeState: start(prompt)
    ForgeState->>ForgeState: Scaffold Cargo project
    ForgeState->>Anthropic: POST /messages<br/>stream=true<br/>system_prompt
    loop Stream chunks
        Anthropic-->>ForgeState: SSE delta
        ForgeState->>ForgeState: Buffer code
        ForgeState->>Browser: Update snapshot<br/>(streaming phase)
    end
    ForgeState->>ForgeState: Extract Rust block
    ForgeState->>ForgeState: Write src/lib.rs
    ForgeState->>Host: cargo build<br/>--target wasm32-unknown-unknown
    alt Build success
        Host-->>ForgeState: forge_app.wasm
        ForgeState->>ForgeState: Copy artifact<br/>Set BuildOk phase
        ForgeState->>Browser: Update snapshot
        User->>Browser: Click "Run in new tab"
        Browser->>Sandbox: Load WASM
        Sandbox->>User: Display app
    else Build failure
        Host-->>ForgeState: stderr log
        alt Auto-retry enabled & attempts remain
            ForgeState->>Anthropic: Retry with<br/>build log context
            loop Retry stream
                Anthropic-->>ForgeState: SSE delta
            end
            ForgeState->>Host: cargo build
        else No retries
            ForgeState->>Browser: Show error + log
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

This PR spans multiple heterogeneous systems (streaming orchestration, async build execution, UI state management, keyboard routing) with significant logic density in forge.rs (Anthropic SSE parsing, session persistence, retry loops) and substantial UI changes (ui.rs, 1055 lines). The interconnection between core Forge logic, browser UI, templating, and skill documentation requires tracing logic across multiple layers and verifying contract compliance (Skill.md rules, template isolation, artifact paths, session cleanup).

Possibly related PRs

  • feat: add multi-tab support with per-tab isolation #8: Modifies oxide-browser/src/ui.rs to alter TabState fields and per-tab routing; this PR extends the same area with Forge-specific TabState fields, UI page routing, and keyboard handling, so the two PRs share UI integration concerns and may have merge ordering/testing implications.

Poem

🐰 A prompt flows through Claude's mind so bright,
Rust code streams forth, compiled just right,
Into the sandbox, a new app springs to life,
Forge weaves the magic, no more compiler strife!
—The Forge Rabbit 🔧✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main feature added: Oxide Forge, an in-browser code generation system powered by Claude that generates and hot-loads WebAssembly. It accurately reflects the primary changes across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 85.23% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oxide-forge

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@niklabh niklabh merged commit 95218a5 into main May 3, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant