一键导入
api-conventions
Use when writing or reviewing REST controllers, HTTP endpoints, URL paths, route naming, HTTP verbs, status codes in a Spring Boot project
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when writing or reviewing REST controllers, HTTP endpoints, URL paths, route naming, HTTP verbs, status codes in a Spring Boot project
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when writing, reviewing, or asking about Java code in a Spring Boot project — error handling, exceptions, catch blocks, constructor injection, @Autowired on fields, service methods, null returns, Optional
Use this skill when an AI agent needs to understand a distributed system at runtime. Covers: service dependency mapping, latency analysis per hop, change impact assessment, active incident investigation, SLO compliance, and error analysis. Invoke this skill for questions like: - "what does service X depend on?" - "where is the latency in this request chain?" - "what did this deploy break?" - "what is currently alerting?" - "is it safe to deploy right now?" - "who calls this service?" Do NOT use for: code review, writing code, static analysis, git operations.
Load this skill when the user asks to review code, a PR, a diff, a changelist (CL), or requests a code review. Trigger words include: review, PR review, pull request review, diff review, code review, CL review, LGTM, look at this code.
基于 SOC 职业分类
| name | api-conventions |
| description | Use when writing or reviewing REST controllers, HTTP endpoints, URL paths, route naming, HTTP verbs, status codes in a Spring Boot project |
Three rules covering HTTP verbs, URL structure, and status codes.
All three are feedforward rules — AI code review references their IDs in PR comments.
Match the verb to the intent. Never use GET for mutations.
| Verb | Use for |
|---|---|
GET | Read — must be safe and idempotent, no side effects |
POST | Create a new resource |
PUT | Full replace of an existing resource |
PATCH | Partial update of an existing resource |
DELETE | Remove a resource |
// ❌ API-001 violation
@GetMapping("/users/{id}/deactivate") // GET with side effect
// ✅ correct
@PostMapping("/users/{id}/deactivation") // or DELETE /users/{id}/activation
URLs identify resources (nouns), not actions (verbs). Use plural nouns.
// ❌ API-002 violations
GET /getUser/42
POST /createOrder
GET /users/42/doDeactivate
// ✅ correct
GET /users/42
POST /orders
DELETE /users/42/activation
Sub-resources are fine: /users/{id}/orders reads as "orders belonging to user".
// ❌ returning 200 for everything
return ResponseEntity.ok(createdUser); // should be 201
return ResponseEntity.ok().build(); // empty body should be 204
// ✅ correct
return ResponseEntity
.created(URI.create("/users/" + user.getId()))
.body(user); // 201 Created with Location header
return ResponseEntity.noContent().build(); // 204 No Content
// In @ExceptionHandler / @RestControllerAdvice:
// 400 Bad Request — validation failures (@Valid, @Validated)
// 404 Not Found — resource does not exist
// 409 Conflict — duplicate, version mismatch
// 500 — unhandled — never return this intentionally
Rule of thumb: if the response body is empty, use 204. If a resource was just created, use 201 with a Location header.
| ID | Rule | Enforced by |
|---|---|---|
API-001 | Correct HTTP verb for the intent | AI code review (PR) |
API-002 | No verbs in URL paths, plural nouns | AI code review (PR) |
API-003 | Correct status codes (201/204/400/404/409) | AI code review (PR) |