跳转到内容

骨架项目工作流

用经过实战验证的现有仓库作为脚手架来启动新项目,而不是从零开始。这套工作流帮助你快速搭建项目基础,同时保留成熟的架构模式和最佳实践。


启动新项目

技术栈已确定,需要快速搭建项目骨架。

团队模式标准化

在多个微服务之间统一架构模式和代码规范。

快速原型开发

架构决策已完成,需要尽快进入业务开发。

新人引导

为新成员提供可运行的参考项目,加速上手。


  • Claude Code 已安装并配置完成
  • 具有参考仓库的 Git 访问权限
  • 对目标项目的需求有清晰的理解

不要从零开始。先找到一个与目标架构匹配的现有仓库。

  1. 搜索候选仓库

    Terminal window
    # 让 Claude 帮你搜索参考仓库
    claude -p "I need a skeleton for a Next.js 15 app with:
    - App Router
    - Prisma ORM with PostgreSQL
    - tRPC for type-safe API
    - Tailwind CSS
    - Jest + Playwright testing
    Search GitHub for well-maintained starter templates.
    Evaluate the top 3 by: last commit date, stars, dependency freshness, test coverage."
  2. 克隆并审计

    Terminal window
    git clone <candidate-repo> skeleton-eval
    cd skeleton-eval
    claude

    然后在 Claude 中执行审计:

    Audit this repository as a potential skeleton for our project:
    1. List all dependencies and their versions (flag outdated ones)
    2. Assess code quality: patterns, consistency, test coverage
    3. Identify what we'd keep vs. what we'd remove
    4. Flag any security concerns (vulnerable deps, exposed secrets)
    5. Rate overall suitability (1-5) with specific justification
  3. 多角度评估(可选,用于深度分析)

    Run a multi-perspective evaluation of this skeleton:
    Agent 1 (Security): Check for vulnerabilities, hardcoded secrets, unsafe patterns
    Agent 2 (Architecture): Assess modularity, separation of concerns, scalability
    Agent 3 (DX): Evaluate developer experience - setup time, documentation, tooling
    Synthesize findings into a go/no-go recommendation.
  1. 从骨架创建项目

    Terminal window
    mkdir my-project
    cp -r skeleton-eval/. my-project/
    cd my-project
    rm -rf .git
    git init
  2. 用 Claude 精简和适配

    Customize this skeleton for our project "Acme Dashboard":
    1. Remove: example routes, demo data, sample tests
    2. Keep: config structure, auth setup, database schema pattern, CI pipeline
    3. Update: package.json (name, description, version 0.1.0)
    4. Add: our CLAUDE.md with project conventions
    5. Verify: pnpm install && pnpm build && pnpm test all pass after changes
    Important: Don't break the working skeleton. Each removal should be followed
    by a build check.
  1. 构建第一个真实功能

    Using the patterns established in this skeleton, implement our first feature:
    User Authentication (login + registration + password reset)
    Follow the skeleton's existing patterns for:
    - Route structure (match the example routes pattern)
    - Service layer (match the existing service pattern)
    - Test structure (match the example test pattern)
    - Error handling (match the existing error pattern)
    Create a task plan before starting implementation.
  2. 验证骨架完整性

    Now that we have one real feature, verify the skeleton still works:
    1. Run full test suite
    2. Check that the CI pipeline passes
    3. Verify no skeleton patterns were broken
    4. Confirm new code follows skeleton conventions consistently

将决策记录到 CLAUDE.md 中:

Update CLAUDE.md with:
1. Which skeleton we started from (repo URL, commit hash)
2. What we kept and why
3. What we removed and why
4. Any pattern deviations from the original skeleton
5. Conventions we've added on top

阶段第 1 天(骨架)第 1 周(MVP)第 1 个月(生产)
路由1 个示例路由5 个真实路由20+ 路由
测试1 个示例测试30 个测试200+ 测试
配置基础配置基于环境变量的配置多环境 + 密钥管理
数据库SQLite / 本地数据库Docker PostgreSQL托管数据库 + 迁移
CI/CD基础 CI完整 CI/CD 流水线
文档仅 READMECLAUDE.md + ADR完整文档体系

Terminal window
# 1. 克隆经过验证的骨架
git clone https://github.com/example/express-prisma-starter skeleton
cd skeleton && claude
# 2. 审计(约 2 分钟)
# "Audit this skeleton. Is it suitable for a billing microservice?"
# Claude 输出依赖列表、模式分析和适用性评分
# 3. 定制(约 5 分钟)
# "Strip examples, rename to billing-service, add our CLAUDE.md"
# Claude 移除示例代码、更新配置、添加项目上下文
# 4. 第一个功能(约 30 分钟)
# "Implement invoice creation endpoint following skeleton patterns"
# Claude 创建路由、服务层、仓储层和测试,遵循骨架约定
# 5. 验证(约 2 分钟)
# "Run all tests, verify build, check skeleton patterns preserved"
# Claude 验证全部通过、模式一致

陷阱症状解决方案
骨架过于复杂精简时间比开发时间还长选择更简单的骨架,或自行构建最小化版本
依赖过时安装时出现安全警告克隆前检查最后提交日期(理想情况下 < 6 个月)
骨架模式被破坏新代码偏离了骨架的约定将骨架模式作为约束写入 CLAUDE.md
保留了无用代码未使用的示例代码使项目杂乱在阶段二彻底精简,每次删除后验证构建
缺少文档忘记了当初为什么选择该骨架在阶段四立即记录到 CLAUDE.md