iterate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSet up iterate in the user's project. This skill detects the framework, installs the right adapter, configures everything, and gets the user ready to go.
在用户项目中设置iterate。该技能会检测框架、安装正确的适配器、完成所有配置,让用户可以直接上手使用。
Steps
步骤
-
Detect the framework. Look at the project's dependencies in:
package.json- Next.js: Has in dependencies or devDependencies → use
nextiterate-ui-next - Vite: Has in dependencies or devDependencies → use
viteiterate-ui-vite - If both are present, ask the user which one to configure
- If neither is found, tell the user iterate currently supports Next.js and Vite, and stop
- Next.js: Has
-
Detect the package manager. Check for lock files in the project root:
- → pnpm
pnpm-lock.yaml - or
bun.lockb→ bunbun.lock - → yarn
yarn.lock - Otherwise → npm
-
Install the adapter package as a dev dependency using the detected package manager:
- pnpm:
pnpm add -D <package> - bun:
bun add -D <package> - yarn:
yarn add -D <package> - npm:
npm install -D <package>
- pnpm:
-
Wire into the framework config. Read the existing config file and add the iterate wrapper:Next.js (,
next.config.mjs, ornext.config.js):next.config.ts- Add at the top
import { withIterate } from "iterate-ui-next" - Wrap the default export with :
withIterate()jsexport default withIterate(nextConfig); - If the config already uses , skip this step
withIterate - Next.js 16+ / Turbopack: Read the field from
versionto determine the major version. If it's 16+, the overlay must also be loaded via a React component (webpack injection is ignored by Turbopack). Find the root layout file (node_modules/next/package.jsonorapp/layout.tsx) and add:app/layout.jsxThen rendertsximport { IterateDevTools } from "iterate-ui-next/devtools";inside<IterateDevTools />, after<body>. If the layout already has{children}, skip this step.<IterateDevTools />
Vite (,vite.config.ts, orvite.config.js):vite.config.mjs- Add at the top
import { iterate } from "iterate-ui-vite" - Add to the
iterate()array:pluginsjsplugins: [react(), iterate()] - If the config already uses , skip this step
iterate()
- Add
-
Createif it doesn't exist. Detect the dev command from
.iterate/config.jsonscripts (preferpackage.json, fallback todev):startjson{ "devCommand": "<detected dev command>", "packageManager": "<detected package manager>", "basePort": 3100, "daemonPort": 4000, "maxIterations": 3, "idleTimeout": 0 } -
Createfor Claude Code MCP integration if it doesn't exist. If it already exists, check whether it already has an
.mcp.jsonserver entry — if not, add one:iteratejson{ "mcpServers": { "iterate": { "command": "npx", "args": ["iterate-mcp"], "env": { "ITERATE_DAEMON_PORT": "4000" } } } } -
Register the Claude Code plugin inso the iterate skills (
.claude/settings.json,/iterate:go,/iterate:prompt) are available. Create the file if it doesn't exist, or merge into the existing settings:/iterate:keepjson{ "extraKnownMarketplaces": { "iterate-plugins": { "source": { "source": "github", "repo": "connorwhite-online/iterate" } } }, "enabledPlugins": { "iterate@iterate-plugins": true } } -
Summarize. Tell the user what was set up and what to do next:
- Restart Claude Code to activate the MCP server and slash commands
- Available slash commands: ,
/iterate:prompt,/iterate:go/iterate:keep - The iterate overlay will appear automatically when their dev server runs
-
检测框架。 查看中项目的依赖项:
package.json- Next.js: 依赖或开发依赖中包含→ 使用
nextiterate-ui-next - Vite: 依赖或开发依赖中包含→ 使用
viteiterate-ui-vite - 如果两者都存在,询问用户需要配置哪一个
- 如果两者都不存在,告知用户iterate目前仅支持Next.js和Vite,终止操作
- Next.js: 依赖或开发依赖中包含
-
检测包管理器。 检查项目根目录下的锁文件:
- → pnpm
pnpm-lock.yaml - 或
bun.lockb→ bunbun.lock - → yarn
yarn.lock - 其他情况 → npm
-
使用检测到的包管理器安装适配器包作为开发依赖:
- pnpm:
pnpm add -D <package> - bun:
bun add -D <package> - yarn:
yarn add -D <package> - npm:
npm install -D <package>
- pnpm:
-
接入框架配置。 读取现有配置文件,添加iterate包装器:Next.js (、
next.config.mjs或next.config.js):next.config.ts- 在顶部添加
import { withIterate } from "iterate-ui-next" - 用包装默认导出:
withIterate()jsexport default withIterate(nextConfig); - 如果配置中已经使用了,跳过该步骤
withIterate - Next.js 16+ / Turbopack: 读取中的
node_modules/next/package.json字段判断主版本号。如果是16及以上版本,浮层还需要通过React组件加载(Turbopack会忽略webpack注入)。 找到根布局文件(version或app/layout.tsx)并添加:app/layout.jsx然后在tsximport { IterateDevTools } from "iterate-ui-next/devtools";标签内部、<body>之后渲染{children}。 如果布局文件中已经存在<IterateDevTools />,跳过该步骤。<IterateDevTools />
Vite (、vite.config.ts或vite.config.js):vite.config.mjs- 在顶部添加
import { iterate } from "iterate-ui-vite" - 向数组中添加
plugins:iterate()jsplugins: [react(), iterate()] - 如果配置中已经使用了,跳过该步骤
iterate()
- 在顶部添加
-
如果不存在则创建该文件。 从
.iterate/config.json的scripts中检测开发命令(优先选择package.json, fallback为dev):startjson{ "devCommand": "<detected dev command>", "packageManager": "<detected package manager>", "basePort": 3100, "daemonPort": 4000, "maxIterations": 3, "idleTimeout": 0 } -
如果不存在则创建该文件用于Claude Code MCP集成。 如果文件已存在,检查是否已经有
.mcp.json服务器条目,如果没有则添加:iteratejson{ "mcpServers": { "iterate": { "command": "npx", "args": ["iterate-mcp"], "env": { "ITERATE_DAEMON_PORT": "4000" } } } } -
在中注册Claude Code插件,这样就可以使用iterate技能(
.claude/settings.json、/iterate:go、/iterate:prompt)。如果文件不存在则创建,否则合并到现有配置中:/iterate:keepjson{ "extraKnownMarketplaces": { "iterate-plugins": { "source": { "source": "github", "repo": "connorwhite-online/iterate" } } }, "enabledPlugins": { "iterate@iterate-plugins": true } } -
总结。 告知用户已完成的配置内容和后续操作:
- 重启Claude Code以激活MCP服务器和斜杠命令
- 可用的斜杠命令:、
/iterate:prompt、/iterate:go/iterate:keep - 当用户的开发服务器运行时,iterate浮层会自动弹出