next-dev-loop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesenext-dev-loop
next-dev-loop
The edit/verify rhythm during — make a change, then
confirm it actually works at runtime, not only that the types or
the build are happy.
next devYou verify through two views of the same running app:
- — an HTTP endpoint Next.js exposes about itself. Knows framework-specific things: routes, segments, RSC, server actions, server logs, and errors as Next.js saw them. Call
/_next/mcpfor the current surface.tools/list - — a CLI that drives a real Chrome. Knows framework-agnostic browser things: DOM, console, network, React fiber, vitals. Run
agent-browserfor the current surface.agent-browser --help
The two views cross-check each other.
next dev你可以通过运行中应用的两个视角进行验证:
- — Next.js暴露的一个HTTP端点,包含框架专属信息:路由、分段、RSC、服务器操作、服务器日志以及Next.js捕获的错误。调用
/_next/mcp可查看当前可用功能。tools/list - — 驱动真实Chrome浏览器的CLI工具,支持与框架无关的浏览器相关操作:DOM、控制台、网络、React Fiber、性能指标。运行
agent-browser可查看当前可用功能。agent-browser --help
这两个视角可以互相交叉验证。
requires
依赖要求
- Next.js 16.3+ with Turbopack — plus the proactive compile check via
/_next/mcp.get_compilation_issues - >= 0.27.0 — when React introspection landed.
agent-browser
These are hard floors, not soft preferences. If anything is missing,
tell the user how to upgrade and stop. Don't fall back to grepping
source or to a weaker probe — this skill assumes both views are live
at the versions above.
- Upgrade Next.js: (or
pnpm next upgrade). Docs: https://nextjs.org/docs/app/getting-started/upgrading (version-16 guide: https://nextjs.org/docs/app/guides/upgrading/version-16)npx next upgrade - Upgrade :
agent-browser.npm i -g agent-browser@latest
- 搭载Turbopack的Next.js **16.3+**版本——支持以及通过
/_next/mcp进行主动编译检查。get_compilation_issues - >= 0.27.0版本——此版本引入了React自省功能。
agent-browser
这些是硬性要求,而非可选配置。若缺少任一组件,请告知用户升级方法并终止流程。不要退回到搜索源码或使用更弱的探测方式——此技能假设上述版本的两个视角均已启用。
- 升级Next.js:(或
pnpm next upgrade)。文档:https://nextjs.org/docs/app/getting-started/upgrading(16版本指南:https://nextjs.org/docs/app/guides/upgrading/version-16)npx next upgrade - 升级:
agent-browser。npm i -g agent-browser@latest
preflight
预检查
Once per session, confirm both views are live.
-
Openat the target URL, restoring saved login state when present. Build the
agent-browsercommand from:open- where
--session-name <slug>is the project directory basename.<slug> - if that file exists. Omit on first run — a missing path fails the open.
--state ~/.agent-browser/sessions/<slug>-default.json - .
--headed --enable react-devtools
The browser is the user's. If state was not restored (first run, expired session) and the page is gated, the user drives the login — pause until they confirm. Session state is sticky: you can't addafter the session is open, and--enable react-devtoolson a not-yet-opened session creates a sessionless cookie that silently fails to apply.cookies set -
POSTto
tools/list. Send/_next/mcp; responses are SSE-framed, strip theAccept: application/json, text/event-streamprefix before parsing JSON.data:- Unreachable → either isn't running, or Next.js is below 16.3. Check
next devto disambiguate, then refuse.package.json - not in the list → Next.js below 16.3. Refuse and tell the user to upgrade.
get_compilation_issues
- Unreachable → either
-
doubles as a Turbopack probe. An error response of
mcp get_compilation_issuesmeans the user is on webpack. Refuse — Turbopack is required."Turbopack project is not available..." -
→ your route map for the rest of the session.
mcp get_routes
每次会话开始时,需确认两个视角均已启用。
-
在目标URL打开,如有保存的登录状态则恢复。 构建
agent-browser命令需包含:open- ,其中
--session-name <slug>为项目目录的基础名称。<slug> - 若文件存在,添加;首次运行时省略——路径不存在会导致打开失败。
--state ~/.agent-browser/sessions/<slug>-default.json - 。
--headed --enable react-devtools
浏览器归用户所有。若未恢复状态(首次运行或会话过期)且页面需要登录,由用户完成登录操作——等待用户确认后再继续。会话状态是固定的:会话打开后无法添加,且在会话未打开时设置--enable react-devtools会创建无会话的cookie,导致无法生效。cookies set -
向发送POST请求
/_next/mcp。请求头设置tools/list;响应为SSE格式,解析JSON前需移除Accept: application/json, text/event-stream前缀。data:- 无法访问 → 要么未运行,要么Next.js版本低于16.3。检查
next dev以区分情况,然后拒绝继续。package.json - 列表中无→ Next.js版本低于16.3。拒绝继续并告知用户升级。
get_compilation_issues
- 无法访问 → 要么
-
同时可作为Turbopack探测工具。若返回错误
mcp get_compilation_issues,说明用户使用的是webpack。拒绝继续——必须使用Turbopack。"Turbopack project is not available..." -
→ 获取后续会话所需的路由映射。
mcp get_routes
loop
循环流程
before the edit — narrow the scope
编辑前——缩小范围
Ask the running app, not the codebase. knows which
files rendered the current route; use those as your search scope.
Runtime introspection stays cheap as the codebase grows; agentic
search doesn't.
/_next/mcp向运行中的应用查询,而非代码库。知晓当前路由对应的渲染文件;将这些文件作为搜索范围。运行时自省在代码库扩大时仍能保持高效,而智能搜索则不行。
/_next/mcpafter the edit — verify
编辑后——验证
Four failure modes. Check each:
- Compiles — .
mcp get_compilation_issues - Runs without errors — (server and bubbled-up browser errors both surface here).
/_next/mcp - Behaves as intended — drives the page; assert what the user actually sees.
agent-browser - React-level behavior — with react-devtools enabled exposes the component tree, props, state, and render counts. Anchor framework-level checks here (extra renders, server/client boundary shifts, suspense fallbacks) — DOM asserts alone miss them.
agent-browser
Pick the specific tool from or rather than from memory.
tools/listagent-browser --help四种失败模式,需逐一检查:
- 编译通过 — 。
mcp get_compilation_issues - 运行无错误 — (服务器和冒泡上来的浏览器错误都会在此显示)。
/_next/mcp - 行为符合预期 — 驱动页面,验证用户实际看到的内容。
agent-browser - React层面行为 — 启用react-devtools的可展示组件树、props、state以及渲染次数。在此进行框架层面的检查(额外渲染、服务端/客户端边界变化、suspense回退)——仅DOM断言会遗漏这些问题。
agent-browser
从或中选择具体工具,而非凭记忆调用。
tools/listagent-browser --helpgotchas
注意事项
- React introspection output is stale after navigation. Re-run.
- Non-3000 dev server: read the banner; set
next dev.NEXT_MCP_URL=http://localhost:<port>/_next/mcp - and
get_errorsneed at least one navigation to populate.get_page_metadata
- 导航后React自省输出会过时,需重新运行。
- 非3000端口的开发服务器:查看启动横幅;设置
next dev。NEXT_MCP_URL=http://localhost:<port>/_next/mcp - 和
get_errors需要至少一次导航才能填充数据。get_page_metadata
reference
参考
All tools below are present once preflight passes. If
is missing any of them, preflight should have refused — re-check.
tools/listundefined预检查通过后,以下所有工具均可用。若中缺少任一工具,预检查应已拒绝继续——请重新检查。
tools/listundefined/_next/mcp notes
/_next/mcp 说明
get_project_metadata projectPath, devServerUrl, bundler
get_routes fs-scan; no browser session needed
get_errors runtime + build; needs a browser session;
includes browser-side errors caught by the
dev server
get_page_metadata segment trie + routerType; needs a browser
session; use as a discovery shortcut for
which files power a route
get_logs returns logFilePath
get_server_action_by_id hashed id → file + functionName
get_compilation_issues Turbopack only; errors on webpack
("Turbopack project is not available")
undefinedget_project_metadata 项目路径、开发服务器URL、打包工具
get_routes 文件系统扫描;无需浏览器会话
get_errors 运行时+构建错误;需要浏览器会话;包含开发服务器捕获的浏览器端错误
get_page_metadata 分段字典树+路由类型;需要浏览器会话;可快速发现路由对应的文件
get_logs 返回日志文件路径
get_server_action_by_id 哈希ID → 文件+函数名
get_compilation_issues 仅支持Turbopack;使用webpack时会报错("Turbopack project is not available")
undefinedteardown
收尾
Close the session — writes state
to disk so the next loop's restores login. Leave
up for the next loop.
agent-browser--session-name--statenext devnext-dev-loop-<topic>next-dev-loop-rscnext-dev-loop-debug关闭会话——会将状态写入磁盘,以便下一次循环通过恢复登录状态。保持运行,供下一次循环使用。
agent-browser--session-name--statenext devnext-dev-loop-<topic>next-dev-loop-rscnext-dev-loop-debug