A complete dev tool suite for Svelte 5 that captures component context for LLM coding agents. Alt+Click any element to get exact file locations, inspect state, analyze styles, audit accessibility, trace errors, and profile renders — all formatted for AI prompts.
Inspired by React Grab which demonstrated 3x speedup for React projects.
Coding agents are slow at frontend because translating intent is lossy:
This search phase is slow and non-deterministic.
svelte-grab eliminates the search phase entirely:
<button class="btn-primary"> in src/lib/components/Header.svelte:42
in src/routes/+layout.svelte:15
User instruction: Make this button bigger and change the color to blue
The fastest way to use svelte-grab with Claude Code:
npm install svelte-grab
<script>
import { SvelteDevKit } from 'svelte-grab';
</script>
{@render children()}
<SvelteDevKit enableMcp />
Add to ~/.claude.json:
{
"mcpServers": {
"svelte-grab": {
"command": "npx",
"args": ["svelte-grab-mcp", "--stdio"]
}
}
}
In Claude Code, say:
"use watch_for_grab to listen for my selections"
Then in your browser: 1. Alt+Click any element 2. Type your prompt in the overlay (e.g. "make this button bigger") 3. Cmd+Enter to send
Claude Code receives everything — file paths, component stack, HTML preview, and your instruction — and makes the change.
The overlay shows a green dot when Claude Code is listening and a red dot when disconnected.
Browser MCP Server Claude Code
| | |
| Alt+Click + prompt | |
|------ POST /context ----->| |
| |-- resolve watch_for_grab ->|
| | |-- reads files, makes change
|<---- SSE: processing -----| |
svelte-grab ships 7 specialized tools + a unified wrapper:
| Tool | Trigger | What it does |
|---|---|---|
| SvelteGrab | Alt+Click | Component location stack with file:line |
| SvelteStateGrab | Alt+Shift+Click | Props, attributes, bound values inspection |
| SvelteStyleGrab | Alt+Ctrl+Click | CSS analysis with source attribution |
| SveltePropsTracer | Alt+DoubleClick | Component hierarchy trace |
| SvelteA11yReporter | Alt+RightClick / Alt+A | Accessibility audit with WCAG scoring |
| SvelteErrorContext | Alt+E | Console errors/warnings with stack parsing |
| SvelteRenderProfiler | Alt+P | DOM mutation profiling per component |
| SvelteDevKit | (wrapper) | All tools in one component |
npm install svelte-grab
# or
yarn add svelte-grab
# or
pnpm add svelte-grab
<script>
import { SvelteGrab } from 'svelte-grab';
</script>
{@render children()}
<SvelteGrab />
Or use SvelteDevKit to enable all tools at once:
<script>
import { SvelteDevKit } from 'svelte-grab';
</script>
{@render children()}
<SvelteDevKit />
Or use the CLI to auto-inject:
npx svelte-grab init
The core tool. Hold Alt, hover to see file:line tooltips, click to capture the component stack.
O to open file in VSCode, Cursor, WebStorm, Zed, or SublimeS to capture element screenshot (requires html-to-image)| Prop | Type | Default | Description |
|---|---|---|---|
modifier |
'alt' \| 'ctrl' \| 'meta' \| 'shift' |
'alt' |
Modifier key to activate |
activationMode |
'hold' \| 'toggle' |
'hold' |
Hold modifier vs toggle on/off |
autoCopyFormat |
'agent' \| 'paths' \| 'none' |
'agent' |
Clipboard format on grab |
showPopup |
boolean |
true |
Show visual popup |
includeHtml |
boolean |
true |
Include HTML preview in output |
editor |
'vscode' \| 'cursor' \| 'webstorm' \| 'zed' \| 'sublime' \| 'none' |
'vscode' |
Editor for "Open in Editor" |
enableScreenshot |
boolean |
true |
Enable screenshot capture |
enableMultiSelect |
boolean |
true |
Enable multi-selection |
enableDragSelect |
boolean |
true |
Enable drag box selection |
enableArrowNav |
boolean |
true |
Enable arrow key navigation |
showToolbar |
boolean |
false |
Show floating toolbar |
showContextMenu |
boolean |
true |
Enable right-click context menu |
maxHistorySize |
number |
20 |
Max grab history entries |
forceEnable |
boolean |
false |
Force enable if dev detection fails |
theme |
ThemeConfig |
— | Custom theme colors |
lightTheme |
boolean |
false |
Use light theme preset |
plugins |
SvelteGrabPlugin[] |
[] |
Registered plugins |
enableAgentRelay |
boolean |
false |
Enable WebSocket relay |
agentRelayUrl |
string |
'ws://localhost:4722' |
Relay server URL |
agentId |
string |
'claude-code' |
Agent identifier |
enableMcp |
boolean |
false |
Enable MCP bridge to Claude Code |
mcpPort |
number |
4723 |
MCP server port |
freezeAnimations |
boolean |
true |
Freeze CSS animations during selection |
freezePseudoStates |
boolean |
true |
Preserve :hover/:focus states during selection |
enableHistoryPersistence |
boolean |
true |
Persist history to sessionStorage |
enablePromptMode |
boolean |
true |
Enable inline prompt overlay |
copyOnKeyboard |
boolean |
true |
Enable Cmd+C / Ctrl+C to copy in selection mode |
projectRoot |
string |
'' |
Absolute path to project root (for "Open in Editor") |
showActiveIndicator |
boolean |
true |
Show active indicator badge |
Agent format (default) — optimized for pasting into AI prompts:
<button class="btn-primary"> in src/lib/components/Button.svelte:23
in src/lib/components/Form.svelte:45
in src/routes/contact/+page.svelte:12
Paths format — simple file:line:column:
src/lib/components/Button.svelte:23:5
src/lib/components/Form.svelte:45:3
src/routes/contact/+page.svelte:12:1
Alt+Shift+Click any element to inspect its component state.
Shows: Props, HTML attributes, data attributes, bound values (form inputs, text content), child component count, and component location.
<SvelteStateGrab />
| Prop | Type | Default | Description |
|---|---|---|---|
modifier |
modifier key | 'alt' |
Primary modifier |
secondaryModifier |
'shift' \| 'ctrl' \| 'meta' |
'shift' |
Secondary modifier |
maxDepth |
number |
3 |
Max object nesting depth |
maxStringLength |
number |
200 |
Truncate long strings |
Handles circular references, functions, DOM elements, Maps, and Sets safely.
Alt+Ctrl+Click to analyze computed styles with source attribution.
Detects style sources: inline styles, Svelte-scoped (svelte-XXXX), Tailwind classes, external CSS, inherited, and user-agent defaults. Calculates CSS specificity and identifies overridden properties and conflicts.
<SvelteStyleGrab />
| Prop | Type | Default | Description |
|---|---|---|---|
modifier |
modifier key | 'alt' |
Primary modifier |
secondaryModifier |
'shift' \| 'ctrl' \| 'meta' |
'ctrl' |
Secondary modifier |
showCategories |
('box-model' \| 'visual' \| 'typography' \| 'layout' \| 'all')[] |
['all'] |
Which categories to show |
Categories: Box Model (width, height, padding, margin, border), Visual (background, color, opacity, shadow), Typography (font, line-height, text-align), Layout (display, position, flex, grid, z-index).
Alt+DoubleClick to trace the full component hierarchy from any element to root.
Shows the complete tree with file:line locations, depth indicators, and visual connectors. Warns about deep nesting (>5 levels) and suggests using Context API or stores.
<SveltePropsTracer />
Alt+RightClick an element to audit it, or Alt+A to audit the entire page.
Checks: WCAG color contrast (AA/AAA), missing alt text, unlabeled form inputs, ARIA attribute validity, heading hierarchy, focus order, and semantic HTML usage. Returns an accessibility score (0-100) with categorized issues (Critical / Warnings / Passes) and fix suggestions with code examples.
<SvelteA11yReporter />
| Prop | Type | Default | Description |
|---|---|---|---|
includeSubtree |
boolean |
true |
Audit child elements too |
Alt+E to view captured errors and warnings.
Intercepts console.error, console.warn, uncaught exceptions, and unhandled promise rejections. Parses stack traces (Chrome, Firefox, Safari), deduplicates repeated errors, correlates with Svelte components, and detects common error patterns with fix suggestions.
<SvelteErrorContext />
| Prop | Type | Default | Description |
|---|---|---|---|
maxErrors |
number |
50 |
Max captured errors |
bufferMinutes |
number |
5 |
Error retention window |
filterNodeModules |
boolean |
true |
Hide node_modules frames |
Alt+P to start a profiling session (default 10 seconds).
Uses MutationObserver to track DOM mutations, correlates them with Svelte components, and detects render bursts (20+ renders in 1 second). Heat-colored display: green (0-10), orange (10-20), yellow (20-50), red (50+).
<SvelteRenderProfiler />
| Prop | Type | Default | Description |
|---|---|---|---|
profileDuration |
number |
10 |
Profiling duration in seconds |
burstThreshold |
number |
20 |
Renders to trigger burst detection |
burstWindow |
number |
1000 |
Burst detection window in ms |
Single component that includes all 7 tools. Selectively enable/disable tools:
<script>
import { SvelteDevKit } from 'svelte-grab';
</script>
<SvelteDevKit />
<SvelteDevKit enabledTools={['grab', 'state', 'a11y']} />
<SvelteDevKit enableMcp />
Accepts all SvelteGrab props plus:
| Prop | Type | Default | Description |
|---|---|---|---|
enabledTools |
DevKitTool[] |
all tools | Which tools to activate |
Available tools: 'grab', 'state', 'style', 'props', 'a11y', 'errors', 'profiler'
The recommended way to connect svelte-grab to Claude Code. Select a component, type your instruction, and Claude Code acts on it — no copy-paste needed.
watch_for_grab, which blocks until you send something from the browserwatch_for_grab again for the next instruction1. Configure Claude Code (~/.claude.json):
{
"mcpServers": {
"svelte-grab": {
"command": "npx",
"args": ["svelte-grab-mcp", "--stdio"]
}
}
}
2. Enable in your app:
<SvelteDevKit enableMcp />
3. In Claude Code, say:
"use watch_for_grab to listen for my selections"
4. In the browser:
| Tool | Description |
|---|---|
| `watch_for |
$ claude mcp add svelte-grab \
-- python -m otcore.mcp_server <graph>