Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/movebrickschi/harness-engineering-mcp/15-spring-rest-api-conventionsgit clone --depth 1 https://github.com/movebrickschi/harness-engineering-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/movebrickschi/harness-engineering-mcp/15-spring-rest-api-conventions)<a href="https://agentmods.dev/rules/movebrickschi/harness-engineering-mcp/15-spring-rest-api-conventions"><img src="https://agentmods.dev/badge/rules/movebrickschi/harness-engineering-mcp/15-spring-rest-api-conventions.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01360 | $0.01360 |
| Opus 5 | $0.00680 | $0.00680 |
| Sonnet 5 | $0.00272 | $0.00272 |
| Haiku 4.5 | $0.00136 | $0.00136 |
Grade A, and why
15-spring-rest-api-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 204 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Spring Boot REST API 编码约定
统一响应格式
所有 Controller 方法必须返回 R<T>,禁止直接返回裸对象或 ResponseEntity。
// ✅ 正确
@GetMapping("/{id}")
public R<UserVO> getUser(@PathVariable Long id) {
return R.ok(userService.findById(id));
}
@DeleteMapping("/{id}")
public R<Void> deleteUser(@PathVariable Long id) {
userService.delete(id);
return R.ok();
}
// ❌ 禁止
@GetMapping("/{id}")
public UserVO getUser(@PathVariable Long id) { ... }
@GetMapping("/{id}")
public ResponseEntity<UserVO> getUser(@PathVariable Long id) { ... }
URL 路径规范
| 前缀 | 用途 | 鉴权要求 |
|---|---|---|
/api/admin/... |
后台管理接口 | @PreAuthorize("@authGuard.isSysUser(authentication)") |
/api/app/... |
前台用户接口 | @PreAuthorize("@authGuard.isAppUser(authentication)") 或 @PublicApi |
RESTful 风格:
- 列表:
GET /api/admin/user/list或GET /api/admin/user/page - 详情:
GET /api/admin/user/{id} - 新增:
POST /api/admin/user - 修改:
PUT /api/admin/user/{id} - 删除:
DELETE /api/admin/user/{id}
依赖注入
统一使用构造器注入 + Lombok @RequiredArgsConstructor,禁止 @Autowired 字段注入。
// ✅ 正确
@RestController
@RequiredArgsConstructor
public class UserController {
private final UserService userService;
private final AuditLogService auditLogService;
}
// ❌ 禁止
@RestController
public class UserController {
@Autowired
private UserService userService;
}
权限与认证
后台接口
类级别添加 @PreAuthorize + @SecurityRequirement:
@SecurityRequirement(name = "Bearer")
@PreAuthorize("@authGuard.isSysUser(authentication)")
@RestController
@RequestMapping("/api/admin/xxx")
public class AdminXxxController { }
公开接口
无需登录的接口使用 @PublicApi 注解,SecurityConfig 自动放行:
@PublicApi
@GetMapping("/public/list")
public R<List<ItemVO>> publicList() { }
获取当前用户
使用 @AuthenticationPrincipal LoginUser 获取当前登录用户信息:
@PostMapping
public R<Void> create(@RequestBody @Valid CreateDTO dto,
@AuthenticationPrincipal LoginUser loginUser) {
Long userId = loginUser.getUserId();
// ...
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 204 lines · 1,360 tokens per session scan A 9bfffd352e56
15-spring-rest-api-conventions is a cursor rule published in the GitHub repository movebrickschi/harness-engineering-mcp (2 stars, last pushed 3mo ago), licensed MIT. It adds 1,360 tokens to every session, about $0.0068 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
gradle
Enforce modern Gradle build practices for Java and Android projects, focusing on Kotlin DSL, modularity, version catalogs, and performance optimizations.
mockito
This guide provides definitive best practices for writing robust, maintainable, and readable unit tests using Mockito with JUnit 5, focusing on modern patterns and common pitfalls.
backend
Backend Java — Spring Boot controllers/services, JUnit controller tests, MakeMe. Read this first for any backend work.
java-import-fqn
Java 禁止不必要的全限定类名,必须 import(类名冲突除外).
springboot-jpa-best-practices
Java Spring Boot + JPA 项目最佳实践,涵盖分层架构、注解、事务、异常处理、安全与代码风格等。.
component-parameter-key-no-dot
@ComponentParameter 的 key 禁止包含 ".",统一使用下划线 / 顶层扁平命名.