/cc-best:backendfrom cc-best
Backend development patterns for services, APIs, and microservices: layered architecture, error handling, logging, and caching. Supports Python, TypeScript, Java, Go, C#, Rust.
Ships in cc-best. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
本技能提供后端服务开发的最佳实践和模式,支持多语言按需加载。
根据项目技术栈,加载对应的语言专属文件:
| 技术栈 | 加载文件 | 框架 |
|---|---|---|
| Python | python.md | FastAPI, Django, Flask |
| TypeScript/Node.js | typescript.md | Express, NestJS, Fastify |
| Java | java.md | Spring Boot, Quarkus |
| Go | go.md | Gin, Echo, Fiber |
| C# | csharp.md | ASP.NET Core |
| Rust | rust.md | Axum, Actix-web, Rocket |
加载方式: 检测项目中的 pyproject.toml/package.json/pom.xml/go.mod/Cargo.toml 等文件确定技术栈。
┌─────────────────────────────────────┐
│ Controller 层 │ 处理 HTTP 请求/响应
├─────────────────────────────────────┤
│ Service 层 │ 业务逻辑
├─────────────────────────────────────┤
│ Repository 层 │ 数据访问
├─────────────────────────────────────┤
│ Model 层 │ 数据模型
└─────────────────────────────────────┘
src/
├── controllers/ # 控制器(或 routes/handlers)
├── services/ # 业务逻辑
├── repositories/ # 数据访问(或 dal/)
├── models/ # 数据模型(或 entities/)
├── middlewares/ # 中间件
├── utils/ # 工具函数
├── config/ # 配置
└── types/ # 类型定义(如适用)
┌─────────────────────────────────────────────────────┐
│ 错误处理金字塔 │
├─────────────────────────────────────────────────────┤
│ 业务错误 (400-499) │
│ ├─ ValidationError (400) 输入验证失败 │
│ ├─ UnauthorizedError (401) 未认证 │
│ ├─ ForbiddenError (403) 无权限 │
│ └─ NotFoundError (404) 资源不存在 │
├─────────────────────────────────────────────────────┤
│ 系统错误 (500-599) │
│ ├─ InternalError (500) 服务器内部错误 │
│ ├─ ServiceUnavailable (503) 服务不可用 │
│ └─ GatewayTimeout (504) 网关超时 │
└─────────────────────────────────────────────────────┘
原则:
日志级别:
| 级别 | 用途 | 示例 |
|---|---|---|
| ERROR | 需要立即关注的错误 | 数据库连接失败 |
| WARN | 潜在问题 | 重试成功、降级处理 |
| INFO | 重要业务事件 | 用户登录、订单创建 |
| DEBUG | 开发调试信息 | 变量值、执行路径 |
结构化日志字段:
{
"timestamp": "2025-01-22T10:00:00Z",
"level": "info",
"message": "用户登录成功",
"requestId": "uuid",
"userId": "123",
"duration": 45
}
| 策略 | 适用场景 | TTL 建议 |
|---|---|---|
| Cache-Aside | 读多写少 | 5-60 分钟 |
| Write-Through | 强一致性要求 | 短 TTL |
| Write-Behind | 写多读少 | 根据业务 |
缓存键命名:
{service}:{entity}:{id}
{service}:{entity}:list:{hash}
/api/v1/...成功响应:
{
"success": true,
"data": { ... },
"meta": { "total": 100, "page": 1 }
}
错误响应:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "邮箱格式不正确"
}
}
GET /health
{
"status": "ok",
"timestamp": "2025-01-22T10:00:00Z",
"services": {
"database": { "status": "ok" },
"redis": { "status": "ok" }
}
}
1. 收到 SIGTERM 信号
2. 停止接受新请求
3. 等待进行中的请求完成(超时时间内)
4. 关闭数据库连接
5. 关闭其他资源
6. 退出进程
详细的语言专属实现请参考:
记住: 后端代码的质量标准是可维护性——类型安全、错误处理、日志追踪缺一不可。
csharp.md (opens in a new tab)go.md (opens in a new tab)java.md (opens in a new tab)performance.md (opens in a new tab)python-observability.md (opens in a new tab)python-patterns.md (opens in a new tab)python-types.md (opens in a new tab)python.md (opens in a new tab)rust.md (opens in a new tab)typescript.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Python, TypeScript, Go, Java, C#
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: userConfig.hookProfile.description: Invalid input: expected string, received undefined
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
19 skills in this plugin
/apiRESTful API design patterns and best practices. Use when creating endpoints, designing APIs, or implementing routes./architectureArchitecture design skill: ADR records, system design checklists, scalability assessment, architecture patterns. Use for complex system design and architecture decisions./compactStrategic compaction skill: suggests context compression at logical breakpoints. Use to suggest compaction at logical intervals during development sessions./databaseDatabase design, query optimization, migrations, and indexing. Use when designing schemas, writing queries, or managing migrations./debugSystematic debugging methods, log analysis, and performance diagnostics. Use when debugging issues, analyzing errors, or troubleshooting incidents./devopsDevOps patterns: containerization, CI/CD, deployment strategies, monitoring. Use when containerizing apps, setting up pipelines, or deploying services.Other plugins' skills for the same job