Jump to section
@srivarsank/glide v3.0.0 · Node ≥ 22.22 · Vite 6–8 · Apache 2.0

Documentation

Everything needed to attach Glide to a Vite or Astro server, verify atomic AST write-backs, and equip AI coding agents with Glide skills and MCP tools. Click any command or code block to copy instantly.

Quick start

Glide runs locally on your existing Vite dev server (Node.js 22.22+, Vite 6,7, or 8). It stamps each rendered element with its file, line, and column in development only. Production builds ship zero Glide code or attributes.

  1. 01

    Install as a devDependency

  2. 02

    Register glideSourceStamping() in Vite or Astro

    Import glideSourceStamping from @srivarsank/glide/vite-plugin (not{ glide }) and append it to your existing plugin array without removing your framework plugin. See Framework setup below for exact snippets.

  3. 03

    Ignore the generated component index

  4. 04

    Start your dev server and open /__glide/

    Origin isolation: Open the printed 127.0.0.1 address rather thanlocalhost. The editor lives on 127.0.0.1 while the preview iframe loads your app on localhost, keeping app scripts isolated from the editor session.

Framework setup

Pick your stack and click anywhere in the code block to copy the exact Vite or Astro config. Glide does not support Webpack or Next.js.

vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';

export default defineConfig({
  plugins: [react(), glideSourceStamping()],
});

AI setup prompts

Paste either prompt into Claude Code, Cursor, Antigravity, Codex, Windsurf, or Copilot. Both prompts include preflight checks, exact export names, lockfile detection, and verification gates.

prompt: install-glide.md
Install and configure Glide (@srivarsank/glide), the local code-native visual editor, in this project so live canvas edits write atomic AST diffs directly to source.

Follow these steps strictly in order:
1. Preflight checks:
   - Run `node -v` and confirm Node.js >= 22.22.0.
   - Inspect `package.json` to confirm this is a Vite-based project (Vite 6/7/8 with React, Vue, Svelte/SvelteKit, Astro, or plain Vite HTML). If it uses Webpack or Next.js, stop and report that Glide requires Vite.
   - Detect the package manager from lockfiles (`pnpm-lock.yaml` -> pnpm, `yarn.lock` -> yarn, `bun.lock`/`bun.lockb` -> bun, otherwise npm).
2. Install `@srivarsank/glide` as a devDependency using the detected package manager (e.g. `npm install -D @srivarsank/glide`).
3. Register the Vite plugin without disturbing any existing configuration:
   - Exact import: `import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';` (never import `{ glide }`).
   - In `vite.config.{ts,js,mjs,mts}`: append `glideSourceStamping()` to the existing `plugins` array while keeping all existing plugins (`react()`, `vue()`, `svelte()`, Tailwind, etc.) intact.
   - In `astro.config.{mjs,ts,js}`: add `glideSourceStamping()` inside `vite: { plugins: [...] }`, preserving existing Vite plugins.
   - Note: `glideSourceStamping()` is a dev-only no-op in production builds.
4. Update `.gitignore`: append `glide-components.json` if it is not already ignored.
5. Verify before reporting done:
   - Confirm the config typechecks/parses cleanly and no existing options or plugins were removed.
   - Start (or restart) the dev server and confirm terminal output includes `[Glide] Editor: http://127.0.0.1:<port>/__glide/`.
   - Confirm `glide-components.json` is generated in the project root.
6. Report back with:
   - Modified files (`package.json`, Vite/Astro config, `.gitignore`).
   - Exact `http://127.0.0.1:<port>/__glide/` editor URL (remind me to use `127.0.0.1`, not `localhost`, for origin isolation).
   - Quick verification step: select an element on the canvas, tweak one style, and confirm the source diff lands via HMR. If `/__glide/` cannot be served directly, provide the fallback `npx @srivarsank/glide <port>`.
Preflight checks, Vite/Astro plugin wiring, .gitignore, HMR checkClick block to copy

Configuration

