project-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Table of Contents

目录

Project Initialization Skill

项目初始化Skill

Interactive workflow for initializing new software projects with complete development infrastructure.
用于初始化新软件项目的交互式工作流,包含完整的开发基础设施配置。

Use When

适用场景

  • Starting a new Python, Rust, or TypeScript project
  • Updating existing project tooling to current standards
  • Need to set up git, GitHub workflows, pre-commit hooks, Makefile
  • Want consistent project structure across team
  • Converting unstructured project to best practices
  • Adding missing configurations to established codebases
  • 启动新的Python、Rust或TypeScript项目
  • 将现有项目工具更新至当前标准
  • 需要设置Git、GitHub工作流、pre-commit钩子、Makefile
  • 希望团队内保持一致的项目结构
  • 将非结构化项目转换为最佳实践规范
  • 为成熟代码库添加缺失的配置

Workflow

工作流程

1. Detect or Select Language

1. 检测或选择编程语言

Load
modules/language-detection.md
  • Auto-detect from existing files (pyproject.toml, Cargo.toml, package.json)
  • If ambiguous or empty directory, ask user to select
  • Validate language is supported (python, rust, typescript)
加载
modules/language-detection.md
  • 从现有文件自动检测(pyproject.toml、Cargo.toml、package.json)
  • 若存在歧义或目录为空,询问用户选择
  • 验证语言是否受支持(python、rust、typescript)

2. Collect Project Metadata

2. 收集项目元数据

Load
modules/metadata-collection.md
Gather:
  • Project name (default: directory name)
  • Author name and email
  • Project description
  • Language-specific settings:
    • Python: version (default 3.10)
    • Rust: edition (default 2021)
    • TypeScript: framework (React, Vue, etc.)
  • License type (MIT, Apache, GPL, etc.)
加载
modules/metadata-collection.md
收集以下信息:
  • 项目名称(默认:目录名称)
  • 作者姓名和邮箱
  • 项目描述
  • 语言特定设置:
    • Python:版本(默认3.10)
    • Rust:版本(默认2021)
    • TypeScript:框架(React、Vue等)
  • 许可证类型(MIT、Apache、GPL等)

3. Review Existing Files

3. 检查现有文件

Check for existing configurations:
bash
ls -la
Verification: Run the command with
--help
flag to verify availability.
If files exist (Makefile, .gitignore, etc.):
  • Show what would be overwritten
  • Ask for confirmation or selective overwrite
  • Offer merge mode (preserve custom content)
检查现有配置:
bash
ls -la
验证: 使用
--help
标志运行命令以确认可用性。
若存在文件(Makefile、.gitignore等):
  • 展示将被覆盖的内容
  • 询问用户确认或选择部分覆盖
  • 提供合并模式(保留自定义内容)

4. Render and Apply Templates

4. 渲染并应用模板

Load
modules/template-rendering.md
Run initialization script:
bash
python3 plugins/attune/scripts/attune_init.py \
  --lang {{LANGUAGE}} \
  --name {{PROJECT_NAME}} \
  --author {{AUTHOR}} \
  --email {{EMAIL}} \
  --python-version {{PYTHON_VERSION}} \
  --description {{DESCRIPTION}} \
  --path .
Verification: Run the command with
--help
flag to verify availability.
加载
modules/template-rendering.md
运行初始化脚本:
bash
python3 plugins/attune/scripts/attune_init.py \
  --lang {{LANGUAGE}} \
  --name {{PROJECT_NAME}} \
  --author {{AUTHOR}} \
  --email {{EMAIL}} \
  --python-version {{PYTHON_VERSION}} \
  --description {{DESCRIPTION}} \
  --path .
验证: 使用
--help
标志运行命令以确认可用性。

5. Initialize Git (if needed)

5. 初始化Git(如需要)

bash
undefined
bash
undefined

Check if git is initialized

检查是否已初始化Git

if [ ! -d .git ]; then git init echo "Git repository initialized" fi
**Verification:** Run `git status` to confirm working tree state.
if [ ! -d .git ]; then git init echo "Git repository initialized" fi
**验证:** 运行`git status`确认工作区状态。

6. Verify Setup

6. 验证设置

Validate setup:
bash
undefined
验证设置是否正确:
bash
undefined

Check Makefile targets

检查Makefile目标

make help
make help

List created files

列出已创建的文件

git status
**Verification:** Run `git status` to confirm working tree state.
git status
**验证:** 运行`git status`确认工作区状态。

7. Next Steps

7. 后续步骤

Advise user to:
bash
undefined
建议用户执行:
bash
undefined

Install dependencies and hooks

安装依赖和钩子

make dev-setup
make dev-setup

Run tests to verify setup

运行测试以验证设置

make test
make test

See all available commands

查看所有可用命令

make help
**Verification:** Run `pytest -v` to verify tests pass.
make help
**验证:** 运行`pytest -v`确认测试通过。

Error Handling

错误处理

  • Language detection fails: Ask user to specify
    --lang
  • Script not found: Guide to plugin installation location
  • Permission denied: Suggest
    chmod +x
    on scripts
  • Git conflicts: Offer to stash or commit existing work
  • 语言检测失败: 询问用户指定
    --lang
    参数
  • 脚本未找到: 引导用户前往插件安装位置
  • 权限拒绝: 建议对脚本执行
    chmod +x
    操作
  • Git冲突: 提供暂存或提交现有工作的选项

Success Criteria

成功标准

  • All template files created successfully
  • No overwrites without user confirmation
  • Git repository initialized
  • make help
    shows available targets
  • make test
    runs without errors (even if no tests yet)
  • 所有模板文件创建成功
  • 未经用户确认不会覆盖任何文件
  • Git仓库已初始化
  • make help
    显示可用目标
  • make test
    可正常运行(即使暂无测试用例)

Examples

示例

Example 1: New Python Project

示例1:新建Python项目

**Verification:** Run `pytest -v` to verify tests pass.
User: /attune:project-init
**验证:** 运行`pytest -v`确认测试通过。
User: /attune:project-init

Troubleshooting

故障排除

Common Issues

常见问题

Command not found Ensure all dependencies are installed and in PATH
Permission errors Check file permissions and run with appropriate privileges
Unexpected behavior Enable verbose logging with
--verbose
flag
命令未找到 确保所有依赖已安装且在PATH中
权限错误 检查文件权限并使用适当权限运行
异常行为 使用
--verbose
标志启用详细日志
undefined