code-setup-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSet up a project development environment with wrapper scripts and/or a Nix flake.
使用 wrapper 脚本和/或 Nix flake 搭建项目开发环境。
Parameters
参数
- location: Desired location for setup artifacts.
- "machine-local": Inside (ignored by git, good for personal tools).
.my/ - "project-local": Root level (e.g., ,
bin/).flake.nix
- "machine-local": Inside
- setup_types: What to set up ("wrapper", "flake", or "both").
If these parameters are not explicitly provided in the request, infer them from context or ask the user for clarification before proceeding.
- location:搭建产物的目标存放位置
- "machine-local":存放在 目录下(git 会忽略该目录,适合个人工具使用)
.my/ - "project-local":存放在项目根目录(例如 、
bin/)flake.nix
- "machine-local":存放在
- setup_types:需要搭建的内容(可选值为 "wrapper"、"flake" 或 "both")
如果请求中未明确提供这些参数,请先从上下文推断,或向用户确认后再继续操作。
Process
流程
For each setup type selected:
针对每个选中的搭建类型执行如下操作:
Wrapper Scripts
Wrapper 脚本
-
Determine paths based on location:
- Machine-local: with
.my/bin/prefixmy- - Project-local: , ask about naming:
bin/- Generic: ,
test,lint,fmt,builddev - Prefixed (default): , etc.
<project-name>-test
- Generic:
- Machine-local:
-
Invoke theskill to:
code-analyze-project- Detect project type
- Recommend wrappers (test, lint, fmt, build, dev commands)
-
Present recommended wrappers and ask which to create
-
Create wrapper directory if needed
-
If machine-local: Createwith content
.my/.gitignore* -
Create wrapper scripts with template:
bash
#!/usr/bin/env bash
set -euo pipefail
<command>- Make executable:
chmod +x <dir>/*
-
根据存储位置确定路径:
- 本地机器级:目录,脚本前缀为
.my/bin/my- - 项目本地级:目录,询问用户命名规则:
bin/- 通用命名:、
test、lint、fmt、builddev - 带前缀(默认):等格式
<项目名>-test
- 通用命名:
- 本地机器级:
-
调用技能,完成以下操作:
code-analyze-project- 检测项目类型
- 推荐需要的 wrapper 脚本(test、lint、fmt、build、dev 相关命令)
-
展示推荐的 wrapper 脚本列表,询问用户需要创建哪些
-
若所需目录不存在则先创建 wrapper 脚本存放目录
-
如果是本地机器级存储:创建文件,内容为
.my/.gitignore* -
按照如下模板创建 wrapper 脚本:
bash
#!/usr/bin/env bash
set -euo pipefail
<command>- 赋予脚本可执行权限:
chmod +x <dir>/*
Nix Flake
Nix Flake
-
Determine path based on location:
- Machine-local:
.my/flake.nix - Project-local:
flake.nix
- Machine-local:
-
Check for existing flake at the determined path
-
Detect project type and required packages:
- Node.js: package.json → nodejs, npm/pnpm/yarn
- Python: pyproject.toml, setup.py → python3, pip/poetry/uv
- Go: go.mod → go, gopls
- Rust: Cargo.toml → cargo, rustc
- Ruby: Gemfile → ruby, bundler
- Other: check for Makefile, CMakeLists.txt, etc.
-
Generate flake using the template in templates/flake.nix
- Use (not
buildInputs) for dependenciespackages - No shellHook unless absolutely necessary
- Keep it simple and minimal
- If updating existing flake, preserve custom inputs/outputs but simplify structure
- Use
-
If machine-local: Createwith content
.my/.gitignoreif not exists* -
Verify the flake:
nix flake check path:.
- If verification fails, fix issues and re-verify
-
根据存储位置确定路径:
- 本地机器级:
.my/flake.nix - 项目本地级:
flake.nix
- 本地机器级:
-
检查确定的路径下是否已存在 flake 文件
-
检测项目类型和所需依赖包:
- Node.js:存在 package.json → 依赖 nodejs、npm/pnpm/yarn
- Python:存在 pyproject.toml、setup.py → 依赖 python3、pip/poetry/uv
- Go:存在 go.mod → 依赖 go、gopls
- Rust:存在 Cargo.toml → 依赖 cargo、rustc
- Ruby:存在 Gemfile → 依赖 ruby、bundler
- 其他:检查是否存在 Makefile、CMakeLists.txt 等文件
-
使用 templates/flake.nix 中的模板生成 flake 文件
- 依赖项放入 (不要放在
buildInputs中)packages - 除非绝对必要,否则不要添加 shellHook
- 保持配置简洁最小化
- 如果是更新已有 flake,保留自定义的 inputs/outputs,但简化整体结构
- 依赖项放入
-
如果是本地机器级存储:若不存在则创建,内容为
.my/.gitignore* -
验证 flake 配置:
nix flake check path:.
- 如果验证失败,修复问题后重新验证
Output
输出
- Project type detected
- Wrapper/flake location created
- Scripts/flake created (with descriptions)
- How to use
- 检测到的项目类型
- 创建的 wrapper/flake 存放位置
- 已创建的脚本/flake 文件(附带说明)
- 使用说明