通过 Skills 可复用工作流、Hooks 自动化防护和 Subagents 并行处理,可以构建企业级的 Claude Code 开发环境,实现代码质量保障和高效协作。
适合的任务:
需要标准化工作流程的团队
复杂的代码审查和质量控制
多任务并行开发
需要外部工具集成的项目(数据库、API等)
不适合的任务:
简单的个人项目
不需要自动化的临时任务
适用的模型版本:Claude Opus 4.7
适用的客户端、Agent 或 API:Claude Code CLI
推荐的推理档位和参数:根据任务复杂度选择 high/xhigh
# Project: billing-service
## Stack
- Node.js 20, TypeScript strict mode
- PostgreSQL via Prisma
- Fastify for HTTP, BullMQ for background jobs
## Conventions
- No `any` types. If the inference is wrong, fix the type at the source.
- All API handlers validate input with Zod schemas in `src/schemas/`
- Prisma queries go through `src/repos/`, never inline
- Tests use Vitest. Run `pnpm test -- <file>` for single-file runs
## Do not
- Run `prisma migrate dev`. Use `pnpm db:migrate` (has our pre-hooks).
- Commit anything that touches `src/billing/legacy/` without flagging it
- Install packages without checking the monorepo root package.json first
## Useful paths
- API routes: `src/routes/`
- Domain logic: `src/domain/<entity>/`
- DB migrations: `prisma/migrations/`目录结构:
.claude/skills/release-notes/
├── SKILL.md
└── references/
└── template.mdSKILL.md 示例:
---
name: release-notes
description: Use when generating release notes from git commits between two tags. Groups by conventional commit type and filters out dependency bumps.
---
# Release Notes Generator
## Steps
1. Run `git log <from-tag>..<to-tag> --oneline` to list commits
2. Parse conventional commit prefixes: feat, fix, perf, refactor, docs, chore
3. Skip commits matching: `chore(deps)`, `chore: bump`, `Merge pull request`
4. Group into: Features, Fixes, Performance, Refactors, Other
5. Use the template in `references/template.md` for formatting
6. Output to stdout unless user specifies a file使用方式:
claude /release-notes v1.2.0 v1.3.0配置文件:.claude/settings.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs -I {} sh -c 'case {} in *.ts|*.tsx) pnpm prettier --write {} ;; esac'"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "jq -e 'select(.tool_input.command | test(\"prod|production\"; \"i\")) | error(\"production commands blocked, use staging\")' > /dev/null 2>&1"
}
]
}
]
}
}Hook 类型说明:
PostToolUse:工具执行后触发(如自动格式化代码)
PreToolUse:工具执行前触发(如阻止危险命令)
专用 Subagent 示例:迁移审计器
---
name: migration-auditor
description: Reviews database migration files for concurrency issues, missing indexes, and backward-compatibility breaks. Use before merging any migration PR.
tools: Read, Grep, Glob, Bash
---
You review database migrations for safety. For each migration file, check:
1. Does it add a NOT NULL column without a default? That breaks concurrent writes.
2. Does it drop a column referenced elsewhere in the codebase? Grep for the column name.
3. Does it add an index on a large table without CONCURRENTLY? That holds a lock.
4. Does it rename a table or column? That breaks deployed code reading the old name.
Output a punch list of issues with file:line references. If clean, say so and stop.使用场景:
代码审查 subagent
安全审计 subagent
性能分析 subagent
测试生成 subagent
添加本地 PostgreSQL 服务器:
# Local scope, only this machine
claude mcp add --transport stdio postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/dev添加项目级 MCP 服务器(共享给团队):
# Project scope, committed to .mcp.json, shared with team
claude mcp add --scope project --transport stdio linear -- npx -y @linear/mcp-server管理 MCP 服务器:
claude mcp list # 列出所有注册的服务器
claude mcp get postgres # 查看单个服务器详情
/mcp # 在会话中查看状态配置 CLAUDE.md:
创建项目根目录的 CLAUDE.md
包含技术栈、约定、禁止事项、有用路径
创建 Skills:
识别重复性工作流(如发布说明、代码审查)
在 .claude/skills/<name>/ 创建 SKILL.md
添加参考文件到 references/ 目录
配置 Hooks:
在 .claude/settings.json 添加 PostToolUse 钩子(自动格式化)
添加 PreToolUse 钩子(阻止危险命令)
测试钩子是否按预期工作
创建 Subagents:
识别需要专门知识的任务(迁移审计、安全审查)
在 .claude/agents/<name>.md 创建 agent 定义
指定需要的工具权限
集成 MCP 服务器:
识别需要的外部工具(数据库、项目管理工具)
使用 claude mcp add 添加服务器
验证连接和数据访问
文章提供了完整的项目配置示例,包括:
详细的 CLAUDE.md 模板(billing-service 项目)
Skills 目录结构和 SKILL.md 完整示例
Hooks 配置(JSON 格式,包含 PostToolUse 和 PreToolUse)
Subagent 定义示例(migration-auditor)
MCP 服务器配置命令和示例
文章强调这些是"patterns that hold up past the first week"(经过一周后仍然有效的模式),适合团队推广使用。
Skills 适合可重复的工作流,不适合一次性任务
Hooks 需要理解 JSON 配置和命令语法,配置错误可能导致 Claude Code 无法正常工作
Subagents 需要明确定义工具权限,避免过度授权
MCP 服务器 需要网络连接和正确的 transport 配置
这些配置需要在团队中共享和同步,建议使用 Git 管理
文章提到:"The honest summary is that most people stop at CLAUDE.md and miss the leverage that comes from Skills, Hooks, and Subagents." 这表明进阶配置能显著提升生产力和代码质量。
文章还提供了团队推广建议:"Rolling it out to a team",强调了标准化配置的重要性。
Claude Opus 4.7