一个面向 Claude Code 的项目启动与协作模板,重点提供:
- 可交互安装(支持新建/克隆/本地项目)
- 前端/后端技术栈初始化与依赖安装
- MCP 配置与 Playwright 基础测试配置
- 可选卸载与恢复
git clone https://github.com/dawenrenhub/claude_code_template.git
cd claude_code_template
# 安装(Linux)
bash install.sh- 新项目
- Git 克隆项目
- 本地已有项目
支持单体项目或前端子目录模式(frontend/client/web/自定义)。
会明确询问技术栈类别,不会默认创建 package.json。
前端选项
- Node.js (JavaScript)
- TypeScript
- 自定义命令
- 跳过前端
后端选项
- FastAPI / Flask / Django
- Express / NestJS
- Go (Gin)
- Rust (Axum)
- 自定义命令 / 跳过
生成基础测试配置和示例测试,适配单体/前端子目录。
- 检查 Linux 系统
- 检查并尝试安装依赖:git / jq / python3 / npx / claude / uvx
- Claude 根目录初始化(缺失则补齐):
- .claude/settings.json
- .mcp.json
- 下载/更新 ralph-claude-code
- Superpowers 检测与安装(读取 ~/.claude.json / ~/.claude/mcp.json / ~/.claude/settings.json)
- 新项目创建
- Git 克隆项目
- 本地已有项目
- 前端目录结构选择:单体或前端子目录(frontend/client/web/自定义)
- 默认端口选择
前端
- Node.js / TypeScript / 自定义 / 跳过
- Node.js:创建 package.json,并安装 Playwright
- TypeScript:创建 package.json + tsconfig.json,并安装 TypeScript 依赖与 Playwright
- 可选安装 ESLint + Prettier
- 可选选择单测框架(Vitest/Jest)
后端
- FastAPI / Flask / Django / Express / NestJS / Gin / Axum / 自定义 / 跳过
- 选择后端会创建 backend/ 并生成示例入口与依赖配置
- Python 可选 pytest/ruff/mypy/Playwright
- Node 可选 ESLint + Prettier、Vitest/Jest
- Go/Rust 可选生成测试/覆盖率入口
克隆项目模式
- 自动检测现有配置(package.json / requirements.txt / go.mod / Cargo.toml 等)
- 根据检测结果询问是否安装依赖/补齐缺失配置
- 不会默认创建 package.json
- logs
- docs
- src(可选)
- tests/unit(可选)
- tests/e2e
- playwright
- 若前端为子目录,则目录创建在对应子目录下
- .mcp.json
- playwright.config.ts
- tests/e2e/example.spec.ts
- .gitignore(追加)
- .template-manifest.json
- 可能生成:.eslintrc.json / .prettierrc / vitest.config.ts / jest.config.cjs
- 可能生成:pytest.ini / ruff.toml / mypy.ini
- 可选生成:.github/workflows/ci.yml
FastAPI
- backend/main.py
- backend/requirements.txt
Flask
- backend/app.py
- backend/requirements.txt
Django
- backend/requirements.txt
- Django 项目结构(django-admin startproject 生成)
Express
- backend/package.json
- backend/server.js
NestJS
- Nest CLI 生成的完整结构
Go (Gin)
- backend/go.mod
- backend/main.go
Rust (Axum)
- backend/Cargo.toml
- backend/src/main.rs
目录
- logs
- docs
- tests/e2e
- playwright
文件
- .mcp.json
- playwright.config.ts
- tests/e2e/example.spec.ts
- .gitignore
- .template-manifest.json
若选择后端初始化,会在 backend/ 下生成对应骨架文件和依赖配置,并记录到清单。
- init.sh:环境或流程初始化入口
- planning.sh:规划/需求整理流程
- restore.sh:恢复卸载时备份
- uninstall.sh:卸载模板生成内容(支持根目录模块与子项目循环删除)
bash uninstall.sh卸载流程支持:
- 选择是否删除根目录模块
- 循环输入子项目目录进行删除
- 可选备份与恢复
- Linux
- Node.js 18+
- Python 3.9+
- jq / npx / pipx
Include only what Claude needs:
- source folders (
frontend/,backend/,scripts/,.claude/,docs/,tests/) Exclude: - dependencies (
node_modules/,.venv/) - artifacts (
dist/,build/,.next/) - logs and datasets (
logs/,data/) - large binaries (
*.zip,*.mp4, etc.)
Allow writing only where you want changes:
.claude/**,scripts/**,docs/**, and selected code folders
Result: fewer tokens, fewer surprises, and safer autonomous operation.
- lint
- format check (optional)
- typecheck
- unit tests (subset)
- full unit tests
- integration tests
- e2e tests (Playwright/Cypress/etc.)
- build checks
Keep the default quick. Use full when merging or releasing.
Recommended Makefile targets (or justfile equivalents):
make verify-fastmake verify-fullmake lintmake typecheckmake testmake e2emake formatmake clean
This prevents “how do I run X again?” loops and makes automation reliable.
Set CI to run:
- On PR:
verify-fast - On main merge:
verify-full
Publish test reports and artifacts (especially e2e traces/screenshots) to make failures debuggable.
- Add
.env.examplefor required variables. - Put real secrets in:
- local
.env(gitignored) - CI secrets (GitHub/GitLab)
- local
- Add secret scanning in CI if possible.
- Keep lockfiles committed:
- Node:
pnpm-lock.yaml/package-lock.json - Python:
uv.lock/poetry.lock/ pinned requirements
- Node:
- Optional: add Docker for reproducible testing.
Use structured commits:
feat: ...,fix: ...,refactor: ...,test: ...,docs: ...
Keep a CHANGELOG.md so release notes are easy and history is searchable.
Add scripts like:
scripts/scaffold-module.shscripts/scaffold-endpoint.shscripts/scaffold-test.sh
Each scaffold should create:
- source file(s)
- tests
- docs snippet
- export wiring (if needed)
For autonomous debugging (especially e2e):
- standardized logs with request IDs
- store traces/screenshots on failure
- keep artifacts in CI for inspection
Add a PR template that forces:
- What / Why
- How to test
- Risk / rollback
- Screenshots/traces (if UI/e2e)
This makes agent changes reviewable and safe.
git add README.md
git commit -m "Add template README"
git branch -M main
git push -u origin main