Glide works with zero configuration. For custom ports, viewport sizes, snap thresholds, or remote host allowlists, add glide.config.json (or .ts/.js/.mjs) in the project root.

glide.config.json
{
  "port": 7777,
  "targetPort": 5173,
  "historyLimit": 100,
  "snapThresholdPx": 4,
  "defaultViewport": {
    "width": 1440,
    "height": 1024
  }
}
glide.config.json (remoteAccess)
{
  "remoteAccess": {
    "bindAddress": "0.0.0.0",
    "allowedHosts": ["dev.internal:5173"],
    "allowedOrigins": ["http://dev.internal:5173"]
  }
}

Standalone proxy mode

If you prefer running the editor in a second terminal on port 7777 instead of/__glide/, start your dev server and launch Glide separately. KeepglideSourceStamping() enabled in Vite so elements stay stamped.

vite.config.ts (stamping only)
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';

// Keep source stamping active while serving the editor via standalone `npx @srivarsank/glide`
export default defineConfig({
  plugins: [react(), glideSourceStamping({ editor: false })],
});

Install from GitHub Packages (optional)

Architecture & write loop

Every visual edit flows through a serialized, authenticated transaction server. Files are checked by SHA-256 digest before and after mutation, written to a temp file, and atomically renamed. IDE or agent saves sync back to the canvas via file watcher without reloading the iframe.

  1. Canvas edit

    batch-edit (file:line:col + expectedDigest)

    Editor sends one serialized transaction carrying the file SHA-256 digest.

  2. Trust & digest gate

    Session + path + SHA-256 check

    Verifies 127.0.0.1 session token, workspace boundary, and file/node identity.

    Mismatch → STALE_DIGEST / STALE_NODE (disk untouched)
  3. Exact source writer

    AST splice / tag-position patch

    Mutates only the target token in memory; comments and formatting stay intact.

    Dynamic binding → UNSUPPORTED_OPERATION
  4. Atomic write & history

    Temp file → re-check → rename

    Writes temp file, re-verifies digest, renames atomically, and logs undo history.

  5. Live HMR sync

    status (selectionRemaps) + Vite HMR

    Returns remapped element coordinates and updates the canvas without reloading.

  • Serialized & idempotent: Transactions run one at a time. Replaying a batchId returns the cached result; different content with the same ID returns TRANSACTION_CONFLICT.
  • Digest & node identity gates: Every operation sends expectedDigest (SHA-256). JSX targets also include a short content hash to reject stale nodes (STALE_NODE).
  • Path & socket confinement: Server binds to 127.0.0.1, enforces Host and Origin checks, requires a hello session token handshake, and blocks writes into .git, node_modules, symlink escapes, or hard links.
