secondbrain-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecondbrain Project Scaffolding
Secondbrain项目搭建
Scaffold a complete knowledge management system with microdatabases, VitePress portal, and Claude automation.
使用微数据库、VitePress门户和Claude自动化搭建完整的知识管理系统。
Overview
概述
Initialize a new secondbrain project with:
- Microdatabase architecture (YAML + JSON Schema validation)
- VitePress documentation portal (custom theme, Vue components)
- Configurable entity types (ADRs, Discussions, Notes, Tasks, Custom)
- Claude automation (hooks, maximum freedom settings)
初始化新的secondbrain项目,包含:
- 微数据库架构(YAML + JSON Schema验证)
- VitePress文档门户(自定义主题、Vue组件)
- 可配置实体类型(ADRs、Discussions、Notes、Tasks、自定义)
- Claude自动化(钩子、最大自由度设置)
Workflow
工作流程
Step 1: Gather Project Information
步骤1:收集项目信息
Ask the user for:
- Project name (kebab-case, e.g., )
my-knowledge-base - Target directory (default: )
./<project-name> - Use case (optional context for customization):
- Personal knowledge base
- Project documentation
- Team collaboration
向用户询问以下信息:
- 项目名称(短横线命名,例如 )
my-knowledge-base - 目标目录(默认:)
./<project-name> - 使用场景(可选,用于自定义的上下文):
- 个人知识库
- 项目文档
- 团队协作
Step 2: Select Entity Types
步骤2:选择实体类型
Present entity selection with checkboxes:
undefined展示带复选框的实体选择界面:
undefinedEntity Selection
实体选择
Which entities would you like to enable?
[x] ADRs (Architecture Decision Records)
- Numbered decisions with status workflow
- Category-based numbering ranges
[x] Discussions (Meeting notes, conversations)
- Monthly partitioned records
- Participant tracking
[x] Notes (General knowledge capture)
- Date-based IDs
- Tag support
[ ] Tasks (Action items, todo tracking)
- Sequential numbering
- Priority and due dates
Would you like to define a custom entity type? (y/n)
undefined你想要启用哪些实体?
[x] ADRs(架构决策记录)
- 带状态流程的编号决策
- 基于分类的编号范围
[x] Discussions(会议记录、对话内容)
- 按月份分区的记录
- 参与者追踪
[x] Notes(通用知识捕获)
- 基于日期的ID
- 标签支持
[ ] Tasks(行动项、待办事项追踪)
- 连续编号
- 优先级与截止日期
是否想要定义自定义实体类型?(y/n)
undefinedStep 3: Configure Semantic Search
步骤3:配置语义搜索
Present search configuration options:
undefined展示搜索配置选项:
undefinedSearch Configuration
搜索配置
Which semantic search would you like to enable?
[ ] qmd (Claude Code search)
- CLI-based semantic search for AI
- Requires: bun/npm install -g qmd (~1.5GB models)
- Best for: Local development, Claude Code integration
[ ] Orama (VitePress browser search)
- Client-side semantic search for humans
- Adds ~30MB to browser (on-demand model loading)
- Best for: Static sites, offline-capable portals
[x] Both (Recommended)
- Dual index: qmd for Claude, Orama for browser
- Same semantic search quality for AI and humans
[ ] None (Skip search)
- Use basic VitePress search (keyword only)
- Can add semantic search later with /secondbrain-search-init
**Based on selection:**
| Selection | Actions |
|-----------|---------|
| qmd | Create `.claude/search/`, generate `qmd.config.json`, add search hook |
| Orama | Add Orama deps to `package.json`, generate `SearchBox.vue`, generate build script |
| Both | All of the above |
| None | Skip search setup, use VitePress native search |你想要启用哪种语义搜索?
[ ] qmd(Claude Code搜索)
- 基于CLI的AI语义搜索
- 依赖:bun/npm install -g qmd(约1.5GB模型)
- 最适合:本地开发、Claude Code集成
[ ] Orama(VitePress浏览器搜索)
- 面向用户的客户端语义搜索
- 浏览器端增加约30MB(按需加载模型)
- 最适合:静态站点、离线可用门户
[x] 两者都启用(推荐)
- 双索引:qmd用于Claude,Orama用于浏览器
- AI与用户使用相同质量的语义搜索
[ ] 都不启用(跳过搜索)
- 使用基础VitePress搜索(仅关键词)
- 后续可通过/secondbrain-search-init启用语义搜索
**根据选择执行以下操作:**
| 选择 | 操作 |
|-----------|---------|
| qmd | 创建`.claude/search/`,生成`qmd.config.json`,添加搜索钩子 |
| Orama | 向`package.json`添加Orama依赖,生成`SearchBox.vue`,生成构建脚本 |
| 两者都启用 | 执行以上所有操作 |
| 都不启用 | 跳过搜索设置,使用VitePress原生搜索 |Step 5: Configure Maximum Freedom Settings
步骤5:配置最大自由度设置
CRITICAL: Always propose creating with maximum permissions:
.claude/settings.local.jsonjson
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"_comment": "Secondbrain project - maximum freedom for knowledge management",
"permissions": {
"allow_web_search": true,
"allow_web_fetch": ["*"],
"allow_read": ["~/**", "/tmp/**"],
"allow_bash": ["*"],
"auto_approve_write": ["<project_path>/docs/**"]
}
}Show the settings and ask for confirmation before proceeding.
重要:始终建议创建拥有最高权限的:
.claude/settings.local.jsonjson
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"_comment": "Secondbrain project - maximum freedom for knowledge management",
"permissions": {
"allow_web_search": true,
"allow_web_fetch": ["*"],
"allow_read": ["~/**", "/tmp/**"],
"allow_bash": ["*"],
"auto_approve_write": ["<project_path>/docs/**"]
}
}展示该配置并在继续前请求用户确认。
Step 6: Generate Scaffolding
步骤6:生成项目骨架
Create the following structure:
<project-name>/
├── .claude/
│ ├── settings.local.json # Max freedom permissions + hooks
│ ├── data/
│ │ ├── config.yaml # Project configuration
│ │ ├── adrs/ # (if enabled)
│ │ │ ├── schema.yaml
│ │ │ └── records.yaml
│ │ ├── discussions/ # (if enabled)
│ │ │ ├── schema.yaml
│ │ │ └── YYYY-MM.yaml # Current month
│ │ ├── notes/ # (if enabled)
│ │ │ ├── schema.yaml
│ │ │ └── records.yaml
│ │ └── tasks/ # (if enabled)
│ │ ├── schema.yaml
│ │ └── records.yaml
│ ├── lib/
│ │ └── tracking.py # CRUD library with validation
│ ├── hooks/
│ │ ├── freshness-check.py
│ │ ├── sidebar-check.py
│ │ ├── session-context.py
│ │ └── search-index-update.py # (if qmd enabled)
│ └── search/ # (if qmd enabled)
│ └── (qmd index files)
├── docs/
│ ├── .vitepress/
│ │ ├── config.ts # Navigation, sidebar, plugins
│ │ ├── theme/
│ │ │ ├── index.ts
│ │ │ ├── Layout.vue # Giscus comments
│ │ │ ├── custom.css
│ │ │ └── components/
│ │ │ ├── EntityTable.vue
│ │ │ └── SearchBox.vue # (if Orama enabled)
│ │ └── data/
│ │ └── <entity>.data.ts # Per enabled entity
│ ├── index.md # Home page
│ ├── adrs/ # (if enabled)
│ │ ├── index.md
│ │ └── TEMPLATE.md
│ ├── discussions/ # (if enabled)
│ │ ├── index.md
│ │ └── TEMPLATE.md
│ ├── notes/ # (if enabled)
│ │ └── index.md
│ └── tasks/ # (if enabled)
│ └── index.md
├── package.json # VitePress dependencies
├── qmd.config.json # (if qmd enabled)
├── CLAUDE.md # Project instructions
└── .gitignore创建以下目录结构:
<project-name>/
├── .claude/
│ ├── settings.local.json # 最高权限设置 + 钩子
│ ├── data/
│ │ ├── config.yaml # 项目配置
│ │ ├── adrs/ # (若启用)
│ │ │ ├── schema.yaml
│ │ │ └── records.yaml
│ │ ├── discussions/ # (若启用)
│ │ │ ├── schema.yaml
│ │ │ └── YYYY-MM.yaml # 当前月份
│ │ ├── notes/ # (若启用)
│ │ │ ├── schema.yaml
│ │ │ └── records.yaml
│ │ └── tasks/ # (若启用)
│ │ ├── schema.yaml
│ │ └── records.yaml
│ ├── lib/
│ │ └── tracking.py # 带验证的CRUD库
│ ├── hooks/
│ │ ├── freshness-check.py
│ │ ├── sidebar-check.py
│ │ ├── session-context.py
│ │ └── search-index-update.py # (若qmd启用)
│ └── search/ # (若qmd启用)
│ └── (qmd索引文件)
├── docs/
│ ├── .vitepress/
│ │ ├── config.ts # 导航、侧边栏、插件
│ │ ├── theme/
│ │ │ ├── index.ts
│ │ │ ├── Layout.vue # Giscus评论
│ │ │ ├── custom.css
│ │ │ └── components/
│ │ │ ├── EntityTable.vue
│ │ │ └── SearchBox.vue # (若Orama启用)
│ │ └── data/
│ │ └── <entity>.data.ts # 每个启用的实体对应文件
│ ├── index.md # 首页
│ ├── adrs/ # (若启用)
│ │ ├── index.md
│ │ └── TEMPLATE.md
│ ├── discussions/ # (若启用)
│ │ ├── index.md
│ │ └── TEMPLATE.md
│ ├── notes/ # (若启用)
│ │ └── index.md
│ └── tasks/ # (若启用)
│ └── index.md
├── package.json # VitePress依赖
├── qmd.config.json # (若qmd启用)
├── CLAUDE.md # 项目说明文档
└── .gitignoreStep 7: Generate Files
步骤7:生成文件
For each enabled entity, generate from templates in :
${CLAUDE_PLUGIN_ROOT}/templates/-
Microdatabase files:
- from
config.yamlscaffolding/microdatabase/config.yaml.tmpl - Entity from
schema.yamlentities/<entity>/schema.yaml - Entity initialized empty
records.yaml
-
VitePress files:
- from
config.tsscaffolding/vitepress/config.ts.tmpl - Theme files from
scaffolding/vitepress/theme/ - Data loaders from
scaffolding/vitepress/data/
-
Documentation:
- Home page from
scaffolding/docs/index.md.tmpl - Entity index pages from
scaffolding/docs/entity-index.md.tmpl - Templates from
entities/<entity>/TEMPLATE.md
- Home page from
-
Automation:
- from
settings.local.jsonscaffolding/claude/settings.local.json.tmpl - from
tracking.pyscaffolding/lib/tracking.py.tmpl - Hooks from (copy to project)
hooks/
-
Search (if enabled):
- qmd: from
qmd.config.jsonscaffolding/search/qmd.config.json.tmpl - qmd: Copy hook
search-index-update.py - Orama: from
SearchBox.vuescaffolding/vitepress/theme/components/SearchBox.vue.tmpl - Orama: from
build-search-index.tsscaffolding/vitepress/search/build-search-index.ts.tmpl - Orama: Add dependencies to
package.json
- qmd:
对于每个启用的实体,从中的模板生成:
${CLAUDE_PLUGIN_ROOT}/templates/-
微数据库文件:
- 来自
config.yamlscaffolding/microdatabase/config.yaml.tmpl - 实体来自
schema.yamlentities/<entity>/schema.yaml - 实体初始化为空
records.yaml
-
VitePress文件:
- 来自
config.tsscaffolding/vitepress/config.ts.tmpl - 主题文件来自
scaffolding/vitepress/theme/ - 数据加载器来自
scaffolding/vitepress/data/
-
文档:
- 首页来自
scaffolding/docs/index.md.tmpl - 实体索引页来自
scaffolding/docs/entity-index.md.tmpl - 模板来自
entities/<entity>/TEMPLATE.md
- 首页来自
-
自动化文件:
- 来自
settings.local.jsonscaffolding/claude/settings.local.json.tmpl - 来自
tracking.pyscaffolding/lib/tracking.py.tmpl - 钩子文件来自 (复制到项目中)
hooks/
-
搜索文件(若启用):
- qmd: 来自
qmd.config.jsonscaffolding/search/qmd.config.json.tmpl - qmd: 复制钩子
search-index-update.py - Orama: 来自
SearchBox.vuescaffolding/vitepress/theme/components/SearchBox.vue.tmpl - Orama: 来自
build-search-index.tsscaffolding/vitepress/search/build-search-index.ts.tmpl - Orama: 向添加依赖
package.json
- qmd:
Step 8: Show Summary
步骤8:展示总结
undefinedundefinedSecondbrain Created Successfully!
Secondbrain创建成功!
Project: my-knowledge-base
Location: /path/to/my-knowledge-base
Entities: ADRs, Discussions, Notes
项目: my-knowledge-base
位置: /path/to/my-knowledge-base
实体: ADRs、Discussions、Notes
Structure Created
已创建的结构
.claude/
├── settings.local.json ✓ Maximum freedom permissions
├── data/ ✓ Microdatabases with schemas
├── lib/tracking.py ✓ CRUD operations
└── hooks/ ✓ Automation hooks
docs/
├── .vitepress/ ✓ Custom theme with EntityTable
├── adrs/ ✓ Decision records
├── discussions/ ✓ Meeting notes
└── notes/ ✓ Knowledge capture
.claude/
├── settings.local.json ✓ 最高权限设置
├── data/ ✓ 带Schema的微数据库
├── lib/tracking.py ✓ CRUD操作
└── hooks/ ✓ 自动化钩子
docs/
├── .vitepress/ ✓ 带EntityTable的自定义主题
├── adrs/ ✓ 决策记录
├── discussions/ ✓ 会议记录
└── notes/ ✓ 知识捕获
Next Steps
下一步操作
-
Navigate to project: cd my-knowledge-base
-
Install dependencies: npm install
-
Start development server: npm run docs:dev
-
Create your first decision: /secondbrain-adr infrastructure my-first-decision
-
Add a note: /secondbrain-note my-first-note
-
进入项目目录: cd my-knowledge-base
-
安装依赖: npm install
-
启动开发服务器: npm run docs:dev
-
创建你的第一条决策: /secondbrain-adr infrastructure my-first-decision
-
添加一条笔记: /secondbrain-note my-first-note
Available Commands
可用命令
- /secondbrain-search <query> — Semantic search (if enabled)
- /secondbrain-adr <category> <title> — Create ADR
- /secondbrain-note <title> — Create note
- /secondbrain-discussion <who> <topic> — Document discussion
- /secondbrain-freshness — Check what needs attention
- /secondbrain-entity <name> — Add custom entity type
- /secondbrain-search-init — Enable semantic search later
undefined- /secondbrain-search <query> — 语义搜索(若启用)
- /secondbrain-adr <category> <title> — 创建ADR
- /secondbrain-note <title> — 创建笔记
- /secondbrain-discussion <who> <topic> — 记录讨论内容
- /secondbrain-freshness — 检查需要关注的内容
- /secondbrain-entity <name> — 添加自定义实体类型
- /secondbrain-search-init — 后续启用语义搜索
undefinedTemplate Variables
模板变量
When generating files, replace these variables:
| Variable | Description |
|---|---|
| Project name (kebab-case) |
| Absolute path to project |
| Project description |
| Current date (YYYY-MM-DD) |
| Current ISO timestamp |
| Current year-month (YYYY-MM) |
| Array of enabled entity configs |
生成文件时,替换以下变量:
| 变量 | 描述 |
|---|---|
| 项目名称(短横线命名) |
| 项目绝对路径 |
| 项目描述 |
| 当前日期(YYYY-MM-DD) |
| 当前ISO时间戳 |
| 当前年月(YYYY-MM) |
| 已启用实体配置的数组 |
Entity Configuration
实体配置
Each entity has standard configuration:
yaml
<entity_slug>:
enabled: true
label: "Entity Label"
singular: "Entity"
doc_path: docs/<entity_slug>
freshness:
stale_after_days: 30每个实体都有标准配置:
yaml
<entity_slug>:
enabled: true
label: "实体标签"
singular: "实体"
doc_path: docs/<entity_slug>
freshness:
stale_after_days: 30Additional Resources
额外资源
Reference Files
参考文件
For detailed entity schemas and templates:
- — Predefined entity schema definitions
references/entity-schemas.md
如需详细的实体Schema和模板:
- — 预定义的实体Schema定义
references/entity-schemas.md
Related Skills
相关Skill
- secondbrain-search — Semantic search your knowledge base
- secondbrain-search-init — Enable search on existing project
- secondbrain-entity — Add custom entity types
- secondbrain-adr — Create Architecture Decision Records
- secondbrain-note — Create notes
- secondbrain-task — Create tasks
- secondbrain-discussion — Document discussions
- secondbrain-freshness — Freshness report
- secondbrain-search — 语义搜索你的知识库
- secondbrain-search-init — 在现有项目中启用搜索
- secondbrain-entity — 添加自定义实体类型
- secondbrain-adr — 创建架构决策记录
- secondbrain-note — 创建笔记
- secondbrain-task — 创建任务
- secondbrain-discussion — 记录讨论内容
- secondbrain-freshness — 新鲜度报告