react-grab

supercent-io/skills-template · updated Apr 8, 2026

$npx skills add https://github.com/supercent-io/skills-template --skill react-grab
0 commentsdiscussion
summary

Keyword: react-grab · grab · element context · copy component to ai

skill.md

react-grab — Browser Element Context for AI Agents

Keyword: react-grab · grab · element context · copy component to ai

Point at any UI element in your browser, press Cmd/Ctrl+C, and instantly copy its React component name, source file path, and HTML markup to clipboard — ready for your AI coding agent.

When to use this skill

  • Set up react-grab in a React project (Next.js, Vite, Webpack) for AI-assisted development
  • Point at UI elements and copy precise component context to Claude Code / Cursor / Copilot / Gemini
  • Add react-grab MCP server so your AI agent can receive element context programmatically
  • Configure react-grab with a custom plugin for project-specific workflows (Jira, Figma, etc.)
  • Use the programmatic API (getElementContext, freeze) for automation or test tooling
  • Remove react-grab from a project or a specific agent integration

Instructions

  1. Run bash scripts/install.sh (or npx -y grab@latest init) to install react-grab in your project
  2. Start your dev server — react-grab is dev-only and never ships to production
  3. Open your app in a browser, hover over any element, and press Cmd+C (Mac) / Ctrl+C (Win)
  4. Paste the clipboard content into your AI coding agent (Claude Code / Cursor / Copilot / Gemini)
  5. Optionally run bash scripts/add-agent.sh mcp to enable MCP tool access for programmatic use

For detailed API and framework-specific setup, see references/api.md.


Examples

Copy element context to Claude Code

# 1. Start your app
npm run dev

# 2. Hover over a button in the browser
# 3. Press Cmd+C (Mac) or Ctrl+C (Win/Linux)
# Clipboard now contains:
#
# in LoginForm at components/login-form.tsx:46:19
#
# <button class="btn-primary" type="submit">
#   Log in
# </button>

# 4. Paste into Claude Code — it knows exactly where the component lives

Set up MCP integration

# Install react-grab MCP server
npx -y grab@latest add mcp

# Your AI agent can now call the get_element_context MCP tool
# to receive element context after you select it in the browser

Add custom plugin action

import { registerPlugin } from "react-grab";

registerPlugin({
  name: "open-in-figma",
  actions: [{
    id: "figma",
    label: "Find in Figma",
    shortcut: "F",
    onAction: (ctx) => {
      window.open(`figma://search?q=${ctx.componentName}`);
    },
  }],
});

Quick Start

# One command — auto-detects your framework and installs everything
npx -y grab@latest init

# Add MCP server for programmatic AI agent access
npx -y grab@latest add mcp

# Add to a specific AI agent
npx -y grab@latest add claude-code

After installation, hover over any element in your browser during development and press:

  • Mac: Cmd+C
  • Windows/Linux: Ctrl+C

Output copied to clipboard:

in LoginForm at components/login-form.tsx:46:19

<a class="ml-auto text-sm underline-offset-4 hover:underline">
  Forgot your password?
</a>

Paste directly into your AI coding agent prompt — no file searching needed.


Installation

Auto-detect (Recommended)

npx -y grab@latest init

Detects your framework (Next.js App Router / Pages Router / Vite / TanStack Start / Webpack) and package manager (npm / yarn / pnpm / bun) automatically.

Manual installation by framework

Next.js App Router (app/layout.tsx):

import Script from 'next/script'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        {process.env.NODE_ENV === "development" && (
          <Script
            src="//unpkg.com/react-grab/dist/index.global.js"
            crossOrigin="anonymous"
            strategy="beforeInteractive"
          />
        )}
      </body>
    </html>
  )
}

Next.js Pages Router (pages/_document.tsx):

import Script from 'next/script'

// Inside _document component:
{process.env.NODE_ENV === "development" && (
  <Script
    src="//unpkg.com/react-grab/dist/index.global.js"
    crossOrigin="anonymous"
    strategy="beforeInteractive"
  />
)}

Vite (index.html):

<script type="module">
  if (import.meta.env.DEV) {
    await import('//unpkg.com/react-grab/dist/index.global.js');
  }
</script>

Webpack (entry file):

if (process.env.NODE_ENV === 'development') {
  import('react-grab');
}

Package install (for programmatic use):

npm install react-grab
# or: pnpm add react-grab | yarn add react-grab | bun add react-grab

Install react-grab via skill scripts

# Auto-detect framework and install
bash scripts/install.sh

# Install for a specific framework
bash scripts/install.sh --framework next-app

# Add to a specific AI agent
bash scripts/add-agent.sh claude-code
bash scripts/add-agent.sh cursor
bash scripts/add-agent.sh mcp

Core Usage

Keyboard shortcut

In development mode:

  1. Hover over any React element in the browser
  2. Press Cmd+C (Mac) or Ctrl+C (Windows/Linux)
  3. The context is copied to clipboard

Output format:

in <ComponentName> at <file-path>:<line>:<col>

<element-html>

Floating toolbar

A draggable toolbar appears in the corner of your browser when react-grab is active:

  • Click to toggle activation on/off
  • Drag to any screen edge
  • Collapse when not needed

Multi-element selection (drag)

Click and drag across multiple elements to capture all their contexts at once. Each element's component stack and HTML is included in the clipboard output.

Programmatic API

import { getGlobalApi } from "react-grab";

const api = getGlobalApi();

// Activate the overlay
api.activate();   // show overlay
api.deactivate(); // hide overlay
api.toggle();     // toggle

// Copy an element's context to clipboard
await api.copyElement(document.querySelector('.my-button'));

// Get source info without copying
const source = await api.getSource(element);
console.log(source.filePath);     // "src/components/Button.tsx"
console.log(source.lineNumber);   // 42
console

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.627 reviews
  • Chaitanya Patil· Dec 28, 2024

    Useful defaults in react-grab — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Ren Chen· Dec 20, 2024

    react-grab fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Amelia Verma· Dec 16, 2024

    We added react-grab from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Maya Ndlovu· Nov 23, 2024

    react-grab reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Piyush G· Nov 19, 2024

    react-grab has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Rahul Santra· Nov 15, 2024

    Registry listing for react-grab matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Sakura Sanchez· Nov 11, 2024

    react-grab is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Nia Lopez· Nov 7, 2024

    Keeps context tight: react-grab is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Daniel Johnson· Oct 26, 2024

    react-grab is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Sofia Liu· Oct 14, 2024

    Registry listing for react-grab matched our evaluation — installs cleanly and behaves as described in the markdown.

showing 1-10 of 27

1 / 3