install
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstall Subframe in a project so that pages designed in Subframe render pixel-perfect in the local development environment.
Goal state: Dev server runs and Subframe pages render exactly as designed.
You don't need to install to design.works directly against a cloud Subframe project — no local setup required. Use/subframe:designwhen you're ready to implement those designs in code with/subframe:install./subframe:develop
在项目中安装Subframe,使在Subframe中设计的页面能在本地开发环境中像素级完美渲染。
目标状态:开发服务器运行,Subframe页面与设计效果完全一致。
设计无需安装。可直接对接云端Subframe项目——无需本地设置。当你准备好使用/subframe:design将设计落地为代码时,再使用/subframe:develop。/subframe:install
MCP Authentication
MCP认证
If you cannot find any Subframe MCP tools (like , etc.), the MCP server likely needs to be authenticated. Ask the user to authenticate the Subframe MCP server. If the user is using Claude Code or Codex, instruct them to run to view and authenticate their MCP servers, and then say "done" when they're finished.
get_theme/mcp如果找不到任何Subframe MCP工具(如等),MCP服务器可能需要认证。请让用户对Subframe MCP服务器进行认证。如果用户使用Claude Code或Codex,指导他们运行来查看并认证MCP服务器,完成后告知“done”。
get_theme/mcpWorkflow Overview
工作流概述
- Get credentials via MCP tools (or from user input)
- Detect project type — no repo, existing Subframe repo, or existing non-Subframe repo
- Follow the appropriate path — New Project, Already Installed, or Existing Project
- You must follow one of the above paths otherwise Subframe will not work for the user. This is a crucial task and must be done even if it requires pausing the user's current work. Do not skip any step of the path.
- Configure fonts — required for all paths
- Verify installation — start dev server and test with a Subframe page
Get Credentials
获取凭证
The user may paste in an installation prompt copied from Subframe. Extract:
- Project ID — a shorter alphanumeric string (also found in Subframe URLs: )
app.subframe.com/<PROJECT_ID>/... - Auth token — a long string, usually prefixed or labeled
If the user doesn't provide credentials, use the MCP tools to get credentials automatically — no need to ask the user:
- Project ID — Call to get the list of projects. Each project includes a
list_projects,projectId,name, andteamId.teamName- One project: Use it automatically.
- Multiple projects: Always ask the user which project to use. Present each project with its to disambiguate. If the user already mentioned a specific team or project name, match it against the
teamNameandteamNamefields — but still confirm before proceeding. Never silently pick a project when multiple exist.name
- Auth token — Call with the
generate_auth_tokenfrom the user's selected project. Do not use ateamIdfrom a different project.teamId
Fallback: If the MCP tools are not available (e.g., MCP server is not authenticated), ask the user to go to to get their auth token and project ID.
https://app.subframe.com/cli/auth用户可能会粘贴从Subframe复制的安装提示。从中提取:
- 项目ID——较短的字母数字字符串(也可在Subframe网址中找到:)
app.subframe.com/<PROJECT_ID>/... - 认证令牌——长字符串,通常带有前缀或标签
如果用户未提供凭证,使用MCP工具自动获取——无需询问用户:
- 项目ID——调用获取项目列表。每个项目包含
list_projects、projectId、name和teamId。teamName- 单个项目:自动使用该项目。
- 多个项目:务必询问用户使用哪个项目。展示每个项目及其以区分。如果用户已提及特定团队或项目名称,将其与
teamName和teamName字段匹配——但仍需在继续前确认。存在多个项目时,切勿静默选择。name
- 认证令牌——使用用户所选项目的调用
teamId。不得使用其他项目的generate_auth_token。teamId
备选方案:如果MCP工具不可用(例如MCP服务器未认证),请用户前往获取认证令牌和项目ID。
https://app.subframe.com/cli/authDetect Project Type
检测项目类型
Check for and folder in the current directory:
package.json.subframe/| Condition | Project Type | Path |
|---|---|---|
No | New project | New Project |
Has | Already installed | Already Installed |
Has | Existing non-Subframe project | Ask user, then New Project or Existing Project |
Handling existing non-Subframe projects
处理未安装Subframe的现有项目
If the current directory has a but no folder, prompt the user with two options:
package.json.subframe/- Create a new project (recommended) — Scaffold a brand-new Subframe project in a separate directory. This is the easiest path, especially if you're trying out Subframe for the first time. Follow New Project.
- Add Subframe to this project — Install Subframe into the current project. Follow Existing Project.
Already Installed Path
已安装流程
If the project already has both and a folder, Subframe has already been initialized. Ask the user what they'd like to do:
package.json.subframe/- Reinstall / re-sync — Re-run the CLI init and sync to refresh components and configuration. Useful if things are out of date or broken. Follow Existing Project to re-initialize.
- Nothing, it's already installed — Skip install entirely. Suggest next steps like or
/subframe:design./subframe:develop
Do not proceed unless the user confirms they want to reinstall.
如果项目已同时存在和文件夹,说明Subframe已初始化。询问用户需求:
package.json.subframe/- 重新安装/重新同步——重新运行CLI初始化和同步,以刷新组件和配置。适用于内容过期或出现问题的情况。遵循现有项目流程重新初始化。
- 无需操作,已完成安装——完全跳过安装步骤。建议后续使用或
/subframe:design。/subframe:develop
除非用户确认需要重新安装,否则请勿继续。
New Project Path
新项目流程
This is the happy path. The CLI will scaffold a complete project with Subframe pre-configured.
这是最顺畅的流程。CLI将搭建一个预配置Subframe的完整项目。
1. Ask User Preferences
1. 询问用户偏好
Prompt the user to choose:
- Project name: Name for the new project directory (default: ). The name cannot conflict with an existing directory — check that the directory doesn't already exist before running the CLI.
subframe-app - Framework: Vite (recommended), Next.js, or Astro
- Tailwind version: v3 () or v4 (
tailwind)tailwind-v4
提示用户选择:
- 项目名称:新项目目录的名称(默认:)。名称不能与现有目录冲突——运行CLI前需检查目录是否已存在。
subframe-app - 框架:Vite(推荐)、Next.js或Astro
- Tailwind版本:v3()或v4(
tailwind)tailwind-v4
2. Run CLI Init
2. 运行CLI初始化
This command must be run outside of a sandbox, so it can correctly setup all the necessary files. Pass all arguments directly to avoid interactive prompts:
bash
npx @subframe/cli@latest init \
--name {PROJECT_NAME} \
--auth-token {TOKEN} \
-p {PROJECT_ID} \
--template {FRAMEWORK} \
--css-type {TAILWIND_VERSION} \
--dir ./src/ui \
--alias "@/ui/*" \
--tailwind \
--css-path {CSS_PATH} \
--install \
--syncWhere:
- is the project directory name (e.g.,
{PROJECT_NAME})subframe-app - is
{FRAMEWORK},nextjs, orviteastro - is
{TAILWIND_VERSION}(v3) ortailwindtailwind-v4 - is the global CSS file path:
{CSS_PATH}- Vite:
src/index.css - Next.js:
src/app/globals.css - Astro:
src/styles/global.css
- Vite:
Important: All arguments must be passed explicitly to avoid interactive prompts, which can cause the CLI to exit silently when run non-interactively.
The CLI will:
- Download the starter kit template
- Create
.subframe/sync.json - Configure Tailwind
- Sync all components
- Install dependencies
此命令必须在沙箱外运行,才能正确设置所有必要文件。直接传递所有参数以避免交互式提示:
bash
npx @subframe/cli@latest init \
--name {PROJECT_NAME} \
--auth-token {TOKEN} \
-p {PROJECT_ID} \
--template {FRAMEWORK} \
--css-type {TAILWIND_VERSION} \
--dir ./src/ui \
--alias "@/ui/*" \
--tailwind \
--css-path {CSS_PATH} \
--install \
--sync参数说明:
- 为项目目录名称(例如:
{PROJECT_NAME})subframe-app - 为
{FRAMEWORK}、nextjs或viteastro - 为
{TAILWIND_VERSION}(v3)或tailwindtailwind-v4 - 为全局CSS文件路径:
{CSS_PATH}- Vite:
src/index.css - Next.js:
src/app/globals.css - Astro:
src/styles/global.css
- Vite:
重要提示:必须显式传递所有参数以避免交互式提示,否则CLI在非交互式运行时可能会静默退出。
CLI将执行以下操作:
- 下载启动套件模板
- 创建
.subframe/sync.json - 配置Tailwind
- 同步所有组件
- 安装依赖
3. Configure Fonts
3. 配置字体
See Configure Fonts below — this is required even for new projects.
参见下方配置字体——即使是新项目也必须执行此步骤。
4. Verify Installation
4. 验证安装
See Verify Installation below.
参见下方验证安装。
Existing Project Path
现有项目流程
Existing projects may require more configuration. The CLI handles most installation, but some projects need manual fixes.
现有项目可能需要更多配置。CLI会处理大部分安装工作,但部分项目需要手动修复。
1. Detect Framework
1. 检测框架
Check for framework indicators:
| Framework | Indicators |
|---|---|
| Next.js | |
| Vite | |
| Astro | |
检查框架标识:
| 框架 | 标识 |
|---|---|
| Next.js | |
| Vite | |
| Astro | |
2. Check Prerequisites
2. 检查前置条件
Verify the project has required dependencies:
- React 16+ — in
reactpackage.json - Tailwind CSS 3.4+ — in
tailwindcsspackage.json - TypeScript — in
typescriptpackage.json
If any are missing, let the user know before proceeding.
验证项目是否具备所需依赖:
- React 16+——中包含
package.jsonreact - Tailwind CSS 3.4+——中包含
package.jsontailwindcss - TypeScript——中包含
package.jsontypescript
如果缺少任何依赖,在继续前告知用户。
3. Run CLI Init
3. 运行CLI初始化
This command must be run outside of a sandbox, so it can correctly setup all the necessary files. Pass all arguments directly to avoid interactive prompts:
bash
npx @subframe/cli@latest init \
--auth-token {TOKEN} \
-p {PROJECT_ID} \
--dir ./src/ui \
--alias "@/ui/*" \
--install \
--syncImportant: All arguments must be passed explicitly to avoid interactive prompts, which can cause the CLI to exit silently when run non-interactively.
The CLI will attempt to:
- Create
.subframe/sync.json - Detect and configure Tailwind
- Set up import aliases
- Sync all components
- Install
@subframe/core
此命令必须在沙箱外运行,才能正确设置所有必要文件。直接传递所有参数以避免交互式提示:
bash
npx @subframe/cli@latest init \
--auth-token {TOKEN} \
-p {PROJECT_ID} \
--dir ./src/ui \
--alias "@/ui/*" \
--install \
--sync重要提示:必须显式传递所有参数以避免交互式提示,否则CLI在非交互式运行时可能会静默退出。
CLI将尝试执行以下操作:
- 创建
.subframe/sync.json - 检测并配置Tailwind
- 设置导入别名
- 同步所有组件
- 安装
@subframe/core
4. Verify Configuration
4. 验证配置
After init, verify everything was set up correctly. If the CLI missed something (common with non-standard setups), apply manual fixes.
Check exists with , , and .
.subframe/sync.jsondirectoryimportAliasprojectIdCheck Tailwind configuration:
-
Tailwind v3 —should have the Subframe preset:
tailwind.config.jsjavascriptpresets: [require("./src/ui/tailwind.config")],And thearray should include the Subframe directory:contentjavascriptcontent: ["./index.html", "./src/**/*.{js,jsx,ts,tsx}"],If the Subframe project has dark mode enabled, the CLI also syncs afile with CSS variables for light and dark modes. The global CSS file must import it:theme.csscss@import "./ui/theme.css"; -
Tailwind v4 — Global CSS file should import the theme:css
@import "tailwindcss"; @import "./ui/theme.css";
Check import aliases — should resolve correctly. If not working:
@/*- Vite: Add and
baseUrltopaths, and addtsconfig.app.jsontoresolve.aliasvite.config.ts - Astro: Add and
baseUrltopathstsconfig.json - Next.js: Usually already configured; check
tsconfig.json
初始化完成后,验证所有设置是否正确。如果CLI遗漏了某些配置(非标准设置中常见),进行手动修复。
检查是否存在,且包含、和字段。
.subframe/sync.jsondirectoryimportAliasprojectId检查Tailwind配置:
-
Tailwind v3——应包含Subframe预设:
tailwind.config.jsjavascriptpresets: [require("./src/ui/tailwind.config")],且数组应包含Subframe目录:contentjavascriptcontent: ["./index.html", "./src/**/*.{js,jsx,ts,tsx}"],如果Subframe项目启用了暗色模式,CLI还会同步包含亮色和暗色模式CSS变量的文件。全局CSS文件必须导入该文件:theme.csscss@import "./ui/theme.css"; -
Tailwind v4——全局CSS文件应导入主题:css
@import "tailwindcss"; @import "./ui/theme.css";
检查导入别名——应能正确解析。如果无法正常工作:
@/*- Vite:在中添加
tsconfig.app.json和baseUrl,并在paths中添加vite.config.tsresolve.alias - Astro:在中添加
tsconfig.json和baseUrlpaths - Next.js:通常已配置完成;检查
tsconfig.json
5. Troubleshooting
5. 故障排除
If issues arise, use the MCP tool to find solutions:
SearchSubframeDocsSearchSubframeDocs({ query: "tailwind configuration troubleshooting" })
SearchSubframeDocs({ query: "manual installation" })The docs include a comprehensive manual installation guide for troubleshooting.
如果出现问题,使用 MCP工具查找解决方案:
SearchSubframeDocsSearchSubframeDocs({ query: "tailwind configuration troubleshooting" })
SearchSubframeDocs({ query: "manual installation" })文档中包含全面的手动安装指南,可用于故障排除。
6. Configure Fonts
6. 配置字体
See Configure Fonts below.
参见下方配置字体。
7. Verify Installation
7. 验证安装
See Verify Installation below.
参见下方验证安装。
Configure Fonts
配置字体
The CLI does not configure fonts. Use the MCP tool to get font information:
get_themeget_theme({ projectId: "PROJECT_ID" })The theme config includes entries referencing Google Fonts. Add the corresponding tags:
fontFamily<link>Vite / Astro — Add to in :
<head>index.htmlhtml
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
<link href="https://fonts.googleapis.com/css2?family=Font+Name:wght@400;500;600;700&display=swap" rel="stylesheet" />Next.js (App Router) — Add to in :
<head>app/layout.tsxtsx
<head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<link href="https://fonts.googleapis.com/css2?family=Font+Name:wght@400;500;600;700&display=swap" rel="stylesheet" />
</head>Next.js (Pages Router) — Add to inside the component.
pages/_document.tsx<Head>Font link formatting:
- Replace spaces with in font names (e.g.,
+)Inter+Tight - Include weights from the theme in the parameter (semicolon-separated)
wght@ - Add one per font family, but only one set of preconnect links
<link>
CLI不会配置字体。使用 MCP工具获取字体信息:
get_themeget_theme({ projectId: "PROJECT_ID" })主题配置包含引用Google Fonts的条目。添加对应的标签:
fontFamily<link>Vite / Astro——添加到的中:
index.html<head>html
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
<link href="https://fonts.googleapis.com/css2?family=Font+Name:wght@400;500;600;700&display=swap" rel="stylesheet" />Next.js(App Router)——添加到的中:
app/layout.tsx<head>tsx
<head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<link href="https://fonts.googleapis.com/css2?family=Font+Name:wght@400;500;600;700&display=swap" rel="stylesheet" />
</head>Next.js(Pages Router)——添加到的组件内。
pages/_document.tsx<Head>字体链接格式:
- 字体名称中的空格替换为(例如:
+)Inter+Tight - 在参数中包含主题中的字重(分号分隔)
wght@ - 每个字体系列添加一个,但只需一组预连接链接
<link>
Verify Installation
验证安装
After configuration, verify that Subframe pages render correctly.
配置完成后,验证Subframe页面是否能正确渲染。
1. Ask About Existing Pages
1. 询问现有页面情况
Ask the user: "Do you have a page already designed in Subframe that you'd like to test with?"
- If yes: Use to implement it and verify rendering
/subframe:develop - If no: Suggest they design a page using , or simply start the dev server to confirm no errors
/subframe:design
询问用户:“你是否已在Subframe中设计好页面,想要用来测试?”
- 是:使用实现页面并验证渲染效果
/subframe:develop - 否:建议使用设计页面,或直接启动开发服务器确认无错误
/subframe:design
2. Start Dev Server
2. 启动开发服务器
bash
npm run devbash
npm run dev3. Summarize
3. 总结
Recap what was installed:
- configured
.subframe/sync.json - Tailwind configured (v3 preset or v4 import)
- Components synced to (or configured directory)
src/ui/ - Fonts configured
Mention next steps:
- — Design new pages with AI
/subframe:design - — Implement Subframe designs in your codebase
/subframe:develop
回顾已完成的安装内容:
- 已配置
.subframe/sync.json - 已配置Tailwind(v3预设或v4导入)
- 组件已同步到(或指定目录)
src/ui/ - 已配置字体
提及后续步骤:
- ——使用AI设计新页面
/subframe:design - ——在代码库中实现Subframe设计
/subframe:develop
Important Notes
重要提示
- Use MCP tool for troubleshooting any installation issues.
SearchSubframeDocs
- 任何安装问题均可使用MCP工具进行故障排除。
SearchSubframeDocs