Skip to main content

moai init 初始化

更新 2026-10-04 2 分钟阅读 在 GitHub 上编辑 ↗

moai init 在当前目录或新文件夹中初始化 MoAI 项目。它会部署 Claude Code 集成所需的 .claude/、.moai/ 结构与配置,并在需要时通过交互式向导设置项目模式、语言与质量门禁。

用法

bash
moai init [project-name]
模式行为
moai init <name>创建 ./<name>/ 文件夹并在其中初始化
moai init .在当前目录初始化
moai init在当前目录初始化(等同于 moai init .)

最多接受 1 个参数。

主要标志

部署范围

标志说明
--all完整本地部署:目录所有层级都本地安装(--no-plugin 载荷 + 可选包)。不带该标志时默认是 core-only slim 模式
--no-plugin跳过 moai 插件,部署完整本地载荷(技能、命令、.mcp.json 的 moai 条目、Codex 镜像)。MOAI_SKIP_PLUGIN_INSTALL=1 效果相同。默认路径(插件模式)不本地安装技能与命令 —— 由 moai 插件承载
--force重新初始化既有项目(会备份当前 .moai/)
--no-hooks跳过 git 钩子安装
--llm <claude|codex|both>选择要接入的 LLM harness (默认: claude)

确定的部署模式记录在 .moai/config/sections/llm.yaml 的 deployment_mode(plugin 或 local),moai update 按该记录保持同样的范围。插件安装未能得到确认的项目会记录在安全的一侧,即 local。

项目默认值

标志说明
--root <dir>项目根目录(默认:当前目录)
--name <name>项目名称(默认:目录名)
--language <lang>主编程语言
--framework <name>框架(默认:自动检测或 none)
--mode <ddd|tdd>开发方法论(默认:tdd)
--non-interactive跳过交互式向导 —— 仅使用标志与默认值

向导提问标志

标志说明
--enable-lsp启用 LSP 集成(默认:true)
--enforce-quality强制质量门禁(默认:true)
--enable-design启用设计工作流(默认:true)

Git / 模型策略

标志说明
--git-mode <manual|personal|team>Git 工作流模式(默认:manual)
--git-provider <github|gitlab>Git 提供商
--github-username <name>GitHub 用户名(personal/team 模式必填)
--profile <high|medium|low>模型+effort 配置文件 —— 保存到 llm.yaml 的 profile (选择配置矩阵列)。legacy 值 max 也接受作为输入并规范化为 high
--model-policy <high|medium|low>legacy 性能层级 —— 保存到 llm.yaml 的 performance_tier (profile 缺失时作为别名读取)

示例

bash
# 在新文件夹中初始化
moai init my-app

# 在当前目录初始化
moai init .

# 指定方法论
moai init --mode tdd

# 部署完整目录(绕过 slim 模式)
moai init --all

# 非交互式(用于 CI 等)
moai init . --non-interactive --language go

相关命令

命令说明
moai update同步已初始化项目的模板
moai status检查初始化状态
moai doctor初始化后验证环境

参考