MCPcopy Index your code
hub / github.com/donghaxkim/react-rewrite

github.com/donghaxkim/react-rewrite @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
680 symbols 1,696 edges 102 files 68 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

react-rewrite

react-rewrite lets you edit a React app visually while it is running locally, then automatically writes those changes back to the source files in your project.

It is built for local development and works by opening a proxy in front of your dev server and injecting an overlay into the page.

Demo

React Rewrite GIF Converter

full demo: https://x.com/imdonghakim/status/2038230475894899119

Fastest path

You do not need to download or clone this repo.

From the root of your React app:

npm install -D react-rewrite-cli

Start your dev server, then in a second terminal run:

npx react-rewrite

If you want to try it without installing first:

npx react-rewrite-cli@latest

What it does

  • Select an element and inspect its component name, file path, and line number
  • Edit supported Tailwind-based layout, spacing, size, typography, and color properties
  • Double-click text to edit it inline
  • Copy, paste, and duplicate elements
  • Delete elements
  • Reorder sibling elements
  • Stage multiple changes and apply them with Confirm
  • Undo in-progress canvas changes and review applied changes in the changelog

Requirements

  • Node.js 20+
  • A React project (18+)
  • A running development server
  • Supported app setups: Next.js, Vite, and Create React App

Tailwind CSS is recommended if you want to use the property editor. Text editing and some structural actions do not depend on Tailwind.

Install

Run this in the root of the React app you want to edit:

npm install -D react-rewrite-cli

If you don't want to install it first, you can also run it directly with npx react-rewrite-cli@latest.

Quick start

  1. Start your React dev server as usual.
  2. In a second terminal, from the same project root, run:
npx react-rewrite

If auto-detection does not pick the right port, pass it explicitly:

npx react-rewrite 3000

The tool opens a local proxy in your browser, shows the editing overlay, and writes confirmed changes back into files inside your project.

Basic flow

  1. Click an element to inspect and select it.
  2. Edit properties in the sidebar, drag to reorder where supported, or double-click text to change copy.
  3. Review pending changes in the UI.
  4. Click Confirm to apply them to your source files.

CLI options

react-rewrite [options] [port]

Arguments:
  port           Dev server port override

Options:
  --no-open      Don't open browser automatically
  --host <host>  Dev server host (default: "localhost")
  --verbose      Enable debug logging

Shortcuts

Shortcut Action
Ctrl/Cmd + C Copy selected element
Ctrl/Cmd + V Paste copied element as sibling
Ctrl/Cmd + D Duplicate selected element in place
Delete / Backspace Remove selected element
Ctrl/Cmd + Z Undo canvas changes
Ctrl/Cmd + Shift + L Toggle changelog
Ctrl/Cmd + Click Follow links through the overlay
Double-click text Edit text inline

Notes

  • Run react-rewrite from your app's root directory so it can detect the framework and safely resolve file paths.
  • It only works against development builds, not production builds.
  • Only files inside the current project are eligible for writes.

Development

To work on this repository itself:

pnpm install
pnpm build
pnpm test -- --run

For iterative CLI development:

pnpm dev

You will still need a separate supported React app running locally to test the tool end to end.

Project structure

packages/
  cli/      CLI, proxy server, and source transforms
  overlay/  Injected browser overlay
  shared/   Shared TypeScript types

License

MIT

Extension points exported contracts — how you extend this code

TextEditDomHints (Interface)
DOM hints for text edit annotations — used by buildBatchOperations for fuzzy resolution.
packages/overlay/src/canvas-state.ts
BatchResult (Interface)
(no doc)
packages/cli/src/batch-transform.ts
JSXPathSegment (Interface)
(no doc)
packages/shared/src/types.ts
Window (Interface)
(no doc)
packages/overlay/src/index.ts
OperationResult (Interface)
(no doc)
packages/cli/src/batch-transform.ts
JSXStructuralPath (Interface)
(no doc)
packages/shared/src/types.ts
SnapGuides (Interface)
(no doc)
packages/overlay/src/snap-guides.ts
ResolvedOp (Interface)
(no doc)
packages/cli/src/batch-transform.ts

Core symbols most depended-on inside this repo

executeBatch
called by 44
packages/cli/src/batch-transform.ts
showToast
called by 31
packages/overlay/src/toolbar.ts
updateClassName
called by 24
packages/cli/src/transform.ts
send
called by 24
packages/cli/src/server.ts
extractFilePath
called by 20
packages/overlay/src/utils/source-resolve.ts
notifyStateChange
called by 14
packages/overlay/src/canvas-state.ts
resolveProjectFilePath
called by 13
packages/cli/src/path-resolver.ts
getOpLine
called by 12
packages/cli/src/batch-transform.ts

Shape

Function 620
Interface 58
Method 2

Languages

TypeScript100%

Modules by API surface

packages/cli/src/transform.ts63 symbols
packages/overlay/src/canvas-state.ts46 symbols
packages/cli/src/batch-transform.ts46 symbols
packages/cli/src/mdx-text.ts36 symbols
packages/overlay/src/selection.ts28 symbols
packages/overlay/src/inline-text-edit.ts27 symbols
packages/overlay/src/changelog.ts26 symbols
packages/overlay/src/highlight-canvas.ts25 symbols
packages/overlay/src/properties/property-controller.ts24 symbols
packages/shared/src/types.ts16 symbols
packages/overlay/src/clone-state.ts14 symbols
packages/overlay/src/tools-panel.ts13 symbols

For agents

$ claude mcp add react-rewrite \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact