# Find the Source Line of Any React Element

> Your agent opens the exact file and line behind a button, card or image on a React page instead of grepping for its text. Works with the free react-source-string plugins for Vite, Next.js (SWC) and Babel, and sets them up if the project has none.

Find the Source Line of Any React Element is a free AI agent skill on Agensi by Jaroslav Barov, in Frontend & Web Apps. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Jaroslav Barov](https://www.agensi.io/creators/jaroslav-barov)
- Category: [Frontend & Web Apps](https://www.agensi.io/skills/frontend-web-apps)
- Version: 1.0
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/find-the-source-line-of-any-react-element
- Tags: ai-agents, react, vite, nextjs, babel, dx

## About this skill

Your agent sees a "Pay" button on the page and searches the repository for "Pay". If the codebase has three of them, it edits the wrong one. This skill gives the agent the exact file and line instead.

It works with the free, open-source react-source-string build plugins. In development they add `data-source="src/pages/Checkout.tsx:42"` to every JSX element. With the overlay on, you can Alt + click an element to copy that reference, and the page gets a `window.__REACT_SOURCE__` lookup that an agent calls from its browser tool.

### What the skill teaches your agent

- **Read a pasted reference.** You Alt + click an element and paste `src/pages/Checkout.tsx:42 <button> "Pay"`. The agent opens that line and skips the search. The `inside:` line tells it which parent to edit when the change is about layout or the surrounding list.
- **Look up an element in the browser.** Accessibility snapshots from Playwright MCP, Claude in Chrome and other agent browsers drop `data-*` attributes. The skill has the agent run `__REACT_SOURCE__.find("Pay")` in the page and get `src/pages/Checkout.tsx:42` back.
- **Pick the right line.** When a shared `<Button>` renders the element, `__REACT_SOURCE__.stack()` lists the component and its call site. The agent changes the checkout page when you mean one button, and the shared component only when you want every button to change.
- **Set up the plugin.** If the project has no plugin, the agent tells you and offers to install it. With your OK it adds the dev dependency and the config for Vite, Next.js or Babel, adds a rule to `AGENTS.md`, and checks that the attributes show up.

### Requirements

- A React project running in development mode.
- One of the plugins: `vite-plugin-react-source-string` (Vite), `swc-plugin-react-source-string` (Next.js 16.1.7 and later) or `babel-plugin-react-source-string` (webpack, Rspack, Next.js with a Babel config, Metro). The skill installs it for you if you agree.

### Limitations

- Production builds have no `data-source` attributes and no overlay.
- Elements rendered inside `node_modules` are not tagged. The agent gets the nearest tagged element from your own code, which is the place that renders the library component.
- Without a plugin the agent falls back to a text search and tells you the result is a guess.

The skill and the plugins are open source under the MIT license.

## Requires

- React project in development mode
- Vite, Next.js 16.1.7+ or Babel
- Node.js
- npm
- pnpm or Yarn

## Known limitations

Only works in development builds. Elements inside node_modules are not tagged. Requires build-time plugin integration (Vite, Next.js, or Babel).

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Find the Source Line of Any React Element skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How is this different from letting the agent search the code for the text it sees?

A text search finds every place with that text, including other pages, tests and translations. The plugin writes the file and line into each element when the dev build compiles it, so the agent reads the location of the element that is on the screen.

### Which bundlers are supported?

Vite, Next.js 16.1.7 and later with SWC, and anything that compiles JSX with Babel: webpack, Rspack, Next.js with a Babel config, Metro. The Alt + click overlay needs Next.js 16.4 or later on SWC.

### Which agents can use it?

Any agent that reads SKILL.md. Pasting an Alt + click reference works in any chat. Looking elements up on the page needs a browser tool that runs JavaScript, such as Playwright MCP or Claude in Chrome.

### Does it work in production?

No. The plugins run in development only, so production HTML has no data-source attributes and no overlay. Elements rendered inside node_modules are not tagged either; the agent uses the nearest element from your own code.

### Will it change my project without asking?

No. If the plugin is missing, the agent tells you and asks first. With your OK it adds one dev dependency and a few lines to the bundler config, and checks that the attributes appear on the page.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
