重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
react-devtools by piotrski/agent-react-devtools
npx skills add https://github.com/piotrski/agent-react-devtools --skill react-devtools通过 React DevTools 协议连接到正在运行的 React 或 React Native 应用程序,并以令牌高效格式公开组件树、props、state、hooks 和分析数据的 CLI。
agent-react-devtools status。如果守护进程未运行,请使用 agent-react-devtools start 启动它。使用 agent-react-devtools wait --connected 来阻塞直到 React 应用程序连接。agent-react-devtools start # 启动守护进程(首次运行命令时自动启动)
agent-react-devtools stop # 停止守护进程
agent-react-devtools status # 检查连接状态、组件数量、最后事件
agent-react-devtools wait --connected # 阻塞直到 React 应用程序连接
agent-react-devtools wait --component App # 阻塞直到指定组件出现
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
agent-react-devtools get tree # 完整的组件层次结构(标签:@c1, @c2, ...)
agent-react-devtools get tree --depth 3 # 限制深度
agent-react-devtools get component @c5 # 获取特定组件的 Props、state、hooks
agent-react-devtools find Button # 按显示名称搜索(模糊匹配)
agent-react-devtools find Button --exact # 精确匹配
agent-react-devtools count # 按类型计数:fn, cls, host, memo, ...
agent-react-devtools errors # 列出有错误或警告的组件
agent-react-devtools profile start # 开始记录
agent-react-devtools profile stop # 停止并收集数据
agent-react-devtools profile slow # 按平均渲染时间排序的最慢组件
agent-react-devtools profile slow --limit 10 # 前 10 个
agent-react-devtools profile rerenders # 重新渲染次数最多的组件
agent-react-devtools profile report @c5 # 单个组件的详细报告
agent-react-devtools profile timeline # 按时间顺序排列的提交列表
agent-react-devtools profile commit 3 # 提交 #3 的详细信息
agent-react-devtools profile export profile.json # 导出为 React DevTools Profiler JSON 格式
agent-react-devtools profile diff before.json after.json # 比较两个导出文件
每个组件都会获得一个稳定的标签,如 @c1、@c2。使用这些标签在后续命令中引用组件:
@c1 [fn] App
├─ @c2 [fn] Header
├─ @c3 [fn] TodoList
│ ├─ @c4 [fn] TodoItem key=1
│ └─ @c5 [fn] TodoItem key=2
└─ @c6 [host] div
类型缩写:fn = 函数组件,cls = 类组件,host = DOM 元素,memo = React.memo,fRef = forwardRef,susp = Suspense,ctx = context。
有错误或警告的组件会显示注释:⚠2 = 2 个警告,✗1 = 1 个错误。使用 agent-react-devtools errors 仅列出受影响的组件。
@c3 [fn] TodoList
props:
items: [{"id":1,"text":"Buy milk"},{"id":2,"text":"Walk dog"}]
onDelete: ƒ
state:
filter: "all"
hooks:
useState: "all"
useMemo: [...]
useCallback: ƒ
ƒ = 函数值。超过 60 个字符的值会被截断。
Slowest (by avg render time):
@c3 [fn] ExpensiveList avg:12.3ms max:18.1ms renders:47 causes:props-changed changed: props: items, filter
@c4 [fn] TodoItem avg:2.1ms max:5.0ms renders:94 causes:parent-rendered, props-changed changed: props: onToggle
渲染原因:props-changed、state-changed、hooks-changed、parent-rendered、force-update、first-mount。
当有特定的变更键可用时,changed: 后缀会精确显示是哪些 props、state 键或 hooks 触发了渲染(例如 changed: props: onClick, className state: count hooks: #0)。
agent-react-devtools wait --connected --timeout 10
agent-react-devtools get tree
在触发页面重新加载或 HMR 更新后使用此命令,以避免查询空状态。
agent-react-devtools profile start
# 用户与应用程序交互(或使用 agent-browser 驱动 UI)
agent-react-devtools profile stop
agent-react-devtools profile slow --limit 5
agent-react-devtools profile rerenders --limit 5
然后使用 get component @cN 和 profile report @cN 检查最耗时的组件。
agent-react-devtools find SearchBar
agent-react-devtools get component @c12
agent-react-devtools profile start
# 重复交互操作
agent-react-devtools profile stop
agent-react-devtools profile slow --limit 5
# 将渲染次数和持续时间与上一次运行进行比较
当使用 agent-browser 在性能分析或调试过程中驱动应用程序时,必须使用有头模式(--headed)。无头 Chromium 执行 ES 模块脚本的方式与真实浏览器不同,这会阻止 devtools 连接脚本正常运行。
agent-browser --session devtools --headed open http://localhost:5173/
agent-react-devtools status # 应显示 1 个已连接的应用程序
wait --connected,然后使用 get tree 或 find 重新检查。status — 如果 status 显示 0 个已连接的应用程序,则 React 应用程序未连接。用户可能需要先在他们的项目中运行 npx agent-react-devtools init。agent-browser,请始终使用 --headed 模式。无头 Chromium 无法正确加载 devtools 连接脚本。profile start 和 profile stop 之间发生的渲染。确保相关的交互发生在该时间段内。--depth — 深度树可能会产生大量输出。从 --depth 3 或 --depth 4 开始,仅在你关心的子树上深入。| 文件 | 何时阅读 |
|---|---|
| commands.md | 包含所有标志和边缘情况的完整命令参考 |
| profiling-guide.md | 分步性能分析工作流程和结果解读 |
| setup.md | 如何连接不同的框架(Vite、Next.js、Expo、CRA) |
每周安装量
48
代码仓库
GitHub 星标数
53
首次出现
2026年2月11日
安全审计
已安装于
codex46
opencode45
github-copilot45
gemini-cli45
amp41
kimi-cli41
CLI that connects to a running React or React Native app via the React DevTools protocol and exposes the component tree, props, state, hooks, and profiling data in a token-efficient format.
agent-react-devtools status. If the daemon is not running, start it with agent-react-devtools start. Use agent-react-devtools wait --connected to block until a React app connects.agent-react-devtools start # Start daemon (auto-starts on first command)
agent-react-devtools stop # Stop daemon
agent-react-devtools status # Check connection, component count, last event
agent-react-devtools wait --connected # Block until a React app connects
agent-react-devtools wait --component App # Block until a component appears
agent-react-devtools get tree # Full component hierarchy (labels: @c1, @c2, ...)
agent-react-devtools get tree --depth 3 # Limit depth
agent-react-devtools get component @c5 # Props, state, hooks for a specific component
agent-react-devtools find Button # Search by display name (fuzzy)
agent-react-devtools find Button --exact # Exact match
agent-react-devtools count # Count by type: fn, cls, host, memo, ...
agent-react-devtools errors # List components with errors or warnings
agent-react-devtools profile start # Start recording
agent-react-devtools profile stop # Stop and collect data
agent-react-devtools profile slow # Slowest components by avg render time
agent-react-devtools profile slow --limit 10 # Top 10
agent-react-devtools profile rerenders # Most re-rendered components
agent-react-devtools profile report @c5 # Detailed report for one component
agent-react-devtools profile timeline # Chronological commit list
agent-react-devtools profile commit 3 # Detail for commit #3
agent-react-devtools profile export profile.json # Export as React DevTools Profiler JSON
agent-react-devtools profile diff before.json after.json # Compare two exports
Every component gets a stable label like @c1, @c2. Use these to reference components in follow-up commands:
@c1 [fn] App
├─ @c2 [fn] Header
├─ @c3 [fn] TodoList
│ ├─ @c4 [fn] TodoItem key=1
│ └─ @c5 [fn] TodoItem key=2
└─ @c6 [host] div
Type abbreviations: fn = function, cls = class, host = DOM element, memo = React.memo, fRef = forwardRef, susp = Suspense, ctx = context.
Components with errors or warnings show annotations: ⚠2 = 2 warnings, ✗1 = 1 error. Use agent-react-devtools errors to list only affected components.
@c3 [fn] TodoList
props:
items: [{"id":1,"text":"Buy milk"},{"id":2,"text":"Walk dog"}]
onDelete: ƒ
state:
filter: "all"
hooks:
useState: "all"
useMemo: [...]
useCallback: ƒ
ƒ = function value. Values over 60 chars are truncated.
Slowest (by avg render time):
@c3 [fn] ExpensiveList avg:12.3ms max:18.1ms renders:47 causes:props-changed changed: props: items, filter
@c4 [fn] TodoItem avg:2.1ms max:5.0ms renders:94 causes:parent-rendered, props-changed changed: props: onToggle
Render causes: props-changed, state-changed, hooks-changed, parent-rendered, force-update, first-mount.
When specific changed keys are available, a changed: suffix shows exactly which props, state keys, or hooks triggered the render (e.g. changed: props: onClick, className state: count hooks: #0).
agent-react-devtools wait --connected --timeout 10
agent-react-devtools get tree
Use this after triggering a page reload or HMR update to avoid querying empty state.
agent-react-devtools profile start
# User interacts with the app (or use agent-browser to drive the UI)
agent-react-devtools profile stop
agent-react-devtools profile slow --limit 5
agent-react-devtools profile rerenders --limit 5
Then inspect the worst offenders with get component @cN and profile report @cN.
agent-react-devtools find SearchBar
agent-react-devtools get component @c12
agent-react-devtools profile start
# Repeat the interaction
agent-react-devtools profile stop
agent-react-devtools profile slow --limit 5
# Compare render counts and durations to the previous run
When using agent-browser to drive the app while profiling or debugging, you must use headed mode (--headed). Headless Chromium does not execute ES module scripts the same way as a real browser, which prevents the devtools connect script from running properly.
agent-browser --session devtools --headed open http://localhost:5173/
agent-react-devtools status # Should show 1 connected app
wait --connected then re-check with get tree or find.status first — if status shows 0 connected apps, the React app is not connected. The user may need to run npx agent-react-devtools init in their project first.agent-browser, always use --headed mode. Headless Chromium does not properly load the devtools connect script.profile start and profile stop. Make sure the relevant interaction happens during that window.| File | When to read |
|---|---|
| commands.md | Full command reference with all flags and edge cases |
| profiling-guide.md | Step-by-step profiling workflows and interpreting results |
| setup.md | How to connect different frameworks (Vite, Next.js, Expo, CRA) |
Weekly Installs
48
Repository
GitHub Stars
53
First Seen
Feb 11, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykPass
Installed on
codex46
opencode45
github-copilot45
gemini-cli45
amp41
kimi-cli41
GSAP时间轴动画教程:创建多步骤序列动画与关键帧控制
4,100 周安装
内容趋势研究员 | 多平台数据分析与SEO内容策略生成工具
48 周安装
Better Auth 集成指南:TypeScript 身份验证框架,支持 OAuth、魔法链接、通行密钥
48 周安装
.NET Thread.Abort 迁移指南:从 .NET Framework 到 .NET 6+ 的协作式取消
48 周安装
Python面板数据分析技能:使用pandas和linearmodels进行固定效应与双重差分模型估计
48 周安装
Drift Protocol SDK 开发指南 - Solana 永续期货与现货交易协议集成教程
48 周安装
Web无障碍性(WCAG 2.2 AA)最佳实践指南:语义化HTML、键盘导航与ARIA
48 周安装
--depth on large trees — a deep tree can produce a lot of output. Start with --depth 3 or --depth 4 and go deeper only on the subtree you care about.