SubsystemRolePackage
Vite pluginStamps elements with data-gl-source, injects bridge, serves editor at /__glide/packages/vite-plugin
BridgeRuns inside the app iframe to report selection, geometry, and computed stylespackages/core
EditorCanvas UI served as a single local HTML bundle on 127.0.0.1packages/overlay
ServerAuthenticated WebSocket hub, chokidar watcher, transactions, history, and MCP bridgepackages/server
WritersAST and exact-position source writers for JSX, Vue, Svelte, Astro, and HTMLpackages/ast-writer, packages/adapters/*

Framework adapters

Glide splices only the edited token into your original source text so formatting, quotes, and comments remain intact. Whenever an edit cannot be made cleanly, Glide refuses withUNSUPPORTED_OPERATION and leaves disk untouched.

File typeEngineSupportedRefused
React / JSX / TSXrecast + @babel/parserStatic className, cn/clsx/cva/template literals, inline style, literal text, literal props, plus insert, delete, duplicate, move, group, ungroup, arrange, extract.className from {...spread}, conditional or shared cva classes that override the edit, moves across lexical scopes.
Vue SFC (.vue)@vue/compiler-sfcStatic class, static style, single literal text segment. Leaves <script> and <style> untouched.:class, :style, v-bind, v-text/v-html, template preprocessors (Pug), structural edits.
Svelte (.svelte)svelte/compiler (re-parsed after every edit)Static class, static style, single literal text segment.Dynamic class="a {b}", {...spread}, component tags (<Card>), structural edits.
Astro (.astro)Exact-position opening tag scannerStatic class, static style, pure literal text. Frontmatter, <script>, and <style> stay intact.class:list, class={...}, style={{...}}, set:html, {...spread}, expressions, components, structural edits.
Plain HTML (.html)Exact-position opening tag scannerStatic class, static style, pure literal text inside <body> (only in framework-free projects).<html>/<head>/<body> tags, void elements (<img>), text with child elements, structural edits.

Surgical Tailwind rewriting

Rather than rewriting entire className strings, Glide swaps only the utility token matching the property and variant scope you edited. It reads Tailwind v3 configs and v4@theme tokens to emit theme classes (bg-brand-500, p-4) when values match, and bracketed arbitrary values (w-[360px]) otherwise.

PropertyPrefixBeforeAfter
Backgroundbg-bg-whitebg-slate-900
Text colortext-text-gray-800text-sky-400
Width / Heightw-, h-w-fullw-[360px]
Paddingp-, px-, py-p-4p-6
Marginm-, mx-, my-mb-2mb-4
Radiusrounded-rounded-mdrounded-xl
Borderborder-border-gray-200border-sky-400
Shadow & Opacityshadow-, opacity-shadow-smshadow-2xl
  • Variant scoping: Base edits never strip responsive (sm:–2xl:) or state variants (hover:, focus:, focus-visible:, active:, disabled:).
  • Class expressions (JSX): Edits unconditional classes inside cn(...), clsx(...), cva(...), and template literals. For shared components, choose target scope: component definition, single usage, or a specific cva variant.

Staged edits & drag layout

Instant mode

Each canvas change previews immediately and commits to source after a short settle delay, updating live via Vite HMR.

Staged mode

Buffers changes across elements with a Before / After toggle. Clicking Apply sends one all-or-nothing batch-edit transaction; Discard clears preview styles cleanly.

  • Layout-safe drag & resize: Previews live with zero disk writes during drag. On release, writes layout styles (Tailwind classes or inline styles) and adds position: relative for normal-flow nodes so flex/grid flow never collapses.
  • Pasteboard drafts: Moving an element off-canvas wraps it as {false && <div data-gl-workspace-id="..." ...>}. It never renders; do not delete it as dead code.
  • No sidecar file: Glide does not create or require glide-positions.json.

Keyboard shortcuts

On macOS, substitute ⌘ for Ctrl. When an element is selected,[ and ] arrange z-order; with nothing selected, they toggle panels.

Tools

  • VSelect
  • HHand / Pan
  • F or AFrame
  • RRectangle
  • OEllipse
  • TText
  • CComment
  • EReactions (1-8)

Editing

  • Ctrl ZUndo
  • Ctrl Shift Z / Ctrl YRedo
  • Ctrl C / Ctrl VCopy / paste
  • Ctrl DDuplicate
  • Delete / BackspaceDelete
  • Ctrl G / Ctrl Shift GGroup / ungroup
  • ] / [Front / back (selected)
  • Arrows (+ Shift)Nudge 1 px (10 px)

View

  • Ctrl 0Fit to screen
  • Ctrl 1Zoom to 100%
  • [ / ]Toggle left / right panel
  • \Toggle both panels
  • Ctrl Alt HHistory panel
  • Ctrl EExport PNG / JPG
  • EscCancel or deselect

Agent skills

Glide ships three opt-in skills that teach coding agents to locate elements fast, preserve canvas-editable markup, and diagnose setup or refusal errors.

SkillWhat it teaches the agent
glideFind stamped elements, edit source without breaking canvas editability, preserve pasteboard drafts, and explain refused edits.
glide-component-segregatorLook up components by name and exact file:line:col in glide-components.json via query-components.mjs.
glide-setupInstall @srivarsank/glide, configure glideSourceStamping(), verify setup with verify-setup.mjs, and troubleshoot disconnects.

Target flags: --agent agents writes .agents/skills/ (Antigravity, Codex, Cursor, Windsurf); --agent claude writes .claude/skills/;--agent all writes both plus .cursor/rules/glide.mdc when Cursor config is present.

MCP server & 14 tools

Run Glide's stdio MCP server so coding agents read your live canvas selection and apply edits through the exact same transaction server (preserving style format and canvas undo history).

ToolTypeParametersBehavior
get_guideRead—Returns Glide authoring conventions to keep markup canvas-editable. Call once per session.
get_project_infoRead—Framework, Tailwind version, entry file, and routes of the active project.
get_selectionRead—Currently selected canvas elements with source refs (file:line:col) and computed styles.
get_treeReadfileElement tree of one relative source file with each element reference.
get_sourceReadsourceExact element source and SHA-256 file digest (expectedDigest) for safe writes.
update_stylesEditsource, styles, breakpoint?, state?, expectedDigest?Write camelCase CSS properties as Tailwind tokens or inline styles while preserving variants.
set_textEditsource, text, expectedDigest?Replace literal text of one element.
set_attributeEditsource, name, value, expectedDigest?Set or remove literal HTML attributes (href, target, rel, id, popover, aria-*, etc.).
retagEditsource, tag, attributes?, expectedDigest?Change HTML tag (e.g. div -> a with href or button with popoverTarget) with HTML validation.
insert_markupStructuresource, markup, sibling?, position?, expectedDigest?Insert a static JSX element tree inside source (before/after sibling or last).
duplicate_elementStructuresource, expectedDigest?Duplicate one JSX element right after itself.
move_elementStructuresource, parent, sibling?, position?, expectedDigest?Move one JSX element into a parent in the same file.
extract_componentStructuresource, name, expectedDigest?Extract a self-contained JSX subtree into a PascalCase component above the caller.
delete_elementStructuresource, expectedDigest?Delete one element and its children from source (undoable on canvas).

Component registry

While Glide runs, it indexes every component in your repo into glide-components.jsonand refreshes within 300 ms of changes. Query it via script instead of loading the full file or grepping the repository:

glide-components.json (generated, read-only)
{
  "framework": "react",
  "buckets": [
    {
      "name": "Card",
      "file": "/src/components/Card.tsx",
      "exportType": "named",
      "line": 12,
      "elements": [
        { "id": "src/Card.tsx:13:4", "tagName": "div", "isRoot": true, "classNames": ["card"] },
        { "id": "src/Card.tsx:14:6", "tagName": "h2", "isRoot": false }
      ],
      "cssFiles": ["/src/components/Card.module.css"]
    }
  ]
}

Error codes & troubleshooting

Code / SymptomCauseFix
STALE_DIGESTThe file changed on disk (via IDE or agent) after the element was selected.Re-select the element on the canvas, or call get_source again before the next MCP write.
STALE_NODEThe JSX element content hash no longer matches the stamped node.Let HMR settle and re-select the target element.
UNSUPPORTED_OPERATIONTarget uses computed classes (:class, class:list, {...spread}), expressions, or a non-JSX structural edit.Edit that binding directly in source; keep static classes literal where canvas editing is desired.
No [Glide] Editor: lineglideSourceStamping() is missing from the active Vite/Astro config or imported as { glide }.Import { glideSourceStamping } from '@srivarsank/glide/vite-plugin', append it to plugins, and restart dev server.
Select works, properties disabledDev server was not restarted after adding the plugin, so DOM lacks data-gl-source stamps.Restart npm run dev and reload http://127.0.0.1:5173/__glide/.
Editor says DisconnectedOpened from an untrusted host or origin rather than the printed loopback URL.Open the printed http://127.0.0.1:<port>/__glide/ URL, or configure remoteAccess in glide.config.json.