init-repo
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInitializing 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 at each decision point to gather user preferences. Do NOT skip steps or assume defaults without asking.
AskUserQuestion调用时请按顺序遵循以下工作流。每个决策节点都要使用收集用户偏好,未询问前不得跳过步骤或假设默认值。
AskUserQuestionWorkflow
工作流
Step 0: Detect Environment
步骤 0:检测环境
Before anything else, check the current directory's state:
- Run to see if the CWD is already inside a git repository (even if it has zero commits or is otherwise empty).
git rev-parse --is-inside-work-tree - Run to check if the directory has any files/folders at all.
ls -A - If it IS a git repo, note this — we will NOT run later. Also run
git initto detect the current default branch name and store it asgit symbolic-ref --short HEAD.{DEFAULT_BRANCH} - If it is NOT a git repo, note this — we may need to initialize one later. will be determined in Step 8.
{DEFAULT_BRANCH}
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?
- Here — use the current directory (
){CWD}- New subdirectory — create a new folder inside the current directory
If the user picks "New subdirectory", ask for the folder name, create it, and into it.
All subsequent operations MUST happen in the chosen directory — never in a parent or sibling directory.
cd在执行任何操作前,先检查当前目录的状态:
- 运行确认当前工作目录是否已经是一个git仓库(即便没有任何提交或者为空仓库)。
git rev-parse --is-inside-work-tree - 运行检查目录下是否存在任何文件/文件夹。
ls -A - 如果已经是git仓库,做好记录——后续不会再执行。同时运行
git init检测当前默认分支名,存储为git symbolic-ref --short HEAD。{DEFAULT_BRANCH} - 如果不是git仓库,做好记录——后续可能需要初始化仓库。将在步骤8中确定。
{DEFAULT_BRANCH}
告知用户检测结果:
- 当前目录是否为git仓库
- 目录为空还是存在已有文件
然后明确询问:
您想要在哪里设置项目?
- 当前目录 —— 使用现有目录(
){CWD}- 新建子目录 —— 在当前目录下创建新文件夹
如果用户选择“新建子目录”,询问文件夹名称,创建后进入该目录。所有后续操作都必须在选中的目录中执行,不得在父目录或同级目录操作。
cdStep 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?
- Full project — scaffold code, tooling, and ops (runtime, package manager, formatter, linter, CI, license, precommits, CLAUDE.md)
- 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.
询问用户想要的脚手架配置层级:
您想要设置哪些内容?
- 完整项目 —— 搭建代码、工具链和运维配置(运行时、包管理器、格式化工具、 lint工具、CI、许可证、precommits、CLAUDE.md)
- 仅运维配置 —— 仅设置运维工具链(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:
| Option | When 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 |
| Python | Data, ML/AI, scripting, automation |
| Rust | Performance-critical, systems, CLI tools |
| Go | Infrastructure, 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 with strict mode
tsconfig.json
TypeScript (Node.js):
- Ask: npm, yarn, or pnpm? (Recommend pnpm)
- Run the appropriate init command
- Create with strict mode
tsconfig.json
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 to pin the toolchain and ensure all contributors have formatting/linting/editor components:
rust-toolchain.toml
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 - 创建固定工具链版本,确保所有贡献者都有格式化/lint/编辑器组件:
rust-toolchain.toml
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:
| Option | Type | Description |
|---|---|---|
| Biome (Recommended) | Formatter + Linter | Fast, unified tool, minimal config |
| ESLint + Prettier | Linter + Formatter | Most popular, huge plugin ecosystem |
| ESLint (flat config) | Linter only | If user wants linting without a formatter |
| oxlint | Linter | Extremely fast, Rust-based, drop-in ESLint alternative |
Python:
| Option | Type | Description |
|---|---|---|
| Ruff (Recommended) | Formatter + Linter | Extremely fast, replaces Black + Flake8 + isort |
| Black + Flake8 | Formatter + Linter | Established, widely adopted |
| Black + Ruff | Formatter + Linter | Black formatting with Ruff linting |
Rust:
| Option | Type | Description |
|---|---|---|
| rustfmt + Clippy (Recommended) | Formatter + Linter | Standard Rust toolchain, no extra install |
Go:
| Option | Type | Description |
|---|---|---|
| gofmt + go vet (Recommended) | Formatter + Linter | Built into Go toolchain |
| gofmt + golangci-lint | Formatter + Linter | More comprehensive linting rules |
After selection:
- Install the chosen tools as dev dependencies
- Create the appropriate config file(s) (e.g., ,
biome.json,ruff.toml,.eslintrc)rustfmt.toml - Add ,
format, andlintscripts to the project's task runner (e.g.,lint:fixscripts,package.json,Makefile)Justfile
询问用户要使用的格式化工具和lint工具,根据选中的运行时提供选项。用户可以选择分开的格式化和lint工具,也可以选择同时支持两者的统一工具。
TypeScript / JavaScript:
| 选项 | 类型 | 说明 |
|---|---|---|
| Biome (推荐) | 格式化 + Lint | 速度快的统一工具,配置极少 |
| ESLint + Prettier | Lint + 格式化 | 最流行的方案,插件生态极丰富 |
| ESLint (flat config) | 仅Lint | 用户只需要lint不需要格式化的场景 |
| oxlint | Lint | 基于Rust开发速度极快,可直接替换ESLint |
Python:
| 选项 | 类型 | 说明 |
|---|---|---|
| Ruff (推荐) | 格式化 + Lint | 速度极快,可替代Black + Flake8 + isort |
| Black + Flake8 | 格式化 + Lint | 成熟方案,应用广泛 |
| Black + Ruff | 格式化 + Lint | Black格式化 + Ruff linting |
Rust:
| 选项 | 类型 | 说明 |
|---|---|---|
| rustfmt + Clippy (推荐) | 格式化 + Lint | Rust标准工具链组件,无需额外安装 |
Go:
| 选项 | 类型 | 说明 |
|---|---|---|
| gofmt + go vet (推荐) | 格式化 + Lint | Go工具链内置 |
| gofmt + golangci-lint | 格式化 + Lint | 更全面的lint规则 |
选择完成后:
- 将选中的工具安装为开发依赖
- 创建对应的配置文件(如、
biome.json、ruff.toml、.eslintrc)rustfmt.toml - 在项目的任务运行器中添加、
format、lint脚本(如lint:fix脚本、package.json、Makefile)Justfile
Step 6: CI/CD
步骤 6:CI/CD
Ask the user what CI/CD they want. Options:
| Option | Description |
|---|---|
| GitHub Actions (Recommended) | Standard for GitHub repos |
| None | Skip CI/CD for now |
| Other | Let user specify |
If GitHub Actions is selected, create with:
.github/workflows/ci.yml- 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 and pull requests
{DEFAULT_BRANCH}
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.,, deployment keys) must be configured in the repository's Settings → Secrets and variables → Actions.GITHUB_TOKEN
询问用户想要使用的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工具)
- 测试步骤(适配的测试运行器)
- 触发条件:向推送代码和提交PR时触发
{DEFAULT_BRANCH}
注意: 工作流文件会在本地创建,用户需要将仓库推送到GitHub并验证工作流可以正常运行。所有需要的密钥(如、部署密钥)都需要在仓库的 设置 → 密钥和变量 → Actions 中配置。GITHUB_TOKEN
Step 7: Licensing
步骤 7:许可证
Ask the user which license to use. Present the common options prominently:
| Option | SPDX ID | Category | When to suggest |
|---|---|---|---|
| MIT | | Permissive | Most common open-source license |
| Apache 2.0 | | Permissive | Open source with patent protection |
| GPL 3.0 | | Copyleft | Requires derivative works stay open |
| Dual License | (see below) | Permissive | Two licenses (e.g., MIT + Apache-2.0, Rust standard) |
| Proprietary | — | — | Private/commercial projects |
| None | — | — | Skip for now |
| Other | (see below) | — | Pick from expanded list |
Permissive:
· · · · · · · · · · ·
MITMIT-0Apache-2.0BSD-2-ClauseBSD-3-ClauseBSD-3-Clause-ClearISC0BSDUnlicenseZlibCC0-1.0UPL-1.0Copyleft:
· · · · · · · · ·
GPL-2.0GPL-3.0LGPL-2.1LGPL-3.0AGPL-3.0MPL-2.0EPL-1.0EPL-2.0EUPL-1.2OSL-3.0Source-available:
BSL-1.0Other:
· · · ·
</details>CC-BY-4.0CC-BY-SA-4.0OFL-1.1MulanPSL-2.0WTFPL询问用户想要使用的许可证,优先展示常用选项:
| 选项 | SPDX ID | 分类 | 建议使用场景 |
|---|---|---|---|
| MIT | | 宽松许可 | 最常用的开源许可证 |
| Apache 2.0 | | 宽松许可 | 提供专利保护的开源许可证 |
| GPL 3.0 | | Copyleft | 要求衍生作品保持开源 |
| 双许可证 | (见下方) | 宽松许可 | 两种许可证组合(如MIT + Apache-2.0,Rust生态标准) |
| 闭源专有 | — | — | 私有/商业项目 |
| 不设置 | — | — | 暂时跳过许可证配置 |
| 其他 | (见下方) | — | 从扩展列表中选择 |
宽松许可:
· · · · · · · · · · ·
MITMIT-0Apache-2.0BSD-2-ClauseBSD-3-ClauseBSD-3-Clause-ClearISC0BSDUnlicenseZlibCC0-1.0UPL-1.0Copyleft许可:
· · · · · · · · ·
GPL-2.0GPL-3.0LGPL-2.1LGPL-3.0AGPL-3.0MPL-2.0EPL-1.0EPL-2.0EUPL-1.2OSL-3.0可获取源代码许可:
BSL-1.0其他:
· · · ·
</details>CC-BY-4.0CC-BY-SA-4.0OFL-1.1MulanPSL-2.0WTFPLFetching License Text
获取许可证文本
Fetch the license text using from this skill's vendored license templates:
WebFetchhttps://raw.githubusercontent.com/Nathan13888/nice-skills/master/data/licenses/{SPDX-ID}After reading, replace placeholder fields with actual values:
- or
<year>→ current year[year] - or
<copyright holders>→ user's name from[fullname](ask if not set)git config user.name
使用从该技能内置的许可证模板仓库获取许可证文本:
WebFetchhttps://raw.githubusercontent.com/Nathan13888/nice-skills/master/data/licenses/{SPDX-ID}获取后,将占位符替换为实际值:
- 或
<year>→ 当前年份[year] - 或
<copyright holders>→ 从[fullname]获取的用户名(如果未配置则询问用户)git config user.name
Single License
单一许可证
- Fetch the license text from the URL above
- Replace placeholders
- Write to
LICENSE
- 从上述URL获取许可证文本
- 替换占位符
- 写入文件
LICENSE
Dual License
双许可证
When the user selects Dual License:
- Ask which two licenses to combine (recommend MIT + Apache-2.0, the Rust ecosystem standard)
- Fetch both license texts in parallel via
WebFetch - Replace placeholders in both
- Create and
LICENSE-MIT(pattern:LICENSE-APACHE)LICENSE-{SHORT-NAME} - Create a root file explaining the dual licensing:
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.当用户选择双许可证时:
- 询问要组合的两个许可证(推荐MIT + Apache-2.0,Rust生态标准)
- 通过并行获取两个许可证的文本
WebFetch - 替换两个文本中的占位符
- 创建和
LICENSE-MIT文件(命名规则:LICENSE-APACHE)LICENSE-{短名称} - 在根目录创建文件说明双许可规则:
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:
- Ask the user what the default branch name should be (suggest , but accept any name such as
main). Store the answer asmaster.{DEFAULT_BRANCH} - Run to initialize with that branch name.
git init -b {DEFAULT_BRANCH} - Create (see below)
.gitignore - Create initial commit:
chore: initialize project
If a repo already exists (detected in Step 0):
- Ask the user if they want a created or updated
.gitignore - If in Ops only mode and no runtime was chosen, ask the user which template(s) to use (or offer to skip)
.gitignore - Ask the user if they want an initial commit with the scaffolded files
使用步骤0中检测的git仓库状态,不要重复检测。
如果步骤0未检测到仓库:
- 询问用户默认分支名(建议,也接受
main等自定义名称),将答案存储为master。{DEFAULT_BRANCH} - 运行以指定分支名初始化仓库。
git init -b {DEFAULT_BRANCH} - 创建(见下文)
.gitignore - 创建初始提交:
chore: initialize project
如果步骤0检测到已有仓库:
- 询问用户是否需要创建或更新
.gitignore - 如果处于仅运维配置模式且未选择运行时,询问用户要使用的模板(或提供跳过选项)
.gitignore - 询问用户是否需要为脚手架生成的文件创建初始提交
Fetching .gitignore
Templates
.gitignore获取.gitignore
模板
.gitignoreFetch the primary template for the chosen runtime using :
.gitignoreWebFetch| Runtime | Template | URL |
|---|---|---|
| TypeScript (Bun/Node) | | |
| Python | | |
| Rust | | |
| Go | | |
After fetching the primary template, ask the user if they want additional global ignores appended:
| Option | Template Name |
|---|---|
| macOS | |
| Linux | |
| Windows | |
| VSCode | |
| JetBrains | |
| Vim | |
| None | (skip) |
Global URL pattern:
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Global/{Name}.gitignoreCombine templates into a single with section headers:
.gitignoregitignore
undefined使用获取选中运行时对应的主流模板:
WebFetch.gitignore| 运行时 | 模板名 | URL |
|---|---|---|
| TypeScript (Bun/Node) | | |
| Python | | |
| Rust | | |
| Go | | |
获取主模板后,询问用户是否需要追加全局忽略规则:
| 选项 | 模板名 |
|---|---|
| macOS | |
| Linux | |
| Windows | |
| VSCode | |
| JetBrains | |
| Vim | |
| 不添加 | (跳过) |
全局模板URL规则:
https://raw.githubusercontent.com/github/gitignore/b4105e73e493bb7a20b5d7ea35efd5780ca44938/Global/{名称}.gitignore将多个模板合并为单个文件,添加分区标题:
.gitignoregitignore
undefined=== Node ===
=== Node ===
{fetched Node.gitignore content}
{获取到的Node.gitignore内容}
=== macOS ===
=== macOS ===
{fetched macOS.gitignore content}
undefined{获取到的macOS.gitignore内容}
undefinedStep 9: Git Hooks
步骤 9:Git Hooks
Ask the user if they want git hooks to enforce code quality. Options:
| Option | Description |
|---|---|
| Yes, with Lefthook (Recommended) | Universal git hooks manager; works with any language/runtime |
| Yes, with native hooks | Language-specific setup (husky, pre-commit framework, .git/hooks) |
| No | Skip git hooks |
The hooks follow this convention:
| Hook | Action |
|---|---|
| Auto-fix formatting and linting on staged files |
| Check formatting and linting (no fix) + run tests |
The rationale: fixes what it can so the developer isn't blocked; is a final gate that catches anything unfixable and runs the full test suite before code reaches the remote.
pre-commitpre-push询问用户是否需要配置git hooks来保障代码质量,选项:
| 选项 | 说明 |
|---|---|
| 是,使用Lefthook (推荐) | 通用git hooks管理器,支持所有语言/运行时 |
| 是,使用原生钩子 | 语言专属配置(husky、pre-commit框架、.git/hooks) |
| 否 | 跳过git hooks配置 |
钩子遵循以下约定:
| 钩子 | 执行逻辑 |
|---|---|
| 自动修复暂存文件的格式和lint问题 |
| 检查格式和lint问题(不修复) + 运行测试 |
设计逻辑:会尽可能自动修复问题,避免阻塞开发流程;是最终卡点,会捕获所有无法自动修复的问题,并在代码推送到远程前运行完整测试套件。
pre-commitpre-pushLefthook (universal, any runtime)
Lefthook(通用,所有运行时适用)
Lefthook is a fast, language-agnostic git hooks manager that works for any runtime.
- Install lefthook (pick the method appropriate for the project):
- npm/bun: /
npm install --save-dev lefthookbun add -d lefthook - Homebrew:
brew install lefthook - Go:
go install github.com/evilmartians/lefthook@latest - Or download a binary release from GitHub
- npm/bun:
- Create at the project root. Substitute the actual commands for the chosen runtime and formatter/linter:
lefthook.yml
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 ./...- Run to activate the hooks.
lefthook install
Lefthook是速度快、与语言无关的git hooks管理器,适用于所有运行时。
- 安装lefthook(选择适配项目的方式):
- npm/bun: /
npm install --save-dev lefthookbun add -d lefthook - Homebrew:
brew install lefthook - Go:
go install github.com/evilmartians/lefthook@latest - 或从GitHub下载二进制版本
- npm/bun:
- 在项目根目录创建,替换为选中的运行时、格式化工具/lint工具对应的命令:
lefthook.yml
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 ./...- 运行激活钩子。
lefthook install
Native hooks (language-specific)
原生钩子(语言专属)
If the user prefers native hooks instead:
TypeScript (Bun/Node.js):
- Install and
huskylint-staged - Configure in
lint-stagedto run the formatter/linter fix commands on staged files (auto-fix on commit)package.json - Initialize husky with:
- hook: runs
pre-commit(auto-fixes staged files)lint-staged - hook: runs format check, lint check, and tests
pre-push
Python:
- Install framework
pre-commit - Create with hooks that fix (e.g.,
.pre-commit-config.yaml,ruff format)ruff check --fix - Run
pre-commit install --hook-type pre-commit --hook-type pre-push - Add a stage entry (or a separate
pre-pushscript) that runs format check, lint check, and.git/hooks/pre-pushpytest
Rust:
- Create : runs
.git/hooks/pre-commit(fix) andcargo fmtcargo clippy --fix - Create : runs
.git/hooks/pre-push,cargo fmt --check, andcargo clippy -- -D warningscargo test - Make both scripts executable ()
chmod +x
Go:
- Create : runs
.git/hooks/pre-commit(fix) and appliesgofmt -w .if availablegolangci-lint run --fix - Create : runs
.git/hooks/pre-push(check),gofmt -l ., andgo vet ./...go test ./... - Make both scripts executable ()
chmod +x
如果用户更偏好原生钩子:
TypeScript (Bun/Node.js):
- 安装和
huskylint-staged - 在中配置
package.json,在暂存文件上运行格式化/lint修复命令(提交时自动修复)lint-staged - 初始化husky:
- 钩子:运行
pre-commit(自动修复暂存文件)lint-staged - 钩子:运行格式检查、lint检查和测试
pre-push
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脚本),运行格式检查、lint检查和.git/hooks/pre-pushpytest
Rust:
- 创建:运行
.git/hooks/pre-commit(修复)和cargo fmtcargo clippy --fix - 创建:运行
.git/hooks/pre-push、cargo fmt --check和cargo clippy -- -D warningscargo test - 为两个脚本添加可执行权限()
chmod +x
Go:
- 创建:运行
.git/hooks/pre-commit(修复),如果安装了golangci-lint则运行gofmt -w .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:
| Option | Description |
|---|---|
Yes, as | Gives Claude context about the project for agentic development |
**Yes, as | Creates |
| No | Skip |
If the user picks + symlink, create the file as and then run:
AGENTS.mdAGENTS.mdbash
ln -s AGENTS.md CLAUDE.mdRegardless of which option is chosen, the file content is identical — use the template below, filling in project-specific details:
markdown
undefined询问用户是否需要为项目创建智能体上下文文件,选项:
| 选项 | 说明 |
|---|---|
是,创建为 | 为Claude提供项目上下文,支持智能体开发 |
**是,创建为 | 将 |
| 否 | 跳过该步骤 |
如果用户选择** + 软链接**,将文件创建为,然后运行:
AGENTS.mdAGENTS.mdbash
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 types"}
any - 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{基于需求的简要架构说明}
undefinedStep 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 (or via the GitHub UI), then push withgh repo create.git push -u origin {DEFAULT_BRANCH}
If the project was created in the current directory, do NOT include a step — the user is already there.
cd输出所有创建内容的总结,根据选中的模式调整内容:
完整项目模式:
项目初始化完成:{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后才会运行。如果还没有创建远程仓库,先创建远程仓库(使用或GitHub页面操作),然后运行gh repo create推送代码。git push -u origin {DEFAULT_BRANCH}
如果项目是在当前目录创建的,不要添加步骤——用户已经在目标目录中。
cdGuidelines
指导原则
- Always ask before creating files — never assume preferences
- Use with concrete options, not open-ended prompts
AskUserQuestion - If a tool is not installed (e.g., ,
bun), offer to install it or suggest an alternativeuv - 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 with prompt "Return the full file content exactly as-is" to get raw template text without summarization
WebFetch - If fails for any URL, fall back to generating content from memory and inform the user
WebFetch - 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用户名,用于模块路径和许可证配置
- 使用时添加提示“Return the full file content exactly as-is”,获取原始模板文本而不做摘要
WebFetch - 如果任意URL的请求失败,降级为从内存生成内容并告知用户
WebFetch - 双许可证场景下并行获取两个许可证文本,降低延迟
undefined