setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSet up 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.
在项目中设置Subframe,使Subframe中设计的页面在本地开发环境中实现像素级完美渲染。
目标状态:开发服务器运行,Subframe页面与设计效果完全一致。
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, 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,指导他们运行来查看并认证MCP服务器,完成后告知“done”。
get_theme/mcpWorkflow Overview
工作流概述
- Parse credentials from the user's input
- Detect project type — no repo, existing Subframe repo, or existing non-Subframe repo
- Follow the appropriate path — New Project, Already Setup, or Existing Project
- Configure fonts — required for all paths
- Verify setup — start dev server and test with a Subframe page
Parse Credentials
解析凭证
The user may paste in an installation prompt copied from Subframe. Extract:
- Auth token — a long string, usually prefixed or labeled
- Project ID — a shorter alphanumeric string (also found in Subframe URLs: )
app.subframe.com/<PROJECT_ID>/...
If the user doesn't provide credentials, ask them 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>/...
如果用户未提供凭证,请引导他们前往获取认证令牌和项目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 setup | Already Setup |
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 Setup 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 set up — Skip setup entirely. Suggest next steps like or
/subframe:design./subframe:develop
Do not proceed with setup 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初始化命令
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 Setup
4. 验证设置
See Verify Setup below.
请查看下方的验证设置部分。
Existing Project Path
现有项目流程
Existing projects may require more configuration. The CLI handles most setup, 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初始化命令
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}"], -
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}"], -
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 Setup
7. 验证设置
See Verify Setup 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 Setup
验证设置
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 set up:
- 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 setup issues.
SearchSubframeDocs
- 若遇到任何设置问题,请使用MCP工具进行故障排除。
SearchSubframeDocs