setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Set 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
get_theme
, 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
/mcp
to view and authenticate their MCP servers, and then say "done" when they're finished.
如果找不到任何Subframe MCP工具(如
get_theme
等),可能需要对MCP服务器进行认证。请用户对Subframe MCP服务器进行认证。如果用户使用Claude Code,指导他们运行
/mcp
来查看并认证MCP服务器,完成后告知“done”。

Workflow Overview

工作流概述

  1. Parse credentials from the user's input
  2. Detect project type — no repo, existing Subframe repo, or existing non-Subframe repo
  3. Follow the appropriate pathNew Project, Already Setup, or Existing Project
  4. Configure fonts — required for all paths
  5. Verify setup — start dev server and test with a Subframe page

  1. 解析凭证:从用户输入中提取相关信息
  2. 检测项目类型 — 无仓库、已存在Subframe仓库、已存在非Subframe仓库
  3. 选择对应流程新项目流程已完成设置流程现有项目流程
  4. 配置字体 — 所有流程均需执行此步骤
  5. 验证设置 — 启动开发服务器并使用Subframe页面进行测试

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
https://app.subframe.com/cli/auth
to get their auth token and project ID.

用户可能会粘贴从Subframe复制的安装提示。请提取:
  • 认证令牌 — 长字符串,通常带有前缀或标签
  • 项目ID — 较短的字母数字字符串(也可在Subframe网址中找到:
    app.subframe.com/<PROJECT_ID>/...
如果用户未提供凭证,请引导他们前往
https://app.subframe.com/cli/auth
获取认证令牌和项目ID。

Detect Project Type

检测项目类型

Check for
package.json
and
.subframe/
folder in the current directory:
ConditionProject TypePath
No
package.json
New projectNew Project
Has
package.json
AND has
.subframe/
folder
Already setupAlready Setup
Has
package.json
but NO
.subframe/
folder
Existing non-Subframe projectAsk user, then New Project or Existing Project
检查当前目录下是否存在
package.json
.subframe/
文件夹:
条件项目类型对应流程
package.json
新项目新项目流程
存在
package.json
且存在
.subframe/
文件夹
已完成设置已完成设置流程
存在
package.json
但无
.subframe/
文件夹
现有非Subframe项目询问用户后,选择新项目流程现有项目流程

Handling existing non-Subframe projects

处理现有非Subframe项目

If the current directory has a
package.json
but no
.subframe/
folder, prompt the user with two options:
  • 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.

如果当前目录存在
package.json
但无
.subframe/
文件夹,请向用户提供两个选项:
  • 创建新项目(推荐) — 在独立目录中搭建全新的Subframe项目。这是最简单的流程,尤其适合首次使用Subframe的用户。遵循新项目流程
  • 在当前项目中添加Subframe — 在现有项目中安装Subframe。遵循现有项目流程

Already Setup Path

已完成设置流程

If the project already has both
package.json
and a
.subframe/
folder, Subframe has already been initialized. Ask the user what they'd like to do:
  • 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
    /subframe:design
    or
    /subframe:develop
    .
Do not proceed with setup unless the user confirms they want to reinstall.

如果项目已同时存在
package.json
.subframe/
文件夹,说明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:
    subframe-app
    ). The name cannot conflict with an existing directory — check that the directory doesn't already exist before running the CLI.
  • Framework: Vite (recommended), Next.js, or Astro
  • Tailwind version: v3 (
    tailwind
    ) or v4 (
    tailwind-v4
    )
