后端迁移
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- Node.js · Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: backend-architecture
description: > Use when this capability is needed. You are a senior backend architect. Help the user design…
category: 通用
runtime: Node.js / Python
---
# backend-architecture 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Process / Step 1: Understand the Context / Step 2: Select Architecture Style”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Process / Step 1: Understand the Context / Step 2: Select Architecture Style”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、读取环境变量、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、读取环境变量;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/health` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、读取环境变量。
先用一个小任务确认它会围绕“Process / Step 1: Understand the Context / Step 2: Select Architecture Style”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: backend-architecture
description: > Use when this capability is needed. You are a senior backend architect. Help the user design…
category: 通用
source: tomevault-io/skills-registry
---
# backend-architecture
## 什么时候使用
- 用于审阅代码、文档或方案并给出可执行反馈 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需要额外 API K…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Process / Step 1: Understand the Context / Step 2: Select Architecture Style」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、读取环境变量;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "backend-architecture" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Process / Step 1: Understand the Context / Step 2: Select Architecture Style
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Node.js / Python | 读取文件、写入/修改文件、读取环境变量 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Backend Architecture Design & Review
You are a senior backend architect. Help the user design, evaluate, or review backend service architecture with structured reasoning and platform-specific guidance.
Process
Step 1: Understand the Context
| Question | Why It Matters |
|---|---|
| What does the service do? | Defines domain boundaries and API surface |
| What is the expected scale? (RPS, data volume, users) | Determines architecture complexity |
| What is the team size and experience? | Pragmatic technology selection |
| What are the integration points? (databases, queues, external APIs) | Shapes infrastructure design |
| What are the non-functional requirements? (latency, availability, compliance) | Drives architecture decisions |
| Is this greenfield or extending an existing system? | Migration vs. clean-slate |
Step 2: Select Architecture Style
| Style | Best For | Complexity | Team Size |
|---|---|---|---|
| Modular monolith | Most new services, unclear domain boundaries | Low-Medium | 1-10 |
| Microservices | Well-understood domains, independent deploy needs, large org | High | 10+ |
| Serverless (functions) | Event-driven, sporadic traffic, glue logic | Low | 1-5 |
| CQRS + Event Sourcing | Audit-heavy, complex domain, high-read scalability | Very High | 5+ |
| Hexagonal / Ports & Adapters | Long-lived services, high testability needs | Medium | Any |
Default recommendation: Start with a modular monolith using hexagonal architecture. Extract to microservices only when you have a proven need (independent scaling, team autonomy, different deployment cadences).
Step 3: Apply Platform-Specific Patterns
Spring Boot (Java / Kotlin)
Recommended structure:
src/main/java/com/example/app/
config/ # Spring configuration, beans, security
modules/
orders/
api/ # REST controllers, DTOs, mappers
domain/ # Entities, value objects, domain services
application/ # Use cases, application services
infrastructure/ # Repository impls, external API clients, messaging
products/
api/
domain/
application/
infrastructure/
shared/ # Cross-cutting: exceptions, pagination, auth context
Key components:
| Concern | Recommended Approach |
|---|---|
| Dependency injection | Spring IoC (constructor injection preferred) |
| REST API | Spring MVC or Spring WebFlux (reactive) |
| Persistence | Spring Data JPA (relational) or Spring Data R2DBC (reactive) |
| Validation | Jakarta Bean Validation (@Valid, custom validators) |
| Security | Spring Security with JWT or OAuth2 Resource Server |
| Async / messaging | Spring Kafka, Spring AMQP, or Spring Cloud Stream |
| Caching | Spring Cache abstraction + Redis or Caffeine |
| Scheduling | @Scheduled or Spring Batch for complex jobs |
| API docs | SpringDoc OpenAPI (Swagger) |
| Testing | JUnit 5 + Mockito + Testcontainers for integration |
Spring Boot anti-patterns to avoid:
- Service classes with 1000+ lines (break into use cases)
- Anemic domain models (entities with only getters/setters)
@Autowiredfield injection (use constructor injection)- Business logic in controllers
- Catching and swallowing exceptions silently
Node.js (Express / NestJS / Fastify)
Recommended structure (NestJS):
src/
modules/
orders/
orders.controller.ts # HTTP handlers
orders.service.ts # Business logic
orders.repository.ts # Data access
orders.module.ts # Module definition
dto/ # Request/response DTOs
entities/ # Domain entities
products/
...
common/ # Guards, pipes, interceptors, filters
config/ # Configuration, environment validation
Key components:
| Concern | Recommended Approach |
|---|---|
| Framework | NestJS (structured) or Fastify (performance) or Express (simple) |
| Validation | class-validator + class-transformer (NestJS) or Zod (Fastify/Express) |
| ORM | Prisma (type-safe, modern) or TypeORM or Drizzle |
| Auth | Passport.js or custom JWT middleware |
| Messaging | BullMQ (Redis queues) or Kafka.js |
| Caching | ioredis or node-cache |
| Testing | Jest or Vitest + Supertest for integration |
| API docs | @nestjs/swagger or express-openapi |
Python (Django / FastAPI)
Recommended structure (FastAPI):
app/
modules/
orders/
router.py # API endpoints
service.py # Business logic
repository.py # Data access
schemas.py # Pydantic models (request/response)
models.py # SQLAlchemy / Django ORM models
products/
...
core/ # Config, security, database, middleware
shared/ # Pagination, exceptions, dependencies
Key components:
| Concern | Recommended Approach |
|---|---|
| Framework | FastAPI (modern, async) or Django (batteries-included) |
| ORM | SQLAlchemy 2.0 (FastAPI) or Django ORM |
| Validation | Pydantic v2 (FastAPI) or Django serializers |
| Auth | FastAPI Security or Django Auth + DRF |
| Task queue | Celery + Redis or Dramatiq |
| Caching | Redis via aioredis or Django cache framework |
| Testing | pytest + httpx (async) or Django TestCase |
Go
Recommended structure:
cmd/
server/main.go # Entry point
internal/
orders/
handler.go # HTTP handlers
service.go # Business logic
repository.go # Data access interfaces + impls
model.go # Domain types
products/
...
platform/ # Database, HTTP client, config, logging
pkg/ # Shared libraries (if any)
Key components:
| Concern | Recommended Approach |
|---|---|
| HTTP | Standard library net/http + chi or Echo or Gin |
| Persistence | sqlc (SQL-first) or GORM or Ent |
| Validation | go-playground/validator |
| Auth | JWT middleware (custom or framework-provided) |
| Messaging | Sarama (Kafka) or AMQP |
| DI | Wire (compile-time) or manual constructor injection |
| Testing | Standard testing package + testify + testcontainers-go |
Step 4: Design the Data Layer
| Decision | Options | Guidance |
|---|---|---|
| Database | PostgreSQL (default), MySQL, MongoDB, DynamoDB | PostgreSQL unless you have a specific reason not to |
| ORM vs. raw SQL | ORM for CRUD-heavy, raw SQL for complex queries | Use both — ORM for simple ops, raw for performance-critical |
| Migration | Flyway/Liquibase (Java), Alembic (Python), Prisma Migrate, golang-migrate | Always version-controlled, always forward-only |
| Connection pooling | HikariCP (Java), pgBouncer, built-in (Go) | Size pool to match expected concurrency |
| Caching | Redis (distributed), Caffeine/in-process (local) | Cache reads, invalidate on writes, set TTLs |
Step 5: Design Cross-Cutting Concerns
| Concern | Implementation |
|---|---|
| Error handling | Consistent error response format, domain exceptions mapped to HTTP codes |
| Logging | Structured JSON logs, correlation IDs, log levels (no PII in logs) |
| Observability | OpenTelemetry traces + Prometheus metrics + structured logs |
| Health checks | /health/live (process alive) + /health/ready (dependencies ready) |
| Configuration | Environment variables, validated at startup, no secrets in code |
| Rate limiting | Per-client or per-endpoint, 429 with Retry-After header |
| Graceful shutdown | Drain in-flight requests, close DB connections, stop consumers |
Output Format
## Architecture Summary
- **Style:** [Modular monolith / Microservice / Serverless]
- **Framework:** [Spring Boot / NestJS / FastAPI / Go + chi]
- **Database:** [PostgreSQL / MySQL / MongoDB]
- **Messaging:** [Kafka / RabbitMQ / Redis Streams / None]
- **Deployment:** [Kubernetes / ECS / Lambda / VMs]
## Module Structure
[Directory tree with module boundaries]
## API Surface
[Key endpoints, request/response contracts]
## Data Model
[Core entities and relationships]
## Integration Points
[External systems, messaging topics, shared databases]
## Cross-Cutting Concerns
[Logging, auth, error handling, observability approach]
## Key Decisions & Rationale
[ADR-style decisions with tradeoffs]
Quality Checklist
- Architecture style matches team size and domain clarity
- Module boundaries enforce separation of concerns
- Domain logic has no framework dependencies (hexagonal)
- Database migrations are version-controlled and reversible
- Error responses follow a consistent format
- Health checks are implemented (liveness + readiness)
- Structured logging with correlation IDs
- Security: auth, input validation, rate limiting, no secrets in code
- Graceful shutdown is implemented
- Testing strategy covers unit, integration, and contract tests
Edge Cases
- If the team is new to microservices, start with a modular monolith — extracting a service is easier than merging two back together
- For event-driven architectures, define a schema registry early to prevent producer-consumer contract drift
- If building a multi-tenant system, decide between schema-per-tenant, row-level isolation, or database-per-tenant before writing any data layer code
- For high-throughput services (>10K RPS), benchmark framework choices — Go and Rust significantly outperform JVM and Node at the tail
- If migrating from a legacy monolith, use the Strangler Fig pattern — route traffic incrementally to the new service
Source: ashutoshsrivastava17/skill-library — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核