project-onboarding
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResources
资源
scripts/
validate-onboarding.sh
references/
onboarding-patterns.mdscripts/
validate-onboarding.sh
references/
onboarding-patterns.mdProject Onboarding Quality Skill
项目入职质量技能
This skill teaches you how to systematically onboard onto new projects using GoodVibes precision tools. A thorough onboarding process maps the architecture, identifies patterns, validates the environment, and generates documentation for rapid productive contribution.
本技能将教你如何使用GoodVibes精准工具,系统地熟悉新项目。完整的入职流程包括梳理架构、识别模式、验证环境,并生成文档,助力你快速高效地参与项目贡献。
When to Use This Skill
何时使用本技能
Load this skill when:
- Joining a new project or team
- Understanding an unfamiliar codebase
- Documenting project architecture
- Setting up developer environments
- Creating onboarding guides
- Auditing project health and technical debt
Trigger phrases: "onboard to this project", "understand this codebase", "setup dev environment", "map the architecture", "generate project docs".
在以下场景加载本技能:
- 加入新项目或新团队
- 理解不熟悉的代码库
- 记录项目架构
- 搭建开发者环境
- 创建入职指南
- 审计项目健康状况与技术债务
触发短语:“熟悉这个项目”“理解这个代码库”“搭建开发环境”“梳理架构”“生成项目文档”。
Core Workflow
核心工作流程
Phase 1: Project Structure Analysis
第一阶段:代码库结构分析
Understand the directory layout, monorepo configuration, and entry points.
了解目录布局、单仓库(monorepo)配置与入口文件。
Step 1.1: Discover Directory Structure
步骤1.1:梳理目录结构
Use to map the project's directory layout and identify key configuration files.
discoveryaml
discover:
queries:
- id: config_files
type: glob
patterns:
- "package.json"
- "tsconfig*.json"
- "*.config.{js,ts,mjs,cjs}"
- ".env*"
- "docker-compose*.yml"
- "Dockerfile*"
- id: src_structure
type: glob
patterns:
- "src/**/*"
- "app/**/*"
- "pages/**/*"
- "lib/**/*"
- id: monorepo_indicators
type: glob
patterns:
- "pnpm-workspace.yaml"
- "lerna.json"
- "nx.json"
- "turbo.json"
- "packages/*/package.json"
- "apps/*/package.json"
verbosity: files_onlyWhat this reveals:
- Project type (monorepo vs single package)
- Framework/build tool (Next.js, Vite, Create React App, etc.)
- Configuration complexity
- Docker setup for containerized development
使用工具梳理项目的目录布局,识别关键配置文件。
discoveryaml
discover:
queries:
- id: config_files
type: glob
patterns:
- "package.json"
- "tsconfig*.json"
- "*.config.{js,ts,mjs,cjs}"
- ".env*"
- "docker-compose*.yml"
- "Dockerfile*"
- id: src_structure
type: glob
patterns:
- "src/**/*"
- "app/**/*"
- "pages/**/*"
- "lib/**/*"
- id: monorepo_indicators
type: glob
patterns:
- "pnpm-workspace.yaml"
- "lerna.json"
- "nx.json"
- "turbo.json"
- "packages/*/package.json"
- "apps/*/package.json"
verbosity: files_only该步骤可揭示:
- 项目类型(单仓库 vs 独立包)
- 框架/构建工具(Next.js、Vite、Create React App等)
- 配置复杂度
- 用于容器化开发的Docker配置
Step 1.2: Identify Entry Points
步骤1.2:识别入口文件
Find main application entry points, server files, and public APIs.
yaml
discover:
queries:
- id: entry_points
type: glob
patterns:
- "src/index.{ts,tsx,js,jsx}"
- "src/main.{ts,tsx,js,jsx}"
- "src/app.{ts,tsx,js,jsx}"
- "app/layout.{ts,tsx,js,jsx}"
- "pages/_app.{ts,tsx,js,jsx}"
- "server.{ts,js}"
- id: api_routes
type: glob
patterns:
- "src/api/**/*"
- "app/api/**/*"
- "pages/api/**/*"
- "routes/**/*"
- id: public_assets
type: glob
patterns:
- "public/**/*"
- "static/**/*"
verbosity: files_onlyWhat this reveals:
- Application architecture (SPA, SSR, API-only, full-stack)
- Routing patterns
- Static asset organization
查找主应用入口文件、服务器文件与公开API。
yaml
discover:
queries:
- id: entry_points
type: glob
patterns:
- "src/index.{ts,tsx,js,jsx}"
- "src/main.{ts,tsx,js,jsx}"
- "src/app.{ts,tsx,js,jsx}"
- "app/layout.{ts,tsx,js,jsx}"
- "pages/_app.{ts,tsx,js,jsx}"
- "server.{ts,js}"
- id: api_routes
type: glob
patterns:
- "src/api/**/*"
- "app/api/**/*"
- "pages/api/**/*"
- "routes/**/*"
- id: public_assets
type: glob
patterns:
- "public/**/*"
- "static/**/*"
verbosity: files_only该步骤可揭示:
- 应用架构(SPA、SSR、仅API、全栈)
- 路由模式
- 静态资源组织方式
Step 1.3: Read Core Configuration
步骤1.3:读取核心配置
Use to examine package.json and key config files.
precision_readyaml
precision_read:
files:
- path: "package.json"
extract: content
- path: "tsconfig.json"
extract: content
verbosity: standardWhat this reveals:
- Dependencies and dev dependencies
- Scripts for build, dev, test, lint
- Node version requirements (engines field)
- Package manager (npm, yarn, pnpm)
使用工具查看package.json与关键配置文件。
precision_readyaml
precision_read:
files:
- path: "package.json"
extract: content
- path: "tsconfig.json"
extract: content
verbosity: standard该步骤可揭示:
- 依赖项与开发依赖项
- 用于构建、开发、测试、代码检查的脚本
- Node版本要求(engines字段)
- 包管理器(npm、yarn、pnpm)
Phase 2: Dependency Audit
第二阶段:依赖审计
Analyze dependencies for version currency, security vulnerabilities, and bundle size.
分析依赖项的版本时效性、安全漏洞与包体积。
Step 2.1: List All Dependencies
步骤2.1:列出所有依赖项
Extract dependencies from package.json files.
yaml
precision_grep:
queries:
- id: dependencies
pattern: '"dependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
- id: dev_dependencies
pattern: '"devDependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
- id: peer_dependencies
pattern: '"peerDependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
output:
format: matches
verbosity: standard从package.json文件中提取依赖项。
yaml
precision_grep:
queries:
- id: dependencies
pattern: '"dependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
- id: dev_dependencies
pattern: '"devDependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
- id: peer_dependencies
pattern: '"peerDependencies":\s*\{[\s\S]*?\}'
glob: "**/package.json"
multiline: true
output:
format: matches
verbosity: standardStep 2.2: Check for Outdated Dependencies
步骤2.2:检查过时依赖项
Run npm/yarn/pnpm commands to check for updates.
yaml
precision_exec:
commands:
- cmd: "npm outdated --json"
- cmd: "npm audit --json"
verbosity: standardWhat this reveals:
- Packages with available updates
- Security vulnerabilities
- Severity levels (critical, high, moderate, low)
运行npm/yarn/pnpm命令检查更新。
yaml
precision_exec:
commands:
- cmd: "npm outdated --json"
- cmd: "npm audit --json"
verbosity: standard该步骤可揭示:
- 有可用更新的包
- 安全漏洞
- 漏洞严重级别(Critical、High、Moderate、Low)
Step 2.3: Analyze Bundle Size and Tree
步骤2.3:分析包体积与依赖树
Identify large dependencies and potential optimizations.
yaml
precision_exec:
commands:
- cmd: "npx bundle-phobia-cli --json react react-dom next"
verbosity: minimalWhat this reveals:
- Download size and install size
- Gzipped size for production
- Heavy dependencies to watch
识别体积较大的依赖项与潜在优化点。
yaml
precision_exec:
commands:
- cmd: "npx bundle-phobia-cli --json react react-dom next"
verbosity: minimal该步骤可揭示:
- 下载体积与安装体积
- 生产环境压缩后的Gzip体积
- 需要重点关注的重型依赖项
Phase 3: Architecture Mapping
第三阶段:架构梳理
Map module boundaries, data flow, and API surface.
梳理模块边界、数据流与API接口。
Step 3.1: Extract Module Structure
步骤3.1:提取模块结构
Use with outline extraction to map the codebase structure.
precision_readyaml
undefined使用工具的大纲提取功能梳理代码库结构。
precision_readyaml
undefinedNote: path "src" works as a directory - precision_read will recursively extract outline
注意:路径“src”作为目录 - precision_read会递归提取大纲
precision_read:
files:
- path: "src"
extract: outline
output:
max_per_item: 100
verbosity: standard
**What this reveals:**
- Directory organization patterns
- Module boundaries
- Code volume per moduleprecision_read:
files:
- path: "src"
extract: outline
output:
max_per_item: 100
verbosity: standard
**该步骤可揭示:**
- 目录组织模式
- 模块边界
- 各模块的代码量Step 3.2: Identify Key Symbols
步骤3.2:识别关键符号
Use with symbol extraction to find exported functions, classes, and types.
precision_readyaml
undefined使用工具的符号提取功能查找导出的函数、类与类型。
precision_readyaml
undefinedFirst discover the files
首先发现文件
discover:
queries:
- id: lib_files
type: glob
patterns: ["src/lib//*.{ts,tsx}"]
- id: api_files
type: glob
patterns: ["src/api//*.{ts,tsx}"]
verbosity: files_only
discover:
queries:
- id: lib_files
type: glob
patterns: ["src/lib//*.{ts,tsx}"]
- id: api_files
type: glob
patterns: ["src/api//*.{ts,tsx}"]
verbosity: files_only
Then read symbols from discovered files
然后从发现的文件中读取符号
precision_read:
files:
# Use file paths from discover results
- path: "src/lib/index.ts" # Example - use actual discovered paths
extract: symbols
- path: "src/api/index.ts" # Example - use actual discovered paths
extract: symbols
symbol_filter: ["function", "class", "interface", "type"]
verbosity: minimal
**What this reveals:**
- Public API surface
- Core abstractions and utilities
- Type definitionsprecision_read:
files:
# 使用discover结果中的文件路径
- path: "src/lib/index.ts" # 示例 - 使用实际发现的路径
extract: symbols
- path: "src/api/index.ts" # 示例 - 使用实际发现的路径
extract: symbols
symbol_filter: ["function", "class", "interface", "type"]
verbosity: minimal
**该步骤可揭示:**
- 公开API接口
- 核心抽象与工具
- 类型定义Step 3.3: Map Data Flow
步骤3.3:梳理数据流
Trace imports and exports to understand module dependencies.
yaml
discover:
queries:
- id: imports
type: grep
pattern: '^import .* from ["''].*["''];?$'
glob: "src/**/*.{ts,tsx,js,jsx}"
- id: exports
type: grep
pattern: '^export (default|const|function|class|interface|type|enum)'
glob: "src/**/*.{ts,tsx,js,jsx}"
verbosity: count_onlyWhat this reveals:
- Module coupling
- Import patterns (barrel files, direct imports)
- Potential circular dependencies
追踪导入与导出关系,理解模块依赖。
yaml
discover:
queries:
- id: imports
type: grep
pattern: '^import .* from ["''].*["''];?$'
glob: "src/**/*.{ts,tsx,js,jsx}"
- id: exports
type: grep
pattern: '^export (default|const|function|class|interface|type|enum)'
glob: "src/**/*.{ts,tsx,js,jsx}"
verbosity: count_only该步骤可揭示:
- 模块耦合度
- 导入模式(桶文件、直接导入)
- 潜在的循环依赖
Phase 4: Convention Detection
第四阶段:规范检测
Identify code style, naming patterns, and file organization rules.
识别代码风格、命名模式与文件组织规则。
Step 4.1: Detect Naming Conventions
步骤4.1:检测命名规范
Search for naming patterns in files and symbols.
yaml
discover:
queries:
- id: component_naming
type: grep
pattern: 'export (default )?(function|const) [A-Z][a-zA-Z]*'
glob: "src/components/**/*.{ts,tsx}"
- id: hook_naming
type: grep
pattern: 'export (default )?(function|const) use[A-Z][a-zA-Z]*'
glob: "src/**/*.{ts,tsx}"
- id: util_naming
type: grep
pattern: 'export (default )?(function|const) [a-z][a-zA-Z]*'
glob: "src/lib/**/*.{ts,tsx}"
verbosity: count_onlyWhat this reveals:
- PascalCase for components
- camelCase for utilities
- prefix for hooks
use - File naming patterns
查找文件与符号中的命名模式。
yaml
discover:
queries:
- id: component_naming
type: grep
pattern: 'export (default )?(function|const) [A-Z][a-zA-Z]*'
glob: "src/components/**/*.{ts,tsx}"
- id: hook_naming
type: grep
pattern: 'export (default )?(function|const) use[A-Z][a-zA-Z]*'
glob: "src/**/*.{ts,tsx}"
- id: util_naming
type: grep
pattern: 'export (default )?(function|const) [a-z][a-zA-Z]*'
glob: "src/lib/**/*.{ts,tsx}"
verbosity: count_only该步骤可揭示:
- 组件使用PascalCase命名
- 工具函数使用camelCase命名
- Hook使用前缀
use - 文件命名模式
Step 4.2: Detect File Organization Patterns
步骤4.2:检测文件组织模式
Analyze directory structure for organizational conventions.
yaml
discover:
queries:
- id: index_files
type: glob
patterns: ["**/index.{ts,tsx,js,jsx}"]
- id: type_files
type: glob
patterns: ["**/*.types.{ts,tsx}", "**/types.{ts,tsx}", "**/types/**/*"]
- id: test_colocation
type: glob
patterns:
- "**/*.test.{ts,tsx}"
- "**/__tests__/**/*"
verbosity: count_onlyWhat this reveals:
- Barrel exports (index.ts pattern)
- Type definition organization
- Test file placement (co-located vs dedicated folders)
分析目录结构,识别组织规范。
yaml
discover:
queries:
- id: index_files
type: glob
patterns: ["**/index.{ts,tsx,js,jsx}"]
- id: type_files
type: glob
patterns: ["**/*.types.{ts,tsx}", "**/types.{ts,tsx}", "**/types/**/*"]
- id: test_colocation
type: glob
patterns:
- "**/*.test.{ts,tsx}"
- "**/__tests__/**/*"
verbosity: count_only该步骤可揭示:
- 桶导出(index.ts模式)
- 类型定义的组织方式
- 测试文件的放置位置(与代码同目录 vs 独立文件夹)
Step 4.3: Check for Linting and Formatting Config
步骤4.3:检查代码检查与格式化配置
Find ESLint, Prettier, and other code quality configurations.
yaml
discover:
queries:
- id: lint_config
type: glob
patterns:
- ".eslintrc*"
- "eslint.config.{js,mjs,cjs}"
- ".prettierrc*"
- "prettier.config.{js,mjs,cjs}"
- id: editor_config
type: glob
patterns:
- ".editorconfig"
- ".vscode/settings.json"
verbosity: files_onlyRead the configs:
yaml
precision_read:
files:
- path: ".eslintrc.json"
extract: content
- path: ".prettierrc"
extract: content
verbosity: standardWhat this reveals:
- Code style rules (indentation, quotes, semicolons)
- Enabled/disabled linting rules
- Formatting preferences
查找ESLint、Prettier与其他代码质量配置文件。
yaml
discover:
queries:
- id: lint_config
type: glob
patterns:
- ".eslintrc*"
- "eslint.config.{js,mjs,cjs}"
- ".prettierrc*"
- "prettier.config.{js,mjs,cjs}"
- id: editor_config
type: glob
patterns:
- ".editorconfig"
- ".vscode/settings.json"
verbosity: files_only读取配置文件:
yaml
precision_read:
files:
- path: ".eslintrc.json"
extract: content
- path: ".prettierrc"
extract: content
verbosity: standard该步骤可揭示:
- 代码风格规则(缩进、引号、分号)
- 启用/禁用的代码检查规则
- 格式化偏好
Phase 5: Environment Setup
第五阶段:环境搭建
Set up developer environment with required dependencies, config files, and database.
搭建包含必要依赖项、配置文件与数据库的开发者环境。
Step 5.1: Check Node Version Requirements
步骤5.1:检查Node版本要求
Read , , or .
.nvmrcpackage.json engines.node-versionyaml
precision_grep:
queries:
- id: node_version_nvmrc
pattern: '.*'
glob: ".nvmrc"
- id: node_version_package
pattern: '"engines":\s*\{[\s\S]*?"node":\s*"[^"]+"'
glob: "package.json"
multiline: true
output:
format: matches
verbosity: standardWhat this reveals:
- Required Node.js version
- Package manager version requirements
读取、或文件。
.nvmrcpackage.json engines.node-versionyaml
precision_grep:
queries:
- id: node_version_nvmrc
pattern: '.*'
glob: ".nvmrc"
- id: node_version_package
pattern: '"engines":\s*\{[\s\S]*?"node":\s*"[^"]+"'
glob: "package.json"
multiline: true
output:
format: matches
verbosity: standard该步骤可揭示:
- 所需的Node.js版本
- 包管理器版本要求
Step 5.2: Install Dependencies
步骤5.2:安装依赖项
Run the package manager install command.
yaml
precision_exec:
commands:
- cmd: "npm install"
timeout_ms: 300000
verbosity: minimalFor pnpm or yarn:
yaml
precision_exec:
commands:
- cmd: "pnpm install"
timeout_ms: 300000
verbosity: minimal运行包管理器的安装命令。
yaml
precision_exec:
commands:
- cmd: "npm install"
timeout_ms: 300000
verbosity: minimal对于pnpm或yarn:
yaml
precision_exec:
commands:
- cmd: "pnpm install"
timeout_ms: 300000
verbosity: minimalStep 5.3: Setup Environment Variables
步骤5.3:配置环境变量
Identify required environment variables from or code.
.env.exampleyaml
precision_read:
files:
- path: ".env.example"
extract: content
verbosity: standardSearch for env var usage in code:
yaml
precision_grep:
queries:
- id: env_usage
pattern: 'process\.env\.[A-Z_]+'
glob: "src/**/*.{ts,tsx,js,jsx}"
output:
format: matches
max_per_item: 20
verbosity: minimalWhat this reveals:
- Required environment variables
- API keys, database URLs, secrets needed
- Third-party service integrations
从或代码中识别所需的环境变量。
.env.exampleyaml
precision_read:
files:
- path: ".env.example"
extract: content
verbosity: standard在代码中查找环境变量的使用:
yaml
precision_grep:
queries:
- id: env_usage
pattern: 'process\.env\.[A-Z_]+'
glob: "src/**/*.{ts,tsx,js,jsx}"
output:
format: matches
max_per_item: 20
verbosity: minimal该步骤可揭示:
- 所需的环境变量
- 需要的API密钥、数据库URL、密钥
- 第三方服务集成
Step 5.4: Database Setup
步骤5.4:数据库搭建
Check for database schema files, migrations, and seed scripts.
yaml
discover:
queries:
- id: prisma_schema
type: glob
patterns: ["prisma/schema.prisma"]
- id: migrations
type: glob
patterns:
- "prisma/migrations/**/*"
- "migrations/**/*"
- "db/migrations/**/*"
- id: seed_scripts
type: glob
patterns:
- "prisma/seed.{ts,js}"
- "db/seed.{ts,js}"
- "scripts/seed.{ts,js}"
verbosity: files_onlyRun database setup:
yaml
precision_exec:
commands:
- cmd: "npx prisma generate"
- cmd: "npx prisma migrate dev"
- cmd: "npx prisma db seed"
verbosity: standardWhat this reveals:
- Database schema and models
- Migration history
- Seed data for development
检查数据库模式文件、迁移脚本与初始化脚本。
yaml
discover:
queries:
- id: prisma_schema
type: glob
patterns: ["prisma/schema.prisma"]
- id: migrations
type: glob
patterns:
- "prisma/migrations/**/*"
- "migrations/**/*"
- "db/migrations/**/*"
- id: seed_scripts
type: glob
patterns:
- "prisma/seed.{ts,js}"
- "db/seed.{ts,js}"
- "scripts/seed.{ts,js}"
verbosity: files_only运行数据库搭建:
yaml
precision_exec:
commands:
- cmd: "npx prisma generate"
- cmd: "npx prisma migrate dev"
- cmd: "npx prisma db seed"
verbosity: standard该步骤可揭示:
- 数据库模式与模型
- 迁移历史
- 用于开发的初始化数据
Phase 6: Build & Dev Workflow
第六阶段:构建与开发工作流
Understand build commands, dev server, hot reload, and test runners.
了解构建命令、开发服务器、热重载与测试运行器。
Step 6.1: Identify Build Scripts
步骤6.1:识别构建脚本
Extract scripts from package.json.
yaml
precision_grep:
queries:
- id: scripts
pattern: '"scripts":\s*\{[\s\S]*?\}'
glob: "package.json"
multiline: true
output:
format: matches
verbosity: standardWhat this reveals:
- or
devcommand for local developmentstart - command for production build
build - command for running tests
test - command for linting
lint - Custom scripts for deployment, database, etc.
从package.json中提取脚本。
yaml
precision_grep:
queries:
- id: scripts
pattern: '"scripts":\s*\{[\s\S]*?\}'
glob: "package.json"
multiline: true
output:
format: matches
verbosity: standard该步骤可揭示:
- 用于本地开发的或
dev命令start - 用于生产构建的命令
build - 用于运行测试的命令
test - 用于代码检查的命令
lint - 用于部署、数据库等的自定义脚本
Step 6.2: Test Build Process
步骤6.2:测试构建流程
Run the build command to verify setup.
yaml
precision_exec:
commands:
- cmd: "npm run build"
timeout_ms: 300000
verbosity: standardWhat this reveals:
- Build errors or warnings
- Build output location
- Build time and performance
运行构建命令验证配置。
yaml
precision_exec:
commands:
- cmd: "npm run build"
timeout_ms: 300000
verbosity: standard该步骤可揭示:
- 构建错误或警告
- 构建输出位置
- 构建时间与性能
Step 6.3: Start Dev Server
步骤6.3:启动开发服务器
Run the dev command to verify hot reload works.
yaml
precision_exec:
commands:
- cmd: "npm run dev"
timeout_ms: 60000
until:
pattern: "(ready|compiled|listening|started)"
kill_after: true # Stops dev server after pattern matches
verbosity: standardWhat this reveals:
- Dev server port (usually :3000, :5173, :8080)
- Hot reload configuration
- Startup time
运行开发命令验证热重载是否正常工作。
yaml
precision_exec:
commands:
- cmd: "npm run dev"
timeout_ms: 60000
until:
pattern: "(ready|compiled|listening|started)"
kill_after: true # 匹配到模式后停止开发服务器
verbosity: standard该步骤可揭示:
- 开发服务器端口(通常为:3000、:5173、:8080)
- 热重载配置
- 启动时间
Step 6.4: Run Tests
步骤6.4:运行测试
Execute test suite to verify test setup.
yaml
precision_exec:
commands:
- cmd: "npm test"
timeout_ms: 120000
verbosity: standardWhat this reveals:
- Test framework (Jest, Vitest, Mocha, etc.)
- Test coverage
- Failing tests or setup issues
执行测试套件验证测试配置。
yaml
precision_exec:
commands:
- cmd: "npm test"
timeout_ms: 120000
verbosity: standard该步骤可揭示:
- 测试框架(Jest、Vitest、Mocha等)
- 测试覆盖率
- 失败的测试或配置问题
Phase 7: Key Patterns
第七阶段:关键模式
Identify recurring patterns for state management, error handling, authentication, and routing.
识别状态管理、错误处理、身份验证与路由的常用模式。
Step 7.1: State Management Patterns
步骤7.1:状态管理模式
Search for state management libraries and patterns.
yaml
discover:
queries:
- id: react_state
type: grep
pattern: '(useState|useReducer|useContext)'
glob: "src/**/*.{ts,tsx}"
- id: zustand
type: grep
pattern: "(create|useStore).*from ['\"]zustand"
glob: "src/**/*.{ts,tsx}"
- id: redux
type: grep
pattern: "(useSelector|useDispatch|createSlice)"
glob: "src/**/*.{ts,tsx}"
- id: jotai
type: grep
pattern: "(atom|useAtom).*from ['\"]jotai"
glob: "src/**/*.{ts,tsx}"
verbosity: count_onlyWhat this reveals:
- Primary state management approach
- Global vs local state patterns
- Store organization
查找状态管理库与模式。
yaml
discover:
queries:
- id: react_state
type: grep
pattern: '(useState|useReducer|useContext)'
glob: "src/**/*.{ts,tsx}"
- id: zustand
type: grep
pattern: "(create|useStore).*from ['\"]zustand"
glob: "src/**/*.{ts,tsx}"
- id: redux
type: grep
pattern: "(useSelector|useDispatch|createSlice)"
glob: "src/**/*.{ts,tsx}"
- id: jotai
type: grep
pattern: "(atom|useAtom).*from ['\"]jotai"
glob: "src/**/*.{ts,tsx}"
verbosity: count_only该步骤可揭示:
- 主要的状态管理方案
- 全局与局部状态模式
- Store组织方式
Step 7.2: Error Handling Patterns
步骤7.2:错误处理模式
Find error boundaries, try-catch patterns, and error reporting.
yaml
undefined查找错误边界、try-catch模式与错误上报。
yaml
undefinedUse precision_grep instead of discover for multiline patterns
对于多行模式,使用precision_grep而非discover
precision_grep:
queries:
- id: error_boundaries
pattern: "(class|extends) .ErrorBoundary"
glob: "src/**/.{ts,tsx}"
- id: try_catch
pattern: "try {[\s\S]?} catch"
glob: "src/**/.{ts,tsx,js,jsx}"
multiline: true
- id: error_reporting
pattern: "(Sentry|Bugsnag|ErrorBoundary|reportError)"
glob: "src/**/*.{ts,tsx,js,jsx}"
output:
format: count_only
verbosity: minimal
**What this reveals:**
- Error boundary usage
- Error logging and reporting setup
- Exception handling conventionsprecision_grep:
queries:
- id: error_boundaries
pattern: "(class|extends) .ErrorBoundary"
glob: "src/**/.{ts,tsx}"
- id: try_catch
pattern: "try {[\s\S]?} catch"
glob: "src/**/.{ts,tsx,js,jsx}"
multiline: true
- id: error_reporting
pattern: "(Sentry|Bugsnag|ErrorBoundary|reportError)"
glob: "src/**/*.{ts,tsx,js,jsx}"
output:
format: count_only
verbosity: minimal
**该步骤可揭示:**
- 错误边界的使用
- 错误日志与上报配置
- 异常处理规范Step 7.3: Authentication Patterns
步骤7.3:身份验证模式
Identify authentication library and patterns.
yaml
discover:
queries:
- id: auth_providers
type: grep
pattern: "(NextAuth|Clerk|Auth0|Supabase|Lucia|useAuth)"
glob: "src/**/*.{ts,tsx}"
- id: protected_routes
type: grep
pattern: "(withAuth|requireAuth|ProtectedRoute|middleware)"
glob: "src/**/*.{ts,tsx}"
- id: session_usage
type: grep
pattern: "(getSession|useSession|getServerSession)"
glob: "src/**/*.{ts,tsx}"
verbosity: count_onlyWhat this reveals:
- Authentication provider (Clerk, NextAuth, custom)
- Protected route patterns
- Session management approach
识别身份验证库与模式。
yaml
discover:
queries:
- id: auth_providers
type: grep
pattern: "(NextAuth|Clerk|Auth0|Supabase|Lucia|useAuth)"
glob: "src/**/*.{ts,tsx}"
- id: protected_routes
type: grep
pattern: "(withAuth|requireAuth|ProtectedRoute|middleware)"
glob: "src/**/*.{ts,tsx}"
- id: session_usage
type: grep
pattern: "(getSession|useSession|getServerSession)"
glob: "src/**/*.{ts,tsx}"
verbosity: count_only该步骤可揭示:
- 身份验证提供商(Clerk、NextAuth、自定义)
- 受保护路由模式
- Session管理方案
Step 7.4: Routing Patterns
步骤7.4:路由模式
Understand routing architecture.
yaml
discover:
queries:
- id: app_router
type: glob
patterns: ["app/**/page.{ts,tsx}", "app/**/layout.{ts,tsx}"]
- id: pages_router
type: glob
patterns: ["pages/**/*.{ts,tsx}"]
- id: react_router
type: grep
pattern: "(BrowserRouter|Routes|Route|useNavigate)"
glob: "src/**/*.{ts,tsx}"
verbosity: count_onlyWhat this reveals:
- Routing framework (Next.js App Router, Pages Router, React Router)
- Route organization
- Dynamic route patterns
理解路由架构。
yaml
discover:
queries:
- id: app_router
type: glob
patterns: ["app/**/page.{ts,tsx}", "app/**/layout.{ts,tsx}"]
- id: pages_router
type: glob
patterns: ["pages/**/*.{ts,tsx}"]
- id: react_router
type: grep
pattern: "(BrowserRouter|Routes|Route|useNavigate)"
glob: "src/**/*.{ts,tsx}"
verbosity: count_only该步骤可揭示:
- 路由框架(Next.js App Router、Pages Router、React Router)
- 路由组织方式
- 动态路由模式
Phase 8: Documentation Generation
第八阶段:文档生成
Generate CLAUDE.md, architecture docs, and onboarding guides.
生成CLAUDE.md、架构文档与入职指南。
Step 8.1: Create CLAUDE.md Project Instructions
步骤8.1:创建CLAUDE.md项目说明
Write a comprehensive CLAUDE.md with project context.
yaml
precision_write:
files:
- path: ".claude/CLAUDE.md"
mode: fail_if_exists
content: |
# Project Name
## Overview
[Brief description of the project, its purpose, and key features]
## Architecture
- **Framework**: [Next.js 14 App Router / Remix / etc.]
- **Language**: [TypeScript]
- **Database**: [PostgreSQL with Prisma]
- **Authentication**: [Clerk / NextAuth]
- **State Management**: [Zustand / Redux / etc.]
## Directory Structure
```
src/
app/ # Next.js App Router pages and layouts
components/ # React components
lib/ # Utility functions and shared logic
api/ # API route handlers
types/ # TypeScript type definitions
```
## Development Workflow
1. Install dependencies: `pnpm install`
2. Setup environment: Copy `.env.example` to `.env.local`
3. Setup database: `npx prisma migrate dev`
4. Start dev server: `pnpm dev`
5. Run tests: `pnpm test`
## Key Patterns
- Components use PascalCase naming
- Utilities use camelCase naming
- Hooks start with `use` prefix
- Server components by default, use 'use client' directive for client components
## Testing
- Unit tests: Vitest
- E2E tests: Playwright
- Run with: `pnpm test`
## Deployment
- Platform: [Vercel / Netlify / etc.]
- CI/CD: [GitHub Actions]
- Deploy command: `pnpm build`
verbosity: minimal编写包含项目上下文的完整CLAUDE.md。
yaml
precision_write:
files:
- path: ".claude/CLAUDE.md"
mode: fail_if_exists
content: |
# 项目名称
## 概述
[项目的简要描述、用途与核心功能]
## 架构
- **框架**: [Next.js 14 App Router / Remix / 等]
- **语言**: [TypeScript]
- **数据库**: [PostgreSQL with Prisma]
- **身份验证**: [Clerk / NextAuth]
- **状态管理**: [Zustand / Redux / 等]
## 目录结构
```
src/
app/ # Next.js App Router页面与布局
components/ # React组件
lib/ # 工具函数与共享逻辑
api/ # API路由处理器
types/ # TypeScript类型定义
```
## 开发工作流
1. 安装依赖: `pnpm install`
2. 配置环境: 复制`.env.example`到`.env.local`
3. 配置数据库: `npx prisma migrate dev`
4. 启动开发服务器: `pnpm dev`
5. 运行测试: `pnpm test`
## 关键模式
- 组件使用PascalCase命名
- 工具函数使用camelCase命名
- Hook以`use`前缀开头
- 默认使用服务器组件,客户端组件使用'use client'指令
## 测试
- 单元测试: Vitest
- E2E测试: Playwright
- 运行命令: `pnpm test`
## 部署
- 平台: [Vercel / Netlify / 等]
- CI/CD: [GitHub Actions]
- 部署命令: `pnpm build`
verbosity: minimalStep 8.2: Generate Architecture Diagram
步骤8.2:生成架构图
Create a mermaid diagram of the architecture.
yaml
precision_write:
files:
- path: "docs/ARCHITECTURE.md"
mode: fail_if_exists
content: |
# Architecture
## System Overview
```mermaid
graph TD
A[Client Browser] --> B[Next.js App Router]
B --> C[React Server Components]
B --> D[API Routes]
D --> E[Database - Prisma]
D --> F[External APIs]
C --> E
```
## Module Boundaries
- `app/`: Page routes and layouts (Next.js App Router)
- `components/`: Reusable UI components
- `lib/`: Business logic and utilities
- `api/`: Backend API handlers
## Data Flow
1. User requests page -> Next.js App Router
2. Server Component fetches data -> Prisma -> Database
3. Server renders component with data
4. Client receives HTML with hydration instructions
5. Client-side interactions -> API routes -> Database
## External Dependencies
- Authentication: Clerk
- Email: Resend
- Storage: Vercel Blob
verbosity: minimal创建架构的Mermaid图。
yaml
precision_write:
files:
- path: "docs/ARCHITECTURE.md"
mode: fail_if_exists
content: |
# 架构
## 系统概述
```mermaid
graph TD
A[客户端浏览器] --> B[Next.js App Router]
B --> C[React服务器组件]
B --> D[API路由]
D --> E[数据库 - Prisma]
D --> F[外部API]
C --> E
```
## 模块边界
- `app/`: 页面路由与布局(Next.js App Router)
- `components/`: 可复用UI组件
- `lib/`: 业务逻辑与工具函数
- `api/`: 后端API处理器
## 数据流
1. 用户请求页面 -> Next.js App Router
2. 服务器组件获取数据 -> Prisma -> 数据库
3. 服务器渲染带数据的组件
4. 客户端接收包含水合指令的HTML
5. 客户端交互 -> API路由 -> 数据库
## 外部依赖
- 身份验证: Clerk
- 邮件: Resend
- 存储: Vercel Blob
verbosity: minimalStep 8.3: Create Onboarding Checklist
步骤8.3:创建入职清单
Generate a checklist for new developers.
yaml
precision_write:
files:
- path: "docs/ONBOARDING.md"
mode: fail_if_exists
content: |
# Onboarding Checklist
## Prerequisites
- [ ] Node.js 18+ installed
- [ ] pnpm installed (`npm install -g pnpm`)
- [ ] Git configured
- [ ] PostgreSQL installed locally (or Docker)
## Setup Steps
1. [ ] Clone repository
2. [ ] Install dependencies: `pnpm install`
3. [ ] Copy `.env.example` to `.env.local`
4. [ ] Fill in environment variables (get from team)
5. [ ] Setup database: `npx prisma migrate dev`
6. [ ] Seed database: `npx prisma db seed`
7. [ ] Start dev server: `pnpm dev`
8. [ ] Open http://localhost:3000
9. [ ] Run tests: `pnpm test`
10. [ ] Verify build: `pnpm build`
## Key Resources
- Architecture: [docs/ARCHITECTURE.md](./ARCHITECTURE.md)
- API Docs: [docs/API.md](./API.md)
- Code Review: Use `/code-review` skill
## First Tasks
1. Read through CLAUDE.md for project context
2. Explore the codebase structure
3. Review recent pull requests
4. Pick a "good first issue" from GitHub
verbosity: minimal为新开发者生成 checklist。
yaml
precision_write:
files:
- path: "docs/ONBOARDING.md"
mode: fail_if_exists
content: |
# 入职清单
## 前置条件
- [ ] 安装Node.js 18+
- [ ] 安装pnpm (`npm install -g pnpm`)
- [ ] 配置Git
- [ ] 本地安装PostgreSQL(或Docker)
## 配置步骤
1. [ ] 克隆仓库
2. [ ] 安装依赖: `pnpm install`
3. [ ] 复制`.env.example`到`.env.local`
4. [ ] 填写环境变量(向团队获取)
5. [ ] 配置数据库: `npx prisma migrate dev`
6. [ ] 初始化数据库: `npx prisma db seed`
7. [ ] 启动开发服务器: `pnpm dev`
8. [ ] 打开http://localhost:3000
9. [ ] 运行测试: `pnpm test`
10. [ ] 验证构建: `pnpm build`
## 核心资源
- 架构: [docs/ARCHITECTURE.md](./ARCHITECTURE.md)
- API文档: [docs/API.md](./API.md)
- 代码评审: 使用`/code-review`技能
## 初始任务
1. 阅读CLAUDE.md了解项目上下文
2. 探索代码库结构
3. 查看近期的Pull Request
4. 从GitHub挑选一个“good first issue”
verbosity: minimalPhase 9: Contribution Workflow
第九阶段:贡献工作流
Understand Git branching strategy, PR process, and CI/CD pipeline.
了解Git分支策略、PR流程与CI/CD流水线。
Step 9.1: Check Git Configuration
步骤9.1:检查Git配置
Find branch protection rules and workflow files.
yaml
discover:
queries:
- id: github_workflows
type: glob
patterns: [".github/workflows/**/*.yml", ".github/workflows/**/*.yaml"]
- id: git_hooks
type: glob
patterns: [".husky/**/*", ".git/hooks/**/*"]
- id: branch_config
type: glob
patterns: [".github/CODEOWNERS", ".github/pull_request_template.md"]
verbosity: files_onlyRead GitHub Actions workflows:
yaml
precision_read:
files:
- path: ".github/workflows/ci.yml"
extract: content
verbosity: standardWhat this reveals:
- CI/CD pipeline steps
- Required checks before merge
- Deploy process
查找分支保护规则与工作流文件。
yaml
discover:
queries:
- id: github_workflows
type: glob
patterns: [".github/workflows/**/*.yml", ".github/workflows/**/*.yaml"]
- id: git_hooks
type: glob
patterns: [".husky/**/*", ".git/hooks/**/*"]
- id: branch_config
type: glob
patterns: [".github/CODEOWNERS", ".github/pull_request_template.md"]
verbosity: files_only读取GitHub Actions工作流:
yaml
precision_read:
files:
- path: ".github/workflows/ci.yml"
extract: content
verbosity: standard该步骤可揭示:
- CI/CD流水线步骤
- 合并前的必要检查
- 部署流程
Step 9.2: Understand PR Process
步骤9.2:理解PR流程
Read PR template and contributing guidelines.
yaml
precision_read:
files:
- path: ".github/pull_request_template.md"
extract: content
- path: "CONTRIBUTING.md"
extract: content
verbosity: standardWhat this reveals:
- PR description requirements
- Review process
- Testing expectations
读取PR模板与贡献指南。
yaml
precision_read:
files:
- path: ".github/pull_request_template.md"
extract: content
- path: "CONTRIBUTING.md"
extract: content
verbosity: standard该步骤可揭示:
- PR描述要求
- 评审流程
- 测试预期
Step 9.3: Check Commit Conventions
步骤9.3:检查提交规范
Search for commit message conventions.
yaml
undefined查找提交消息规范。
yaml
undefinedCheck for commitlint config
检查commitlint配置
precision_grep:
queries:
- id: commitlint
pattern: '.'
glob: ".commitlintrc"
output:
format: matches
verbosity: minimal
precision_grep:
queries:
- id: commitlint
pattern: '.'
glob: ".commitlintrc"
output:
format: matches
verbosity: minimal
Check commit convention from recent commits
从近期提交中检查提交规范
precision_exec:
commands:
- cmd: "git log --oneline -20"
verbosity: standard
**What this reveals:**
- Commit message format (Conventional Commits, custom)
- Scopes used in commitsprecision_exec:
commands:
- cmd: "git log --oneline -20"
verbosity: standard
**该步骤可揭示:**
- 提交消息格式(Conventional Commits、自定义)
- 提交中使用的作用域Phase 10: Validation & Verification
第十阶段:验证与确认
Verify environment works end-to-end.
端到端验证环境是否正常工作。
Step 10.1: Run Full Test Suite
步骤10.1:运行完整测试套件
Execute all tests with coverage.
yaml
precision_exec:
commands:
- cmd: "npm test -- --coverage"
timeout_ms: 180000
verbosity: standardWhat this reveals:
- Test coverage percentage
- Uncovered files or lines
- Slow or flaky tests
执行所有测试并查看覆盖率。
yaml
precision_exec:
commands:
- cmd: "npm test -- --coverage"
timeout_ms: 180000
verbosity: standard该步骤可揭示:
- 测试覆盖率百分比
- 未覆盖的文件或代码行
- 缓慢或不稳定的测试
Step 10.2: Verify Linting Passes
步骤10.2:验证代码检查通过
Run linting to ensure code quality.
yaml
precision_exec:
commands:
- cmd: "npm run lint"
verbosity: standardWhat this reveals:
- Linting errors or warnings
- Code style violations
运行代码检查确保代码质量。
yaml
precision_exec:
commands:
- cmd: "npm run lint"
verbosity: standard该步骤可揭示:
- 代码检查错误或警告
- 代码风格违规
Step 10.3: Check Type Safety
步骤10.3:检查类型安全性
Run TypeScript type checker.
yaml
precision_exec:
commands:
- cmd: "npm run typecheck"
verbosity: standardWhat this reveals:
- Type errors
- Missing type definitions
- usage
any
运行TypeScript类型检查器。
yaml
precision_exec:
commands:
- cmd: "npm run typecheck"
verbosity: standard该步骤可揭示:
- 类型错误
- 缺失的类型定义
- 的使用
any
Step 10.4: Verify Production Build
步骤10.4:验证生产构建
Build for production and check bundle size.
yaml
precision_exec:
commands:
- cmd: "npm run build"
timeout_ms: 300000
- cmd: "ls -lh .next/static/chunks" # Next.js example
verbosity: standardWhat this reveals:
- Build warnings or errors
- Bundle size
- Optimization opportunities
构建生产版本并检查包体积。
yaml
precision_exec:
commands:
- cmd: "npm run build"
timeout_ms: 300000
- cmd: "ls -lh .next/static/chunks" # Next.js示例
verbosity: standard该步骤可揭示:
- 构建警告或错误
- 包体积
- 优化机会
Best Practices
最佳实践
1. Start Small, Go Deep
1. 由浅入深
Don't try to understand everything at once. Start with:
- Project structure (Phase 1)
- Environment setup (Phase 5)
- Build workflow (Phase 6)
Then dive deeper into architecture, patterns, and contribution workflow.
不要试图一次性理解所有内容。从以下部分开始:
- 项目结构(第一阶段)
- 环境搭建(第五阶段)
- 构建工作流(第六阶段)
然后深入了解架构、模式与贡献工作流。
2. Use Precision Tools Efficiently
2. 高效使用精准工具
- Use with
discoverfirst to gauge scopeverbosity: count_only - Use to build target lists
verbosity: files_only - Use with
precision_readbefore reading full contentextract: outline - Use with
precision_grepfor pattern prevalence checksoutput.format: count_only
- 先使用并设置
discover来评估范围verbosity: count_only - 使用来构建目标文件列表
verbosity: files_only - 在读取完整内容前,使用并设置
precision_readextract: outline - 使用并设置
precision_grep来检查模式的普及程度output.format: count_only
3. Document as You Learn
3. 边学边记录
Create or update documentation during onboarding:
- CLAUDE.md with project context
- Architecture diagrams
- Setup guides
- Common pitfalls and solutions
在入职过程中创建或更新文档:
- 包含项目上下文的CLAUDE.md
- 架构图
- 配置指南
- 常见陷阱与解决方案
4. Validate Early
4. 尽早验证
Run builds, tests, and linting early in the onboarding process. This catches environment issues before you invest time in understanding the codebase.
在入职过程中尽早运行构建、测试与代码检查。这能在你投入时间理解代码库前,发现环境问题。
5. Ask Questions
5. 主动提问
When you find:
- Undocumented patterns
- Complex abstractions
- Missing tests
- Inconsistent conventions
Document them as questions for the team.
当你发现:
- 未记录的模式
- 复杂的抽象
- 缺失的测试
- 不一致的规范
将它们记录为问题,向团队咨询。
Common Pitfalls
常见陷阱
Pitfall 1: Skipping Dependency Installation
陷阱1:跳过依赖安装
Problem: Jumping into code reading without installing dependencies.
Solution: Always run first. Many tools (TypeScript, ESLint) need dependencies to function.
npm install问题: 未安装依赖就直接阅读代码。
解决方案: 始终先运行。许多工具(TypeScript、ESLint)需要依赖才能正常工作。
npm installPitfall 2: Ignoring Environment Variables
陷阱2:忽略环境变量
Problem: Missing file causes runtime errors.
.env.localSolution: Copy to and fill in required values. Ask team for secrets.
.env.example.env.local问题: 缺少文件导致运行时错误。
.env.local解决方案: 复制到并填写必要的值。向团队获取密钥。
.env.example.env.localPitfall 3: Not Testing the Build
陷阱3:不测试构建
Problem: Assuming the build works without verifying.
Solution: Run early to catch configuration issues, missing dependencies, or TypeScript errors.
npm run build问题: 假设构建能正常工作而不验证。
解决方案: 尽早运行来发现配置问题、缺失的依赖或TypeScript错误。
npm run buildPitfall 4: Overlooking Database Setup
陷阱4:忽略数据库搭建
Problem: Application fails at runtime due to missing database schema.
Solution: Run migrations () and seed data before starting dev server.
npx prisma migrate dev问题: 由于缺少数据库模式,应用在运行时失败。
解决方案: 在启动开发服务器前,运行迁移()并初始化数据。
npx prisma migrate devPitfall 5: Not Reading Existing Documentation
陷阱5:不阅读现有文档
Problem: Missing key context in README.md, CONTRIBUTING.md, or project docs.
Solution: Use to read all markdown files in the root and folder first.
precision_readdocs/问题: 错过README.md、CONTRIBUTING.md或项目文档中的关键上下文。
解决方案: 使用先读取根目录与文件夹中的所有markdown文件。
precision_readdocs/Validation Script
验证脚本
Use the validation script to check your onboarding completeness:
bash
bash plugins/goodvibes/skills/quality/project-onboarding/scripts/validate-onboarding.shThis will verify:
- Dependencies installed
- Environment variables configured
- Database setup complete
- Tests passing
- Build successful
使用验证脚本检查你的入职完成度:
bash
bash plugins/goodvibes/skills/quality/project-onboarding/scripts/validate-onboarding.sh这将验证:
- 依赖已安装
- 环境变量已配置
- 数据库已搭建完成
- 测试通过
- 构建成功
References
参考资料
For detailed patterns and examples, see:
- Onboarding Patterns Reference
- Architecture Mapping Examples
- Convention Detection Patterns
有关详细模式与示例,请查看:
- 入职模式参考
- 架构梳理示例
- 规范检测模式
Related Skills
相关技能
- - Review code quality after understanding the codebase
quality/code-review - - Design new features following existing patterns
architecture/system-design - - Write tests matching project conventions
testing/test-strategy
- - 理解代码库后评审代码质量
quality/code-review - - 遵循现有模式设计新功能
architecture/system-design - - 按照项目规范编写测试
testing/test-strategy