init-repo

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Initializing Project

项目初始化

Scaffold a new project repository optimized for agentic development from a problem description — or just set up ops tooling (git, precommits, gitignore, licensing, etc.) for an existing or empty project.
可根据问题描述搭建专为智能体开发优化的全新项目仓库,也可为现有或空项目配置运维工具链(git、precommits、gitignore、许可证等)。

Quick Start

快速入门

When invoked, follow the workflow below sequentially. Use
AskUserQuestion
at each decision point to gather user preferences. Do NOT skip steps or assume defaults without asking.
调用时请按顺序遵循以下工作流。每个决策节点都要使用
AskUserQuestion
收集用户偏好,未询问前不得跳过步骤或假设默认值。

Workflow

工作流

Step 0: Detect Environment

步骤 0:检测环境

Before anything else, check the current directory's state:
  1. Run
    git rev-parse --is-inside-work-tree
    to see if the CWD is already inside a git repository (even if it has zero commits or is otherwise empty).
  2. Run
    ls -A
    to check if the directory has any files/folders at all.
  3. If it IS a git repo, note this — we will NOT run
    git init
    later. Also run
    git symbolic-ref --short HEAD
    to detect the current default branch name and store it as
    {DEFAULT_BRANCH}
    .
  4. If it is NOT a git repo, note this — we may need to initialize one later.
    {DEFAULT_BRANCH}
    will be determined in Step 8.
Tell the user what you detected:
  • Whether the current directory is a git repo
  • Whether it's empty or has existing files
Then ask explicitly:
Where do you want to set up the project?
  1. Here — use the current directory (
    {CWD}
    )
  2. New subdirectory — create a new folder inside the current directory
If the user picks "New subdirectory", ask for the folder name, create it, and
cd
into it. All subsequent operations MUST happen in the chosen directory — never in a parent or sibling directory.
在执行任何操作前,先检查当前目录的状态:
  1. 运行
    git rev-parse --is-inside-work-tree
    确认当前工作目录是否已经是一个git仓库(即便没有任何提交或者为空仓库)。
  2. 运行
    ls -A
    检查目录下是否存在任何文件/文件夹。
  3. 如果已经是git仓库,做好记录——后续不会再执行
    git init
    。同时运行
    git symbolic-ref --short HEAD
    检测当前默认分支名,存储为
    {DEFAULT_BRANCH}
  4. 如果不是git仓库,做好记录——后续可能需要初始化仓库。
    {DEFAULT_BRANCH}
    将在步骤8中确定。
告知用户检测结果:
  • 当前目录是否为git仓库
  • 目录为空还是存在已有文件
然后明确询问:
您想要在哪里设置项目?
  1. 当前目录 —— 使用现有目录(
    {CWD}
    )
  2. 新建子目录 —— 在当前目录下创建新文件夹
如果用户选择“新建子目录”,询问文件夹名称,创建后
cd
进入该目录。所有后续操作都必须在选中的目录中执行,不得在父目录或同级目录操作。

Step 1: Understand the Problem

步骤 1:理解需求

Read the user's problem description. If none was provided, ask:
What problem are you solving? Describe what you want to build in 1-2 sentences.
Summarize back your understanding before proceeding.
阅读用户的问题描述,如果没有提供相关内容,询问:
您正在解决什么问题?用1-2句话描述您想要构建的内容。
在继续下一步前,向用户复述您的理解进行确认。

Step 1.5: Scaffolding Mode

步骤 1.5:脚手架模式

Ask the user what level of scaffolding they want:
What would you like to set up?
  1. Full project — scaffold code, tooling, and ops (runtime, package manager, formatter, linter, CI, license, precommits, CLAUDE.md)
  2. Ops only — just set up ops tooling (git, .gitignore, license, CI, precommits, CLAUDE.md) without creating project code or installing a runtime/package manager
If the user picks Ops only, skip Steps 2–5 entirely and jump straight to Step 6 (CI/CD). The ops-only path still walks through CI, licensing, git setup, gitignore, precommits, and CLAUDE.md.
If the user picks Full project, continue with Step 2.
询问用户想要的脚手架配置层级:
您想要设置哪些内容?
  1. 完整项目 —— 搭建代码、工具链和运维配置(运行时、包管理器、格式化工具、 lint工具、CI、许可证、precommits、CLAUDE.md)
  2. 仅运维配置 —— 仅设置运维工具链(git、.gitignore、许可证、CI、precommits、CLAUDE.md),不创建项目代码或安装运行时/包管理器
