react-devtools-bridge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/SKILL.md +96 -0
- package/TOOLS.md +96 -0
- package/dist/cli.js +2806 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +1099 -0
- package/dist/index.js +2799 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Skylar Barrera
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# react-devtools-bridge
|
|
2
|
+
|
|
3
|
+
Give AI agents eyes into your React app.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
### 1. Add MCP server to Claude Code
|
|
8
|
+
|
|
9
|
+
`.mcp.json`:
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"mcpServers": {
|
|
13
|
+
"react-devtools": {
|
|
14
|
+
"command": "npx",
|
|
15
|
+
"args": ["react-devtools-bridge"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. Connect your React app
|
|
22
|
+
|
|
23
|
+
**Web** - Add to your HTML (before your app bundle):
|
|
24
|
+
```html
|
|
25
|
+
<script src="http://localhost:8097"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**React Native** - DevTools is built-in. No extra setup needed.
|
|
29
|
+
|
|
30
|
+
### 3. (Optional) Install the skill
|
|
31
|
+
|
|
32
|
+
Teach Claude when to use these tools:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx add-skill skylarbarrera/react-devtools-mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or manually:
|
|
39
|
+
```bash
|
|
40
|
+
cp node_modules/react-devtools-bridge/SKILL.md ~/.claude/skills/react-devtools/SKILL.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
With your React app running, ask Claude things like:
|
|
46
|
+
- "What's the current state of the Counter component?"
|
|
47
|
+
- "Why doesn't clicking this button update the UI?"
|
|
48
|
+
- "Which components are re-rendering too often?"
|
|
49
|
+
|
|
50
|
+
## Docs
|
|
51
|
+
|
|
52
|
+
- [All tools](TOOLS.md)
|
|
53
|
+
- [Skill guide](SKILL.md) - When and how to use each tool
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-devtools
|
|
3
|
+
description: Debug React apps by inspecting runtime state, props, hooks, and renders
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React DevTools
|
|
7
|
+
|
|
8
|
+
Inspect running React apps. See actual props, state, hooks - not just source code.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
**Use these tools when:**
|
|
13
|
+
- User says "why doesn't this update" or "state is wrong"
|
|
14
|
+
- Behavior doesn't match what code suggests
|
|
15
|
+
- Need to verify actual runtime values
|
|
16
|
+
- Debugging performance / excessive renders
|
|
17
|
+
- Exploring unfamiliar React codebase
|
|
18
|
+
|
|
19
|
+
**Don't use when:**
|
|
20
|
+
- Bug is obvious from source (missing dep, typo)
|
|
21
|
+
- Just need to read/edit files
|
|
22
|
+
- No React app is running
|
|
23
|
+
|
|
24
|
+
## Setup Check
|
|
25
|
+
|
|
26
|
+
Before using, ensure:
|
|
27
|
+
1. MCP server is configured in `.mcp.json`
|
|
28
|
+
2. React app is running with DevTools connected
|
|
29
|
+
|
|
30
|
+
## Core Workflow
|
|
31
|
+
|
|
32
|
+
### 1. Connect
|
|
33
|
+
```
|
|
34
|
+
connect()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Find the component
|
|
38
|
+
```
|
|
39
|
+
search_components({ query: "ComponentName" })
|
|
40
|
+
```
|
|
41
|
+
or
|
|
42
|
+
```
|
|
43
|
+
get_component_tree()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Inspect it
|
|
47
|
+
```
|
|
48
|
+
inspect_element({ id: <element_id> })
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Returns: `{ props, state, hooks, context }`
|
|
52
|
+
|
|
53
|
+
## Common Debugging Patterns
|
|
54
|
+
|
|
55
|
+
### "Why doesn't clicking X update Y?"
|
|
56
|
+
```
|
|
57
|
+
1. search_components({ query: "ButtonComponent" })
|
|
58
|
+
2. inspect_element({ id }) → check state/props
|
|
59
|
+
3. Compare actual values vs expected
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### "This component re-renders too much"
|
|
63
|
+
```
|
|
64
|
+
1. start_profiling()
|
|
65
|
+
2. [user interacts with app]
|
|
66
|
+
3. stop_profiling() → see render counts and timing
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### "What's the actual value of this state?"
|
|
70
|
+
```
|
|
71
|
+
1. search_components({ query: "ComponentName" })
|
|
72
|
+
2. inspect_element({ id })
|
|
73
|
+
3. Look at hooks[].value for useState values
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### "Who renders this component?"
|
|
77
|
+
```
|
|
78
|
+
get_owners_list({ id }) → shows parent chain
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Key Tools
|
|
82
|
+
|
|
83
|
+
| Tool | Use For |
|
|
84
|
+
|------|---------|
|
|
85
|
+
| `inspect_element` | See props, state, hooks, context |
|
|
86
|
+
| `search_components` | Find component by name |
|
|
87
|
+
| `get_component_tree` | See full hierarchy |
|
|
88
|
+
| `get_owners_list` | Trace render chain |
|
|
89
|
+
| `start/stop_profiling` | Measure render performance |
|
|
90
|
+
| `highlight_element` | Visually identify component in app |
|
|
91
|
+
|
|
92
|
+
## Tips
|
|
93
|
+
|
|
94
|
+
- Element IDs change on hot reload - re-search after code changes
|
|
95
|
+
- Use `highlight_element` to confirm you're looking at the right component
|
|
96
|
+
- Hooks are indexed - `hooks[0]` is first useState/useEffect in component
|
package/TOOLS.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Tools
|
|
2
|
+
|
|
3
|
+
## Connection
|
|
4
|
+
|
|
5
|
+
| Tool | Description |
|
|
6
|
+
|------|-------------|
|
|
7
|
+
| `connect` | Connect to DevTools backend |
|
|
8
|
+
| `disconnect` | Disconnect |
|
|
9
|
+
| `get_connection_status` | Check connection state |
|
|
10
|
+
| `health_check` | Server health status |
|
|
11
|
+
|
|
12
|
+
## Component Tree
|
|
13
|
+
|
|
14
|
+
| Tool | Description |
|
|
15
|
+
|------|-------------|
|
|
16
|
+
| `get_component_tree` | Get full component hierarchy |
|
|
17
|
+
| `get_element_by_id` | Get element info |
|
|
18
|
+
| `search_components` | Find components by name |
|
|
19
|
+
| `get_owners_list` | Get render chain (who rendered this) |
|
|
20
|
+
| `get_element_source` | Get source file location |
|
|
21
|
+
|
|
22
|
+
## Inspection
|
|
23
|
+
|
|
24
|
+
| Tool | Description |
|
|
25
|
+
|------|-------------|
|
|
26
|
+
| `inspect_element` | Get props, state, hooks, context |
|
|
27
|
+
| `get_native_style` | Get style info (React Native) |
|
|
28
|
+
|
|
29
|
+
## Mutation
|
|
30
|
+
|
|
31
|
+
| Tool | Description |
|
|
32
|
+
|------|-------------|
|
|
33
|
+
| `override_props` | Change a prop value |
|
|
34
|
+
| `override_state` | Change state (class components) |
|
|
35
|
+
| `override_hooks` | Change hook value (function components) |
|
|
36
|
+
| `override_context` | Change context value |
|
|
37
|
+
| `delete_path` | Delete a prop/state/hook/context path |
|
|
38
|
+
| `rename_path` | Rename a key |
|
|
39
|
+
| `set_native_style` | Set style (React Native) |
|
|
40
|
+
|
|
41
|
+
## Profiling
|
|
42
|
+
|
|
43
|
+
| Tool | Description |
|
|
44
|
+
|------|-------------|
|
|
45
|
+
| `start_profiling` | Start recording renders |
|
|
46
|
+
| `stop_profiling` | Stop and get profiling data |
|
|
47
|
+
| `get_profiling_data` | Get data without stopping |
|
|
48
|
+
| `get_profiling_status` | Check if profiling is active |
|
|
49
|
+
|
|
50
|
+
## Errors & Warnings
|
|
51
|
+
|
|
52
|
+
| Tool | Description |
|
|
53
|
+
|------|-------------|
|
|
54
|
+
| `get_errors_and_warnings` | Get all React errors/warnings |
|
|
55
|
+
| `clear_errors_and_warnings` | Clear errors/warnings |
|
|
56
|
+
| `toggle_error` | Force error boundary state |
|
|
57
|
+
| `toggle_suspense` | Force suspense state |
|
|
58
|
+
|
|
59
|
+
## UI Helpers
|
|
60
|
+
|
|
61
|
+
| Tool | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| `highlight_element` | Highlight element in app |
|
|
64
|
+
| `clear_highlight` | Remove highlight |
|
|
65
|
+
| `scroll_to_element` | Scroll to show element |
|
|
66
|
+
| `log_to_console` | Log element as `$r` in console |
|
|
67
|
+
| `store_as_global` | Store value as global variable |
|
|
68
|
+
| `view_source` | Open source in IDE |
|
|
69
|
+
|
|
70
|
+
## Filters
|
|
71
|
+
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|------|-------------|
|
|
74
|
+
| `get_component_filters` | Get current filters |
|
|
75
|
+
| `set_component_filters` | Hide certain components |
|
|
76
|
+
| `set_trace_updates_enabled` | Toggle render highlighting |
|
|
77
|
+
|
|
78
|
+
## Native Inspection (React Native)
|
|
79
|
+
|
|
80
|
+
| Tool | Description |
|
|
81
|
+
|------|-------------|
|
|
82
|
+
| `start_inspecting_native` | Start tap-to-select mode |
|
|
83
|
+
| `stop_inspecting_native` | Stop inspection mode |
|
|
84
|
+
| `get_inspecting_native_status` | Check if inspecting |
|
|
85
|
+
| `capture_screenshot` | Screenshot an element |
|
|
86
|
+
|
|
87
|
+
## Advanced
|
|
88
|
+
|
|
89
|
+
| Tool | Description |
|
|
90
|
+
|------|-------------|
|
|
91
|
+
| `get_renderers` | List all React renderers |
|
|
92
|
+
| `get_renderer` | Get specific renderer |
|
|
93
|
+
| `get_elements_by_renderer` | Elements for a renderer |
|
|
94
|
+
| `get_capabilities` | Protocol capabilities |
|
|
95
|
+
| `view_attribute_source` | Source for specific attribute |
|
|
96
|
+
| `save_to_clipboard` | Copy to clipboard |
|