Jump to section
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.
- 01
Install as a devDependency
- 02
Register glideSourceStamping() in Vite or Astro
Import
glideSourceStampingfrom@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. - 03
Ignore the generated component index
- 04
Start your dev server and open /__glide/
Origin isolation: Open the printed127.0.0.1address rather thanlocalhost. The editor lives on127.0.0.1while the preview iframe loads your app onlocalhost, 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.
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';
export default defineConfig({
plugins: [react(), glideSourceStamping()],
});import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';
export default defineConfig({
plugins: [vue(), glideSourceStamping()],
});import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';
export default defineConfig({
plugins: [svelte(), glideSourceStamping()],
});import { defineConfig } from 'astro/config';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';
export default defineConfig({
vite: {
plugins: [glideSourceStamping()],
},
});import { defineConfig } from 'vite';
import { glideSourceStamping } from '@srivarsank/glide/vite-plugin';
export default defineConfig({
plugins: [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.
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>`.Install Glide's official AI agent skills and MCP server configuration in this project, then verify the setup so you can inspect live canvas selections and write Glide-safe source edits.
Follow these steps strictly in order:
1. Install all three official Glide skills (`glide`, `glide-component-segregator`, `glide-setup`):
- Run `npx -y @srivarsank/glide install-skills --agent all` from the project root.
- This writes `.agents/skills/` (Antigravity, Codex, Cursor, Windsurf), `.claude/skills/` (Claude Code), and `.cursor/rules/glide.mdc` (when Cursor config exists) with the latest skill files.
2. Register the Glide MCP stdio server for project coding agents:
- Run `npx -y @srivarsank/glide mcp install --agent all` to merge the `glide` server into `.mcp.json`, `.cursor/mcp.json`, and `.vscode/mcp.json` without overwriting existing servers.
- If OpenAI Codex CLI is available, also run `codex mcp add glide -- npx -y @srivarsank/glide mcp`.
3. Ensure `glide-components.json` is ignored in `.gitignore` (append if missing; never create `glide-components.json` manually).
4. Verify installation:
- Run `node .agents/skills/glide/scripts/verify-setup.mjs` and confirm `@srivarsank/glide`, `glideSourceStamping`, and installed skills pass.
- Confirm `.agents/skills/glide/SKILL.md`, `.agents/skills/glide-component-segregator/SKILL.md`, and `.agents/skills/glide-setup/SKILL.md` exist and MCP JSON configs parse cleanly.
5. Follow these operating rules on every UI task in this repo (read the installed `SKILL.md` files first):
- When Glide MCP tools are connected, call `get_guide` once, inspect canvas focus with `get_selection`, and apply changes through Glide MCP tools (`update_styles`, `set_text`, `insert_markup`, etc.) so edits follow project style conventions and join canvas undo history.
- Look up targets in `glide-components.json` or via `node .agents/skills/glide/scripts/query-components.mjs --name <Component>` instead of scanning the file tree.
- Edit only the requested property: keep responsive/state variants (`md:`, `hover:`), keep static classes and links literal so the canvas stays editable, never delete `{false && <... data-gl-workspace-id="...">}` pasteboard blocks, and instruct me to re-select on the canvas if `STALE_DIGEST` occurs.
6. Report installed skill paths, updated MCP config files, verifier output, and remind me to reload/restart the agent session so the Glide MCP tools connect.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.
{
"port": 7777,
"targetPort": 5173,
"historyLimit": 100,
"snapThresholdPx": 4,
"defaultViewport": {
"width": 1440,
"height": 1024
}
}{
"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.
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.
Canvas edit
batch-edit (file:line:col + expectedDigest)Editor sends one serialized transaction carrying the file SHA-256 digest.
Trust & digest gate
Session + path + SHA-256 checkVerifies 127.0.0.1 session token, workspace boundary, and file/node identity.
Mismatch → STALE_DIGEST / STALE_NODE (disk untouched)Exact source writer
AST splice / tag-position patchMutates only the target token in memory; comments and formatting stay intact.
Dynamic binding → UNSUPPORTED_OPERATIONAtomic write & history
Temp file → re-check → renameWrites temp file, re-verifies digest, renames atomically, and logs undo history.
Live HMR sync
status (selectionRemaps) + Vite HMRReturns remapped element coordinates and updates the canvas without reloading.
- Serialized & idempotent: Transactions run one at a time. Replaying a
batchIdreturns the cached result; different content with the same ID returnsTRANSACTION_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, enforcesHostandOriginchecks, requires ahellosession token handshake, and blocks writes into.git,node_modules, symlink escapes, or hard links.
| Subsystem | Role | Package |
|---|---|---|
| Vite plugin | Stamps elements with data-gl-source, injects bridge, serves editor at /__glide/ | packages/vite-plugin |
| Bridge | Runs inside the app iframe to report selection, geometry, and computed styles | packages/core |
| Editor | Canvas UI served as a single local HTML bundle on 127.0.0.1 | packages/overlay |
| Server | Authenticated WebSocket hub, chokidar watcher, transactions, history, and MCP bridge | packages/server |
| Writers | AST and exact-position source writers for JSX, Vue, Svelte, Astro, and HTML | packages/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 type | Engine | Supported | Refused |
|---|---|---|---|
| React / JSX / TSX | recast + @babel/parser | Static 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-sfc | Static 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 scanner | Static 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 scanner | Static 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.
| Property | Prefix | Before | After |
|---|---|---|---|
| Background | bg- | bg-white | bg-slate-900 |
| Text color | text- | text-gray-800 | text-sky-400 |
| Width / Height | w-, h- | w-full | w-[360px] |
| Padding | p-, px-, py- | p-4 | p-6 |
| Margin | m-, mx-, my- | mb-2 | mb-4 |
| Radius | rounded- | rounded-md | rounded-xl |
| Border | border- | border-gray-200 | border-sky-400 |
| Shadow & Opacity | shadow-, opacity- | shadow-sm | shadow-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 specificcvavariant.
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: relativefor 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.
| Skill | What it teaches the agent |
|---|---|
glide | Find stamped elements, edit source without breaking canvas editability, preserve pasteboard drafts, and explain refused edits. |
glide-component-segregator | Look up components by name and exact file:line:col in glide-components.json via query-components.mjs. |
glide-setup | Install @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).
| Tool | Type | Parameters | Behavior |
|---|---|---|---|
get_guide | Read | — | Returns Glide authoring conventions to keep markup canvas-editable. Call once per session. |
get_project_info | Read | — | Framework, Tailwind version, entry file, and routes of the active project. |
get_selection | Read | — | Currently selected canvas elements with source refs (file:line:col) and computed styles. |
get_tree | Read | file | Element tree of one relative source file with each element reference. |
get_source | Read | source | Exact element source and SHA-256 file digest (expectedDigest) for safe writes. |
update_styles | Edit | source, styles, breakpoint?, state?, expectedDigest? | Write camelCase CSS properties as Tailwind tokens or inline styles while preserving variants. |
set_text | Edit | source, text, expectedDigest? | Replace literal text of one element. |
set_attribute | Edit | source, name, value, expectedDigest? | Set or remove literal HTML attributes (href, target, rel, id, popover, aria-*, etc.). |
retag | Edit | source, tag, attributes?, expectedDigest? | Change HTML tag (e.g. div -> a with href or button with popoverTarget) with HTML validation. |
insert_markup | Structure | source, markup, sibling?, position?, expectedDigest? | Insert a static JSX element tree inside source (before/after sibling or last). |
duplicate_element | Structure | source, expectedDigest? | Duplicate one JSX element right after itself. |
move_element | Structure | source, parent, sibling?, position?, expectedDigest? | Move one JSX element into a parent in the same file. |
extract_component | Structure | source, name, expectedDigest? | Extract a self-contained JSX subtree into a PascalCase component above the caller. |
delete_element | Structure | source, 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:
{
"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 / Symptom | Cause | Fix |
|---|---|---|
STALE_DIGEST | The 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_NODE | The JSX element content hash no longer matches the stamped node. | Let HMR settle and re-select the target element. |
UNSUPPORTED_OPERATION | Target 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: line | glideSourceStamping() 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 disabled | Dev 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 Disconnected | Opened 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. |