生态与社区
Claude Code 的强大不仅来自工具本身,更来自它蓬勃的社区生态。本章介绍被广泛使用的命令、Skill、插件和配置规范。
常用 Slash Commands
Slash Commands 是在对话中直接输入的内置命令,以 / 开头:
会话管理
| 命令 | 说明 |
|---|---|
/clear | 清空当前对话,开始新话题 |
/compact | 压缩对话历史,释放上下文空间 |
/config | 打开 Claude Code 配置界面 |
/context | 显示当前上下文使用情况 |
模式切换
| 命令 | 说明 |
|---|---|
/plan | 进入计划模式(先设计再实现) |
/fast | 切换 Fast Mode(Opus 加速输出) |
/thinking | 切换深度思考模式 |
Git 相关
| 命令 | 说明 |
|---|---|
/commit | 分析变更并创建提交 |
/commit-push-pr | 提交、推送、创建 PR 一键完成 |
/clean_gone | 清理远程已删除的本地分支 |
任务管理
| 命令 | 说明 |
|---|---|
/init | 为新项目生成 CLAUDE.md |
/review | 对当前分支进行代码审查 |
/security-review | 安全审查当前变更 |
/todo | 查看当前任务进度 |
自动化
| 命令 | 说明 |
|---|---|
/loop | 以固定间隔重复执行命令(如每 5 分钟检查 CI 状态) |
/schedule | 在指定时间触发任务 |
/tasks | 查看后台运行的任务 |
社区热门 Skills / Plugins
以下是社区中广泛使用且好评度高的 Skills:
开发流程类
| Skill | 用途 | 社区评价 |
|---|---|---|
| superpowers:brainstorming | 创意阶段的需求分析和方案设计 | 减少 80% 的返工 |
| superpowers:writing-plans | 将设计转化为可执行的实现计划 | 团队协作必备 |
| superpowers:executing-plans | 按计划分步实现,每步设审查点 | 保持代码质量 |
| superpowers:test-driven-development | TDD 工作流:先写测试再写实现 | 适合后端和工具库 |
| superpowers:systematic-debugging | 系统化 Bug 排查方法论 | 比盲目调试高效得多 |
代码质量类
| Skill | 用途 |
|---|---|
| code-review:code-review | 全面的代码审查 |
| security-review | 安全漏洞扫描 |
| code-simplifier | 简化和优化代码 |
| simplify | 审查变更代码的可复用性 |
项目管理类
| Skill | 用途 |
|---|---|
| commit-commands:commit | 智能提交 |
| commit-commands:commit-push-pr | 一键推送到 PR |
| superpowers:finishing-a-development-branch | 完成的开发分支如何集成 |
配置与自动化
| Skill | 用途 |
|---|---|
| init | 为新项目生成 CLAUDE.md |
| claude-md-management | 审查和改进 CLAUDE.md |
| claude-code-setup | 推荐项目应该使用的 Claude Code 功能 |
| update-config | 管理 settings.json 配置 |
| fewer-permission-prompts | 智能分析并减少不必要的权限弹窗 |
CLAUDE.md 编写规范
CLAUDE.md 是 Claude Code 最重要的项目配置文件。一个优秀的 CLAUDE.md 能显著提升 Claude 对项目的理解。
基本结构
markdown
# CLAUDE.md
## Commands
# 常用的构建、测试、开发命令
```bash
pnpm dev # 启动开发服务器
pnpm build # 生产构建
pnpm test # 运行测试
pnpm lint # 代码检查Architecture
项目的高层架构描述
src/— 前端源码(React + TypeScript)server/— 后端 API(Express + Prisma)- 数据流:Client → API → Service → Database
Code Style
编码规范和约定
- 使用 TypeScript 严格模式
- 组件文件使用 PascalCase
- 工具函数文件使用 camelCase
- 所有 API 返回值使用统一的
{ data, error }格式
Conventions
项目特有的约定
- 测试使用 vitest,不要用 jest
- Git commit 使用 conventional commits 格式
- 新功能需要 feature flag,使用
useFeatureFlaghook
### 编写原则
1. **把 CLAUDE.md 当作新人入职文档来写**:你希望新同事第一天知道什么,就写什么
2. **宁短勿长**:只写关键的、反直觉的、易错的。300 行以内最佳
3. **保持更新**:项目架构变化时,同步更新 CLAUDE.md
4. **用 `/init` 生成初稿**:然后手动精炼
5. **放在项目根目录**:Claude Code 自动发现
### 社区推荐模板
```markdown
# CLAUDE.md
## Tech Stack
- Frontend: React 18 + TypeScript + Tailwind CSS
- Backend: Node.js + Express + Prisma + PostgreSQL
- Testing: Vitest + Testing Library
## Commands
```bash
pnpm dev # Start dev server (localhost:3000)
pnpm build # Production build
pnpm test # Run tests
pnpm test:watch # Watch mode
pnpm lint # ESLint + Prettier
pnpm db:migrate # Run Prisma migrationsProject Structure
src/
components/ # Shared UI components
features/ # Feature modules (each has its own hooks, types, tests)
lib/ # Utilities and helpers
pages/ # Route pages
server/
routes/ # API route handlers
services/ # Business logic
db/ # Prisma schema and migrationsRules
- Always use TypeScript strict mode
- API responses use
{ data, error }envelope - Feature flags are required for new features
- Commit messages follow conventional commits
- Never import from
../../— use path aliases - Tests go next to the file they test, with
.test.tssuffix
## 社区推荐配置
### 权限最小化配置
适合刚接触 Claude Code,希望逐步建立信任:
```json
// .claude/settings.json
{
"permissions": {
"allow": [
"Bash(git:status)",
"Bash(git:diff)",
"Bash(git:log)",
"Bash(npm:run)",
"Bash(pnpm:run)",
"Bash(ls:*)",
"Bash(cat:*)"
],
"deny": [
"Bash(rm:*)",
"Bash(sudo:*)",
"Bash(curl:*)",
"Bash(git:push*)"
]
}
}效率优先配置
适合有经验的用户,减少打断:
json
{
"permissions": {
"allow": [
"Bash(git:*)",
"Bash(npm:*)",
"Bash(pnpm:*)",
"Bash(node:*)",
"Bash(ls:*)",
"Bash(cat:*)",
"WebFetch",
"WebSearch"
],
"deny": [
"Bash(rm:-rf:*)",
"Bash(sudo:*)",
"Bash(git:push:--force:*)"
]
},
"enableAllProjectMcpServers": true
}