trpc-auditor
审计tRPC程序的安全性、验证和架构一致性。确保程序遵循服务层模式并具有适当的Zod输入验证。在审查服务器端路由和程序时使用。
📖 中文导读:审计tRPC程序的安全性、验证和架构一致性。确保程序遵循服务层模式并具有适当的Zod输入验证。在审查服务器端路由和程序时使用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: trpc-auditor description: Audit tRPC procedures for security, validation, and architectural consistency. Ensures procedures follow the service-layer pattern and have proper Zod input validation. Use when reviewing server-side routers and procedures. allowed-tools: Read, Grep, Glob
tRPC Procedure Auditor
Standards
Security
- ✅ Use
protectedProcedurefor all authenticated routes - ✅ Validate user permissions within the procedure or middleware
- ✅ Ensure sensitive data is not leaked in response objects
Validation
- ✅ Use Zod for strict input validation (
input(z.object({ ... }))) - ✅ Provide meaningful error messages for validation failures
Architecture (The "Service Layer" Rule)
- ❌ NO business logic in routers.
- ✅ Routers should only:
- Validate input (via Zod)
- Check authentication/authorization
- Call a service function from
server/services/ - Return the result
- ✅ All business logic, database queries, and external API calls must live in
server/services/.
Error Handling
- ✅ Use
TRPCErrorwith appropriate codes (NOT_FOUND, UNAUTHORIZED, etc.) - ✅ Log errors before throwing them to the client
Review Checklist
- Service Layer: Is there business logic in this router? If yes, flag it for move to service layer.
- Validation: Is every input strictly validated with Zod?
- Auth: Is the correct procedure type (public vs protected) being used?
- Typing: Are the return types clear and well-defined?
Auto-Invocation Triggers
This Skill should activate when:
- Reviewing files in
server/routers/or files named*-router.ts - User asks to "audit trpc" or "check server procedures"