请用户选择:
  • 项目名称:新项目目录的名称(默认:
    subframe-app
    )。名称不能与现有目录冲突——运行CLI前请确认目录不存在。
  • 框架:Vite(推荐)、Next.js或Astro
  • Tailwind版本:v3 (
    tailwind
    ) 或 v4 (
    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 \
  --sync
Where:
  • {PROJECT_NAME}
    is the project directory name (e.g.,
    subframe-app
    )
  • {FRAMEWORK}
    is
    nextjs
    ,
    vite
    , or
    astro
  • {TAILWIND_VERSION}
    is
    tailwind
    (v3) or
    tailwind-v4
  • {CSS_PATH}
    is the global CSS file path:
    • Vite:
      src/index.css
    • Next.js:
      src/app/globals.css
    • Astro:
      src/styles/global.css
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
    vite
    astro
  • {TAILWIND_VERSION}
    可选值为
    tailwind
    (v3)或
    tailwind-v4
  • {CSS_PATH}
    为全局CSS文件路径:
    • Vite:
      src/index.css
    • Next.js:
      src/app/globals.css
    • Astro:
      src/styles/global.css
重要提示:必须显式传入所有参数以避免交互式提示,否则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:
FrameworkIndicators
Next.js
next
in
package.json
dependencies,
next.config.*
file
Vite
vite
in
package.json
devDependencies,
vite.config.*
file
Astro
astro
in
package.json
dependencies,
astro.config.*
file
通过以下标识检测项目框架:
框架标识
Next.js
package.json
依赖中包含
next
,存在
next.config.*
文件
Vite
package.json
开发依赖中包含
vite
,存在
vite.config.*
文件
Astro
package.json
依赖中包含
astro
,存在
astro.config.*
文件

2. Check Prerequisites

2. 检查前置条件

Verify the project has required dependencies:
  • React 16+
    react
    in
    package.json
  • Tailwind CSS 3.4+
    tailwindcss
    in
    package.json
  • TypeScript
    typescript
    in
    package.json
If any are missing, let the user know before proceeding.
验证项目是否包含必要依赖:
  • React 16+
    package.json
    中包含
    react
  • Tailwind CSS 3.4+
    package.json
    中包含
    tailwindcss
  • TypeScript
    package.json
    中包含
    typescript
如果缺少任何依赖,请在继续前告知用户。

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 \
  --sync
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 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
.subframe/sync.json
exists
with
directory
,
importAlias
, and
projectId
.
Check Tailwind configuration:
  • Tailwind v3
    tailwind.config.js
    should have the Subframe preset:
    javascript
    presets: [require("./src/ui/tailwind.config")],
    And the
    content
    array should include the Subframe directory:
    javascript
    content: ["./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
    baseUrl
    and
    paths
    to
    tsconfig.app.json
    , and add
    resolve.alias
    to
    vite.config.ts
  • Astro: Add
    baseUrl
    and
    paths
    to
    tsconfig.json
  • Next.js: Usually already configured; check
    tsconfig.json
初始化完成后,验证所有设置是否正确。如果CLI遗漏了某些配置(非标准设置中常见),请进行手动修复。
检查
.subframe/sync.json
是否存在
,且包含
directory
importAlias
projectId
字段。
检查Tailwind配置:
  • Tailwind v3
    tailwind.config.js
    中应包含Subframe预设:
    javascript
    presets: [require("./src/ui/tailwind.config")],
    content
    数组应包含Subframe目录:
    javascript
    content: ["./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.ts
    中添加
    resolve.alias
  • Astro:在
    tsconfig.json
    中添加
    baseUrl
    paths
  • Next.js:通常已配置完成;检查
    tsconfig.json
    即可

5. Troubleshooting

5. 故障排除

If issues arise, use the
SearchSubframeDocs
MCP tool to find solutions:
SearchSubframeDocs({ query: "tailwind configuration troubleshooting" })
SearchSubframeDocs({ query: "manual installation" })
The docs include a comprehensive manual installation guide for troubleshooting.
如果出现问题,请使用
SearchSubframeDocs
MCP工具查找解决方案:
SearchSubframeDocs({ 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
get_theme
MCP tool to get font information:
get_theme({ projectId: "PROJECT_ID" })
The theme config includes
fontFamily
entries referencing Google Fonts. Add the corresponding
<link>
tags:
Vite / Astro — Add to
<head>
in
index.html
:
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) — Add to
<head>
in
app/layout.tsx
:
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) — Add to
pages/_document.tsx
inside the
<Head>
component.
Font link formatting:
  • Replace spaces with
    +
    in font names (e.g.,
    Inter+Tight
    )
  • Include weights from the theme in the
    wght@
    parameter (semicolon-separated)
  • Add one
    <link>
    per font family, but only one set of preconnect links

CLI不会自动配置字体。请使用
get_theme
MCP工具获取字体信息:
get_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
    /subframe:develop
    to implement it and verify rendering
  • If no: Suggest they design a page using
    /subframe:design
    , or simply start the dev server to confirm no errors
询问用户:"你是否已经在Subframe中设计好页面用于测试?"
  • :使用
    /subframe:develop
    实现页面并验证渲染效果
  • :建议用户使用
    /subframe:design
    设计页面,或直接启动开发服务器确认无错误

2. Start Dev Server

2. 启动开发服务器

bash
npm run dev
bash
npm run dev

3. Summarize

3. 总结

Recap what was set up:
  • .subframe/sync.json
    configured
  • Tailwind configured (v3 preset or v4 import)
  • Components synced to
    src/ui/
    (or configured directory)
  • Fonts configured
Mention next steps:
  • /subframe:design
    — Design new pages with AI
  • /subframe:develop
    — Implement Subframe designs in your codebase

回顾已完成的设置:
  • 已配置
    .subframe/sync.json
  • 已配置Tailwind(v3预设或v4导入)
  • 组件已同步到
    src/ui/
    (或指定目录)
  • 已配置字体
说明后续步骤:
  • /subframe:design
    — 使用AI设计新页面
  • /subframe:develop
    — 在代码库中实现Subframe设计

Important Notes

重要提示

  • Use
    SearchSubframeDocs
    MCP tool for troubleshooting any setup issues.
  • 若遇到任何设置问题,请使用
    SearchSubframeDocs
    MCP工具进行故障排除。