如果用户选择仅运维配置,直接跳过步骤2-5,跳转至步骤6(CI/CD)。仅运维路径仍会完成CI、许可证、git设置、gitignore、precommits和CLAUDE.md的配置。
如果用户选择完整项目,继续执行步骤2。

Step 2: Project Name

步骤 2:项目名称

Suggest 2-3 kebab-case project names derived from the problem description. Ask the user to pick one or provide their own.
Naming rules:
  • Lowercase, kebab-case (
    my-project-name
    )
  • Short (1-3 words)
  • Descriptive of the solution, not the problem
根据问题描述生成2-3个kebab-case格式的项目名称建议,让用户选择一个或提供自定义名称。
命名规则:
  • 小写,kebab-case格式(如
    my-project-name
  • 简短(1-3个单词)
  • 描述解决方案而非问题本身

Step 3: Runtime & Language

步骤 3:运行时与语言

Ask the user which runtime/language to use. Present options based on what fits the problem:
OptionWhen to suggest
TypeScript (Bun)Web apps, APIs, CLI tools, full-stack; fast runtime with built-in bundler/test runner
TypeScript (Node.js)Web apps, APIs, CLI tools, full-stack; broader ecosystem compatibility
PythonData, ML/AI, scripting, automation
RustPerformance-critical, systems, CLI tools
GoInfrastructure, networking, microservices
Suggest the best fit as the first option with "(Recommended)" appended.
询问用户要使用的运行时/语言,根据适配的场景提供选项:
选项建议使用场景
TypeScript (Bun)Web应用、API、CLI工具、全栈开发;运行速度快,内置打包器/测试运行器
TypeScript (Node.js)Web应用、API、CLI工具、全栈开发;生态兼容性更广
Python数据、ML/AI、脚本编写、自动化
Rust性能敏感场景、系统开发、CLI工具
Go基础设施、网络服务、微服务
将最优选项作为第一个推荐项,标注“(推荐)”。

Step 4: Package Manager & Project Init

步骤 4:包管理器与项目初始化

Based on the chosen runtime, initialize the project:
TypeScript (Bun) (Recommended for TypeScript):
  • Run
    bun init
  • Create
    tsconfig.json
    with strict mode
TypeScript (Node.js):
  • Ask: npm, yarn, or pnpm? (Recommend pnpm)
  • Run the appropriate init command
  • Create
    tsconfig.json
    with strict mode
Python:
  • Ask: uv, poetry, or pip? (Recommend uv)
  • Run the appropriate init command
  • Set Python version (ask or default to 3.12+)
Rust:
  • Run
    cargo init
  • Create
    rust-toolchain.toml
    to pin the toolchain and ensure all contributors have formatting/linting/editor components:
toml
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy", "rust-analyzer"]
Go:
  • Ask for module path (suggest
    github.com/{user}/{project}
    )
  • Run
    go mod init
根据选中的运行时初始化项目:
TypeScript (Bun)(TypeScript推荐方案):
  • 运行
    bun init
  • 创建开启严格模式的
    tsconfig.json
TypeScript (Node.js):
  • 询问:使用npm、yarn还是pnpm?(推荐pnpm)
  • 运行对应的初始化命令
  • 创建开启严格模式的
    tsconfig.json
Python:
  • 询问:使用uv、poetry还是pip?(推荐uv)
  • 运行对应的初始化命令
  • 设置Python版本(询问用户或默认使用3.12+)
Rust:
  • 运行
    cargo init
  • 创建
    rust-toolchain.toml
    固定工具链版本,确保所有贡献者都有格式化/lint/编辑器组件:
toml
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy", "rust-analyzer"]
Go:
  • 询问模块路径(建议格式
    github.com/{user}/{project}
  • 运行
    go mod init

Step 5: Code Formatting & Linting

步骤 5:代码格式化与Lint

Ask the user which formatter and linter to use. Present options based on the chosen runtime. The user may select separate tools for formatting and linting, or a unified tool that handles both.
TypeScript / JavaScript:
OptionTypeDescription
Biome (Recommended)Formatter + LinterFast, unified tool, minimal config
ESLint + PrettierLinter + FormatterMost popular, huge plugin ecosystem
ESLint (flat config)Linter onlyIf user wants linting without a formatter
oxlintLinterExtremely fast, Rust-based, drop-in ESLint alternative
Python:
OptionTypeDescription
Ruff (Recommended)Formatter + LinterExtremely fast, replaces Black + Flake8 + isort
Black + Flake8Formatter + LinterEstablished, widely adopted
Black + RuffFormatter + LinterBlack formatting with Ruff linting
Rust:
OptionTypeDescription
rustfmt + Clippy (Recommended)Formatter + LinterStandard Rust toolchain, no extra install
Go:
OptionTypeDescription
gofmt + go vet (Recommended)Formatter + LinterBuilt into Go toolchain
gofmt + golangci-lintFormatter + LinterMore comprehensive linting rules
After selection:
  1. Install the chosen tools as dev dependencies
  2. Create the appropriate config file(s) (e.g.,
    biome.json
    ,
    ruff.toml
    ,
    .eslintrc
    ,
    rustfmt.toml
    )
  3. Add
    format
    ,
    lint
    , and
    lint:fix
    scripts to the project's task runner (e.g.,
    package.json
    scripts,
    Makefile
    ,
    Justfile
    )
询问用户要使用的格式化工具和lint工具,根据选中的运行时提供选项。用户可以选择分开的格式化和lint工具,也可以选择同时支持两者的统一工具。
TypeScript / JavaScript:
选项类型说明
Biome (推荐)格式化 + Lint速度快的统一工具,配置极少
ESLint + PrettierLint + 格式化最流行的方案,插件生态极丰富
ESLint (flat config)仅Lint用户只需要lint不需要格式化的场景
oxlintLint基于Rust开发速度极快,可直接替换ESLint
Python:
选项类型说明
Ruff (推荐)格式化 + Lint速度极快,可替代Black + Flake8 + isort
Black + Flake8格式化 + Lint成熟方案,应用广泛
Black + Ruff格式化 + LintBlack格式化 + Ruff linting
Rust:
选项类型说明
rustfmt + Clippy (推荐)格式化 + LintRust标准工具链组件,无需额外安装
Go:
选项类型说明
gofmt + go vet (推荐)格式化 + LintGo工具链内置
gofmt + golangci-lint格式化 + Lint更全面的lint规则
选择完成后:
  1. 将选中的工具安装为开发依赖
  2. 创建对应的配置文件(如
    biome.json
    ruff.toml
    .eslintrc
    rustfmt.toml
  3. 在项目的任务运行器中添加
    format
    lint
    lint:fix
    脚本(如
    package.json
    脚本、
    Makefile
    Justfile

Step 6: CI/CD

步骤 6:CI/CD

Ask the user what CI/CD they want. Options:
OptionDescription
GitHub Actions (Recommended)Standard for GitHub repos
NoneSkip CI/CD for now
OtherLet user specify
If GitHub Actions is selected, create
.github/workflows/ci.yml
with:
  • Format check step (e.g.,
    biome check
    ,
    ruff format --check
    ,
    cargo fmt --check
    )
  • Lint step (using the linter chosen in Step 5)
  • Test step (appropriate test runner)
  • Triggered on push to
    {DEFAULT_BRANCH}
    and pull requests
Note: The workflow file is created locally. The user must push the repository to GitHub and verify the workflow runs. Any required secrets (e.g.,
GITHUB_TOKEN
, deployment keys) must be configured in the repository's Settings → Secrets and variables → Actions.
询问用户想要使用的CI/CD方案,选项:
选项说明
GitHub Actions (推荐)GitHub仓库的标准方案
None暂时跳过CI/CD配置
Other让用户自定义指定
如果选择GitHub Actions,创建
.github/workflows/ci.yml
,包含以下内容:
  • 格式检查步骤(如
    biome check
    ruff format --check
    cargo fmt --check
  • Lint步骤(使用步骤5中选中的lint工具)
  • 测试步骤(适配的测试运行器)
  • 触发条件:向
    {DEFAULT_BRANCH}
    推送代码和提交PR时触发
注意: 工作流文件会在本地创建,用户需要将仓库推送到GitHub并验证工作流可以正常运行。所有需要的密钥(如
GITHUB_TOKEN
、部署密钥)都需要在仓库的 设置 → 密钥和变量 → Actions 中配置。

Step 7: Licensing

步骤 7:许可证

Ask the user which license to use. Present the common options prominently:
OptionSPDX IDCategoryWhen to suggest
MIT
MIT
PermissiveMost common open-source license
Apache 2.0
Apache-2.0
PermissiveOpen source with patent protection
GPL 3.0
GPL-3.0
CopyleftRequires derivative works stay open
Dual License(see below)PermissiveTwo licenses (e.g., MIT + Apache-2.0, Rust standard)
ProprietaryPrivate/commercial projects
NoneSkip for now
Other(see below)Pick from expanded list
<details> <summary>Expanded license list (click to show)</summary>
Permissive:
MIT
·
MIT-0
·
Apache-2.0
·
BSD-2-Clause
·
BSD-3-Clause
·
BSD-3-Clause-Clear
·
ISC
·
0BSD
·
Unlicense
·
Zlib
·
CC0-1.0
·
UPL-1.0
Copyleft:
GPL-2.0
·
GPL-3.0
·
LGPL-2.1
·
LGPL-3.0
·
AGPL-3.0
·
MPL-2.0
·
EPL-1.0
·
EPL-2.0
·
EUPL-1.2
·
OSL-3.0
Source-available:
BSL-1.0
Other:
CC-BY-4.0
·
CC-BY-SA-4.0
·
OFL-1.1
·
MulanPSL-2.0
·
WTFPL
</details>
询问用户想要使用的许可证,优先展示常用选项:
选项SPDX ID分类建议使用场景
MIT
MIT
宽松许可最常用的开源许可证
Apache 2.0
Apache-2.0
宽松许可提供专利保护的开源许可证
GPL 3.0
GPL-3.0
Copyleft要求衍生作品保持开源
双许可证(见下方)宽松许可两种许可证组合(如MIT + Apache-2.0,Rust生态标准)
闭源专有私有/商业项目
不设置暂时跳过许可证配置
其他(见下方)从扩展列表中选择
<details> <summary>扩展许可证列表(点击展开)</summary>
宽松许可:
MIT
·
MIT-0
·
Apache-2.0
·
BSD-2-Clause
·
BSD-3-Clause
·
BSD-3-Clause-Clear
·
ISC
·
0BSD
·
Unlicense
·
Zlib
·
CC0-1.0
·
UPL-1.0
Copyleft许可:
GPL-2.0
·
GPL-3.0
·
LGPL-2.1
·
LGPL-3.0
·
AGPL-3.0
·
MPL-2.0
·
EPL-1.0
·
EPL-2.0
·
EUPL-1.2
·
OSL-3.0
可获取源代码许可:
BSL-1.0
其他:
CC-BY-4.0
·
CC-BY-SA-4.0
·
OFL-1.1
·
MulanPSL-2.0
·
WTFPL
</details>

Fetching License Text

获取许可证文本

Fetch the license text using
WebFetch
from this skill's vendored license templates:
https://raw.githubusercontent.com/Nathan13888/nice-skills/master/data/licenses/{SPDX-ID}
After reading, replace placeholder fields with actual values:
  • <year>
    or
    [year]
    → current year
  • <copyright holders>
    or
    [fullname]
    → user's name from
    git config user.name
    (ask if not set)
使用
WebFetch
从该技能内置的许可证模板仓库获取许可证文本:
https://raw.githubusercontent.com/Nathan13888/nice-skills/master/data/licenses/{SPDX-ID}
获取后,将占位符替换为实际值:
  • <year>
    [year]
    → 当前年份
  • <copyright holders>
    [fullname]
    → 从
    git config user.name
    获取的用户名(如果未配置则询问用户)

Single License

单一许可证

  1. Fetch the license text from the URL above
  2. Replace placeholders
  3. Write to
    LICENSE
  1. 从上述URL获取许可证文本
  2. 替换占位符
  3. 写入
    LICENSE
    文件

Dual License

双许可证

When the user selects Dual License:
  1. Ask which two licenses to combine (recommend MIT + Apache-2.0, the Rust ecosystem standard)
  2. Fetch both license texts in parallel via
    WebFetch
  3. Replace placeholders in both
  4. Create
    LICENSE-MIT
    and
    LICENSE-APACHE
    (pattern:
    LICENSE-{SHORT-NAME}
    )
  5. Create a root
    LICENSE
    file explaining the dual licensing:
This project is licensed under either of

  * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  * MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.
当用户选择双许可证时:
  1. 询问要组合的两个许可证(推荐MIT + Apache-2.0,Rust生态标准)
  2. 通过
    WebFetch
    并行获取两个许可证的文本
  3. 替换两个文本中的占位符
  4. 创建
    LICENSE-MIT
    LICENSE-APACHE
    文件(命名规则:
    LICENSE-{短名称}
  5. 在根目录创建
    LICENSE
    文件说明双许可规则:
This project is licensed under either of

  * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  * MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Step 8: Git Setup

步骤 8:Git设置

Use the git repo status detected in Step 0 — do NOT re-run the check.
If no repo was detected in Step 0:
  1. Ask the user what the default branch name should be (suggest
    main
    , but accept any name such as
    master
    ). Store the answer as
    {DEFAULT_BRANCH}
    .
  2. Run
    git init -b {DEFAULT_BRANCH}
    to initialize with that branch name.
  3. Create
    .gitignore
    (see below)
  4. Create initial commit:
    chore: initialize project
If a repo already exists (detected in Step 0):
  1. Ask the user if they want a
    .gitignore
    created or updated
  2. If in Ops only mode and no runtime was chosen, ask the user which
    .gitignore
    template(s) to use (or offer to skip)
  3. Ask the user if they want an initial commit with the scaffolded files
使用步骤0中检测的git仓库状态,不要重复检测。
如果步骤0未检测到仓库:
  1. 询问用户默认分支名(建议
    main
    ,也接受
    master
    等自定义名称),将答案存储为
    {DEFAULT_BRANCH}
  2. 运行
    git init -b {DEFAULT_BRANCH}
    以指定分支名初始化仓库。
  3. 创建
    .gitignore
    (见下文)
  4. 创建初始提交:
    chore: initialize project
如果步骤0检测到已有仓库:
  1. 询问用户是否需要创建或更新
    .gitignore
  2. 如果处于仅运维配置模式且未选择运行时,询问用户要使用的
    .gitignore
    模板(或提供跳过选项)
  3. 询问用户是否需要为脚手架生成的文件创建初始提交

Fetching
.gitignore
Templates

获取
.gitignore
模板

Fetch the primary
.gitignore
template for the chosen runtime using
WebFetch
:
RuntimeTemplateURL
TypeScript (Bun/Node)
Node
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Node.gitignore
Python
Python
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Python.gitignore
Rust
Rust
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Rust.gitignore
Go
Go
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Go.gitignore
After fetching the primary template, ask the user if they want additional global ignores appended:
OptionTemplate Name
macOS
macOS
Linux
Linux
Windows
Windows
VSCode
VisualStudioCode
JetBrains
JetBrains
Vim
Vim
None(skip)
Global URL pattern:
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Global/{Name}.gitignore
Combine templates into a single
.gitignore
with section headers:
gitignore
undefined
使用
WebFetch
获取选中运行时对应的主流
.gitignore
模板:
运行时模板名URL
TypeScript (Bun/Node)
Node
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Node.gitignore
Python
Python
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Python.gitignore
Rust
Rust
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Rust.gitignore
Go
Go
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Go.gitignore
获取主模板后,询问用户是否需要追加全局忽略规则:
选项模板名
macOS
macOS
Linux
Linux
Windows
Windows
VSCode
VisualStudioCode
JetBrains
JetBrains
Vim
Vim
不添加(跳过)
全局模板URL规则:
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Global/{名称}.gitignore
将多个模板合并为单个
.gitignore
文件,添加分区标题:
gitignore
undefined

=== Node ===

=== Node ===

{fetched Node.gitignore content}
{获取到的Node.gitignore内容}

=== macOS ===

=== macOS ===

{fetched macOS.gitignore content}
undefined
{获取到的macOS.gitignore内容}
undefined

Step 9: Git Hooks

步骤 9:Git Hooks

Ask the user if they want git hooks to enforce code quality. Options:
OptionDescription
Yes, with Lefthook (Recommended)Universal git hooks manager; works with any language/runtime
Yes, with native hooksLanguage-specific setup (husky, pre-commit framework, .git/hooks)
NoSkip git hooks
The hooks follow this convention:
HookAction
pre-commit
Auto-fix formatting and linting on staged files
pre-push
Check formatting and linting (no fix) + run tests
The rationale:
pre-commit
fixes what it can so the developer isn't blocked;
pre-push
is a final gate that catches anything unfixable and runs the full test suite before code reaches the remote.
询问用户是否需要配置git hooks来保障代码质量,选项:
选项说明
是,使用Lefthook (推荐)通用git hooks管理器,支持所有语言/运行时
是,使用原生钩子语言专属配置(husky、pre-commit框架、.git/hooks)
跳过git hooks配置
钩子遵循以下约定:
钩子执行逻辑
pre-commit
自动修复暂存文件的格式和lint问题
pre-push
检查格式和lint问题(不修复) + 运行测试
设计逻辑:
pre-commit
会尽可能自动修复问题,避免阻塞开发流程;
pre-push
是最终卡点,会捕获所有无法自动修复的问题,并在代码推送到远程前运行完整测试套件。

Lefthook (universal, any runtime)

Lefthook(通用,所有运行时适用)

Lefthook is a fast, language-agnostic git hooks manager that works for any runtime.
  1. Install lefthook (pick the method appropriate for the project):
    • npm/bun:
      npm install --save-dev lefthook
      /
      bun add -d lefthook
    • Homebrew:
      brew install lefthook
    • Go:
      go install github.com/evilmartians/lefthook@latest
    • Or download a binary release from GitHub
  2. Create
    lefthook.yml
    at the project root. Substitute the actual commands for the chosen runtime and formatter/linter:
yaml
pre-commit:
  commands:
    format-fix:
      run: {format fix command}   # e.g. biome format --write, ruff format, cargo fmt
    lint-fix:
      run: {lint fix command}     # e.g. biome lint --fix, ruff check --fix, cargo clippy --fix

pre-push:
  commands:
    format-check:
      run: {format check command} # e.g. biome format --check, ruff format --check, cargo fmt --check
    lint-check:
      run: {lint check command}   # e.g. biome lint, ruff check, cargo clippy -- -D warnings
    test:
      run: {test command}         # e.g. bun test, pytest, cargo test, go test ./...
  1. Run
    lefthook install
    to activate the hooks.
Lefthook是速度快、与语言无关的git hooks管理器,适用于所有运行时。
  1. 安装lefthook(选择适配项目的方式):
    • npm/bun:
      npm install --save-dev lefthook
      /
      bun add -d lefthook
    • Homebrew:
      brew install lefthook
    • Go:
      go install github.com/evilmartians/lefthook@latest
    • 或从GitHub下载二进制版本
  2. 在项目根目录创建
    lefthook.yml
    ,替换为选中的运行时、格式化工具/lint工具对应的命令:
yaml
pre-commit:
  commands:
    format-fix:
      run: {format fix command}   # 例如 biome format --write, ruff format, cargo fmt
    lint-fix:
      run: {lint fix command}     # 例如 biome lint --fix, ruff check --fix, cargo clippy --fix

pre-push:
  commands:
    format-check:
      run: {format check command} # 例如 biome format --check, ruff format --check, cargo fmt --check
    lint-check:
      run: {lint check command}   # 例如 biome lint, ruff check, cargo clippy -- -D warnings
    test:
      run: {test command}         # 例如 bun test, pytest, cargo test, go test ./...
  1. 运行
    lefthook install
    激活钩子。

Native hooks (language-specific)

原生钩子(语言专属)

If the user prefers native hooks instead:
TypeScript (Bun/Node.js):
  • Install
    husky
    and
    lint-staged
  • Configure
    lint-staged
    in
    package.json
    to run the formatter/linter fix commands on staged files (auto-fix on commit)
  • Initialize husky with:
    • pre-commit
      hook: runs
      lint-staged
      (auto-fixes staged files)
    • pre-push
      hook: runs format check, lint check, and tests
Python:
  • Install
    pre-commit
    framework
  • Create
    .pre-commit-config.yaml
    with hooks that fix (e.g.,
    ruff format
    ,
    ruff check --fix
    )
  • Run
    pre-commit install --hook-type pre-commit --hook-type pre-push
  • Add a
    pre-push
    stage entry (or a separate
    .git/hooks/pre-push
    script) that runs format check, lint check, and
    pytest
Rust:
  • Create
    .git/hooks/pre-commit
    : runs
    cargo fmt
    (fix) and
    cargo clippy --fix
  • Create
    .git/hooks/pre-push
    : runs
    cargo fmt --check
    ,
    cargo clippy -- -D warnings
    , and
    cargo test
  • Make both scripts executable (
    chmod +x
    )
Go:
  • Create
    .git/hooks/pre-commit
    : runs
    gofmt -w .
    (fix) and applies
    golangci-lint run --fix
    if available
  • Create
    .git/hooks/pre-push
    : runs
    gofmt -l .
    (check),
    go vet ./...
    , and
    go test ./...
  • Make both scripts executable (
    chmod +x
    )
如果用户更偏好原生钩子:
TypeScript (Bun/Node.js):
  • 安装
    husky
    lint-staged
  • package.json
    中配置
    lint-staged
    ,在暂存文件上运行格式化/lint修复命令(提交时自动修复)
  • 初始化husky:
    • pre-commit
      钩子:运行
      lint-staged
      (自动修复暂存文件)
    • pre-push
      钩子:运行格式检查、lint检查和测试
Python:
  • 安装
    pre-commit
    框架
  • 创建
    .pre-commit-config.yaml
    ,配置修复类钩子(如
    ruff format
    ruff check --fix
  • 运行
    pre-commit install --hook-type pre-commit --hook-type pre-push
  • 添加
    pre-push
    阶段配置(或单独的
    .git/hooks/pre-push
    脚本),运行格式检查、lint检查和
    pytest
Rust:
  • 创建
    .git/hooks/pre-commit
    :运行
    cargo fmt
    (修复)和
    cargo clippy --fix
  • 创建
    .git/hooks/pre-push
    :运行
    cargo fmt --check
    cargo clippy -- -D warnings
    cargo test
  • 为两个脚本添加可执行权限(
    chmod +x
Go:
  • 创建
    .git/hooks/pre-commit
    :运行
    gofmt -w .
    (修复),如果安装了golangci-lint则运行
    golangci-lint run --fix
  • 创建
    .git/hooks/pre-push
    :运行
    gofmt -l .
    (检查)、
    go vet ./...
    go test ./...
  • 为两个脚本添加可执行权限(
    chmod +x

Step 10: CLAUDE.md

步骤 10:CLAUDE.md

Ask the user if they want an agent context file created for the project. Options:
OptionDescription
Yes, as
CLAUDE.md
Gives Claude context about the project for agentic development
**Yes, as
AGENTS.md
+ symlink ** (recommended)
Creates
AGENTS.md
as the canonical file and symlinks
CLAUDE.md → AGENTS.md
(preferred for multi-agent/tool setups)
NoSkip
If the user picks
AGENTS.md
+ symlink
, create the file as
AGENTS.md
and then run:
bash
ln -s AGENTS.md CLAUDE.md
Regardless of which option is chosen, the file content is identical — use the template below, filling in project-specific details:
markdown
undefined
询问用户是否需要为项目创建智能体上下文文件,选项:
选项说明
是,创建为
CLAUDE.md
为Claude提供项目上下文,支持智能体开发
**是,创建为
AGENTS.md
+ 软链接 ** (推荐)
AGENTS.md
作为规范文件,创建软链接
CLAUDE.md → AGENTS.md
(更适合多智能体/工具的场景)
跳过该步骤
如果用户选择**
AGENTS.md
+ 软链接**,将文件创建为
AGENTS.md
,然后运行:
bash
ln -s AGENTS.md CLAUDE.md
无论选择哪个选项,文件内容都是一致的——使用以下模板,填充项目专属信息:
markdown
undefined

{Project Name}

{项目名称}

{One-line problem description}
{一行问题描述}

Tech Stack

技术栈

  • Runtime: {runtime}
  • Language: {language}
  • Package Manager: {package manager}
  • Formatter: {formatter}
  • Linter: {linter}
  • 运行时: {runtime}
  • 语言: {language}
  • 包管理器: {package manager}
  • 格式化工具: {formatter}
  • Lint工具: {linter}

Project Structure

项目结构


{tree of created files/dirs}

{创建的文件/目录树}

Development

开发指南

Setup

环境配置

bash
{install command}
bash
{依赖安装命令}

Run

运行

bash
{run/dev command}
bash
{运行/开发命令}

Test

测试

bash
{test command}
bash
{测试命令}

Format

格式化

bash
{format command}
bash
{格式化命令}

Lint

Lint检查

bash
{lint command}
bash
{lint命令}

Lint Fix

Lint修复

bash
{lint fix command}
bash
{lint修复命令}

Conventions

开发规范

  • {Language-specific conventions, e.g., "Use strict TypeScript - no
    any
    types"}
  • Write tests for all new functionality
  • Use conventional commits (type: description)
  • Keep functions small and focused
  • {语言专属规范,例如“使用严格TypeScript - 禁止
    any
    类型”}
  • 所有新功能都要编写测试
  • 使用约定式提交(类型: 描述)
  • 保持函数精简,职责单一

Architecture

架构设计

{Brief description of intended architecture based on the problem}
undefined
{基于需求的简要架构说明}
undefined

Step 11: Summary

步骤 11:总结

Print a summary of everything that was created. Adapt the summary to the chosen mode:
Full project mode:

Project initialized: {name}
Location: {path}
Runtime: {runtime}
Package Manager: {pkg manager}
Formatter: {formatter}
Linter: {linter}
License: {license(s)}
CI/CD: {ci/cd}
Pre-commit: {yes/no}

Files created:
{list of files — if AGENTS.md + symlink was chosen, show both AGENTS.md and CLAUDE.md → AGENTS.md}

Next steps:

1. {install command}
2. Push to GitHub and verify GitHub Actions workflows run correctly
   - Configure any required secrets in Settings → Secrets and variables → Actions
3. Start building!
Ops only mode:

Ops tooling initialized
Location: {path}
License: {license(s)}
CI/CD: {ci/cd}
Pre-commit: {yes/no}

Files created:
{list of files — if AGENTS.md + symlink was chosen, show both AGENTS.md and CLAUDE.md → AGENTS.md}

Next steps:

1. Push to GitHub and verify GitHub Actions workflows run correctly
   - Configure any required secrets in Settings → Secrets and variables → Actions
2. Start building!
Reminder: GitHub Actions workflows only run once the repository is pushed to GitHub. If you haven't created the remote repository yet, do that first (
gh repo create
or via the GitHub UI), then push with
git push -u origin {DEFAULT_BRANCH}
.
If the project was created in the current directory, do NOT include a
cd
step — the user is already there.
输出所有创建内容的总结,根据选中的模式调整内容:
完整项目模式:
项目初始化完成:{name}
存储路径:{path}
运行时:{runtime}
包管理器:{pkg manager}
格式化工具:{formatter}
Lint工具:{linter}
许可证:{license(s)}
CI/CD:{ci/cd}
Pre-commit:{yes/no}

创建的文件:
{文件列表 —— 如果选择了AGENTS.md + 软链接,同时展示AGENTS.md和CLAUDE.md → AGENTS.md}

下一步操作:

1. {安装命令}
2. 推送到GitHub,验证GitHub Actions工作流正常运行
   - 在设置 → 密钥和变量 → Actions中配置所需的所有密钥
3. 开始开发!
仅运维配置模式:
运维工具链初始化完成
存储路径:{path}
许可证:{license(s)}
CI/CD:{ci/cd}
Pre-commit:{yes/no}

创建的文件:
{文件列表 —— 如果选择了AGENTS.md + 软链接,同时展示AGENTS.md和CLAUDE.md → AGENTS.md}

下一步操作:

1. 推送到GitHub,验证GitHub Actions工作流正常运行
   - 在设置 → 密钥和变量 → Actions中配置所需的所有密钥
2. 开始开发!
提醒: GitHub Actions工作流只有在仓库推送到GitHub后才会运行。如果还没有创建远程仓库,先创建远程仓库(使用
gh repo create
或GitHub页面操作),然后运行
git push -u origin {DEFAULT_BRANCH}
推送代码。
如果项目是在当前目录创建的,不要添加
cd
步骤——用户已经在目标目录中。

Guidelines

指导原则

  • Always ask before creating files — never assume preferences
  • Use
    AskUserQuestion
    with concrete options, not open-ended prompts
  • If a tool is not installed (e.g.,
    bun
    ,
    uv
    ), offer to install it or suggest an alternative
  • All files MUST be created in the chosen project directory (CWD or the user's subdirectory choice from Step 0) — never in a parent, sibling, or unrelated directory
  • Check if the target directory already exists before creating anything
  • Keep the initial project minimal — don't over-scaffold
  • Respect the user's choice to skip code scaffolding — ops-only mode is a first-class path, not a fallback
  • The CLAUDE.md should be practical and specific, not boilerplate
  • Detect git user.name and user.email from git config for license attribution
  • If the user provides a GitHub username, use it for module paths and license
  • Use
    WebFetch
    with prompt "Return the full file content exactly as-is" to get raw template text without summarization
  • If
    WebFetch
    fails for any URL, fall back to generating content from memory and inform the user
  • For dual-license, fetch both license texts in parallel to minimize latency
undefined
  • 创建文件前必须询问用户,永远不要假设用户偏好
  • 使用
    AskUserQuestion
    提供具体选项,不要使用开放式提问
  • 如果工具未安装(如
    bun
    uv
    ),主动提供安装选项或建议替代方案
  • 所有文件必须创建在选中的项目目录(步骤0中用户选择的当前目录或子目录)中——绝对不能在父目录、同级目录或无关目录创建文件
  • 创建任何内容前先检查目标目录是否已存在
  • 保持初始项目精简,不要过度搭建脚手架
  • 尊重用户跳过代码脚手架的选择——仅运维模式是一等路径,不是降级方案
  • CLAUDE.md内容要实用具体,不要用通用模板
  • 从git配置中读取git user.name和user.email用于许可证归属
  • 如果用户提供了GitHub用户名,用于模块路径和许可证配置
  • 使用
    WebFetch
    时添加提示“Return the full file content exactly as-is”,获取原始模板文本而不做摘要
  • 如果任意URL的
    WebFetch
    请求失败,降级为从内存生成内容并告知用户
  • 双许可证场景下并行获取两个许可证文本,降低延迟
undefined