Agent skill · Audited from source
Api Design Safety
skill · doccker/cc-use-expNOASSERTION licenceAudited 12 Oct 2026 · source f016c8907732
Is it safe? Yes — SAFE, grade B (89/100). We read this skill's source at commit f016c8907732 and found no filesystem, network or shell access and no hard-coded secrets. What it does: 当设计或修改 REST API 响应结构、处理 API 返回值,或生成 Excel/CSV/PDF/对账文件等下游产物时触发。防止 API 设计缺陷导致的字段错位、类型歧义,以及生成产物时关键字段缺失但静默成功的问题。
Cite
Cite this page
ModelsAtlas. “Api Design Safety (doccker/cc-use-exp)”. Retrieved 12 Oct 2026. https://modelsatlas.com/skills/doccker/api-design-safety
Trust audit
Audit 0.4.1 · source read 12 Oct 2026
SAFE means nothing in the source contradicts what the skill says it does. Grade B is shared by 17,406 of 18,389 audited skills.
What the source does
- FilesystemNone observedNo reads or writes in the source
- NetworkNone observedNo outbound calls in the source
- ShellNone observedNo commands run in the source
- DependenciesPinnedNothing floats
- SecretsNone foundNo keys in source
Five audit layers
| Layer | What we check | Result | Findings |
|---|---|---|---|
L0 Provenance | Repo owner, licence, archive status, activity | PASS | 0 |
L1 Static source | Secrets, path traversal, supply chain, hidden code | NA | 0 |
L2 Instructions | Prompt injection, authority framing, hidden directives | PASS | 0 |
L3 Inventory | The files and declarations match the source | PASS | 0 |
L4 Sandbox | Run in isolation and watch behaviour | SKIPPED why | 0 |
Gates applied: no behavioural pass.
Findings (0)
No findings at any severity. We re-audit when the source changes.
Audit 0.4.1 · source sha f016c8907732 · 12 Oct 2026Report an issue or request a re-scan
Provenance
Who published it, and what the verdict is pinned to
- Publisherdoccker GitHub userOwner of the repository this skill is read from
- Source folderdoccker/cc-use-exp/.cursor/skills/api-design-safetyThe exact folder we audited
- LicenceNOASSERTIONAs the repository states it
- Commit pinned for this verdictf016c8907732A new audit runs when the source changes
- Repository statusNot archivedLast push 47 days ago
- Sandboxed runNot runSkills are read, not executed; layer L4 is skipped
What it tells the agent
Full source on GitHub ↗Its description: 当设计或修改 REST API 响应结构、处理 API 返回值,或生成 Excel/CSV/PDF/对账文件等下游产物时触发。防止 API 设计缺陷导致的字段错位、类型歧义,以及生成产物时关键字段缺失但静默成功的问题。
---
name: api-design-safety
description: 当设计或修改 REST API 响应结构、处理 API 返回值,或生成 Excel/CSV/PDF/对账文件等下游产物时触发。防止 API 设计缺陷导致的字段错位、类型歧义,以及生成产物时关键字段缺失但静默成功的问题。
---
# API 设计安全规范
当设计或修改 REST API 响应结构时,防止常见的设计缺陷。
---
## 陷阱 #1: 泛型方法重载歧义
**场景**: 返回类型为 String 时,Java 重载解析可能匹配错误的方法
### 问题根因
Java 方法重载解析时,`String` 类型参数会优先匹配 `success(String message)` 而非 `success(T data)`,导致数据进入错误的字段。
### 错误示例
```java
// ApiResponse 有两个重载:
public static <T> ApiResponse<T> success(T data)
public static <T> ApiResponse<T> success(String message, T data)
// ❌ 错误: String 类型匹配到 success(String message)
String avatarUrl = "http://example.com/avatar.jpg";
return ApiResponse.success(avatarUrl);
// 结果: {"code":200, "message":"http://...", "data":null}
// 前端 data.data 拿到 null,导致功能异常
```
### 正确做法
```java
// ✅ 方案1: 明确指定 message 参数(推荐)
return ApiResponse.success("上传成功", avatarUrl);
// 结果: {"code":200, "message":"上传成功", "data":"http://..."}
// ✅ 方案2: 使用泛型明确类型
return ApiResponse.<String>success(avatarUrl);
// ✅ 方案3: 包装为 DTO(复杂场景推荐)
return ApiResponse.success(new UploadResult(avatarUrl));
```
### 检查清单
- [ ] 返回 String 类型时,是否明确指定 message 参数
- [ ] 是否有单参数和双参数的重载方法
- [ ] 前端是否正确解析 `data` 字段(而非 `message`)
- [ ] 是否有单元测试验证响应结构
---
## 陷阱 #2: 响应字段语义不清
**场景**: `message` 和 `data` 字段职责混淆
### 规范
| 字段 | 用途 | 类型 | 示例 |
|------|------|------|------|
| `code` | 业务状态码 | int | 200, 400, 500 |
| `message` | 用户可读的提示信息 | String | "上传成功", "参数错误" |
| `data` | 业务数据 | T | `{"url": "..."}`, `[...]` |
| `timestamp` | 响应时间戳 | String | ISO 8601 格式 |
### 错误示例
```java
// ❌ 错误: 把业务数据放在 message
return ApiResponse.success("avatars/2026-04/xxx.jpeg");
// ❌ 错误: message 包含技术细节
return ApiResponse.error("NullPointerException at line 42");
```
### 正确做法
```java
// ✅ message 是用户提示,data 是业务数据
return ApiResponse.success("上传成功", avatarUrl);
// ✅ 错误信息对用户友好
return ApiResponse.error("文件格式不支持,请上传 JPG/PNG 格式");
```
---
## 陷阱 #3: 空值处理不一致
**场景**: 无数据时返回 `null`、`{}`、`[]` 不统一
### 规范
| 场景 | 推荐返回 | 说明 |
|------|---------|------|
| 单个对象不存在 | `data: null` | 前端判断 `if (!data)` |
| 列表为空 | `data: []` | 前端可直接遍历 |
| 分页数据为空 | `data: {list: [], total: 0}` | 保持结构一致 |
### 错误示例
```java
// ❌ 错误: 有时返回 null,有时返回空对象
if (user == null) {
return ApiResponse.success(null); // 不一致
}
return ApiResponse.success(new UserVO());
```
### 正确做法
```java
// ✅ 统一返回 null 表示不存在
if (user == null) {
return ApiResponse.success(null);
}
return ApiResponse.success(userVO);
// ✅ 列表统一返回空数组
List<UserVO> users = userService.list();
return ApiResponse.success(users); // 永远不返回 null
```
---
## 陷阱 #4: HTTP 状态码与业务状态码混淆
**场景**: 业务失败时返回 HTTP 500
### 规范
| 场景 | HTTP 状态码 | 业务 code | 说明 |
|------|------------|----------|------|
| 成功 | 200 | 200 | 正常响应 |
| 参数错误 | 200 | 400 | 业务层校验失败 |
| 未授权 | 401 | - | 认证失败 |
| 无权限 | 403 | - | 授权失败 |
| 资源不存在 | 200 | 404 | 业务资源不存在 |
| 服务器错误 | 500 | - | 代码异常 |
### 错误示例
```java
// ❌ 错误: 业务失败返回 HTTP 500
if (user == null) {
throw new RuntimeException("用户不存在"); // HTTP 500
}
```
### 正确做法
```java
// ✅ 业务失败返回 HTTP 200 + 业务 code
if (user == null) {
return ApiResponse.error(404, "用户不存在"); // HTTP 200
}
// ✅ 只有代码异常才返回 HTTP 500
@ExceptionHandler(Exception.class)
public ResponseEntity<ApiResponse<?>> handleException(Exception e) {
log.error("服务器错误", e);
return ResponseEntity.status(500)
.body(ApiResponse.error("服务器错误,请稍后重试"));
}
```
---
## 陷阱 #5: 生成下游产物前缺乏完整性校验(看似成功,下游静默失败)
**场景**: 导出 Excel/CSV/PDF、生成对账文件、推送第三方接口、批量通知等"产生下游消费产物"的功能,关键字段缺失时用空字符串/null/默认值兜底,文件能生成、接口能返回 200,但下游消费方(微信导入、对账系统、第三方平台)会静默失败或拒收。
### 问题根因
业务方关注"接口返回 200"和"文件生成成功",但真实成功的判断标准在**下游消费方**:
- 微信发货模板要求 `mchId` 和 `transactionId` 必须存在,缺失会拒收
- 对账文件要求每行有完整的 `订单号 / 金额 / 时间`,缺一项整批驳回
- 物流推送要求 `快递公司` 和 `快递单号` 都存在,否则物流端报错
如果生成时缺值用 `""` / `null` / `0` 兜底,调用方会以为成功,等下游消费失败时才回头排查,浪费时间且影响业务。
### 错误示例
```java
// ❌ 错误: 关键字段缺失时静默用空值兜底,Excel 能生成但微信导入失败
public byte[] export(Long tenantId, List<Long> orderIds) {
String mchId = miniAppConfigRepository.findByTenantId(tenantId)
.map(TenantMiniAppConfig::getMchId)
.orElse("");
Map<Long, PaymentRecord> paymentMap = loadPaymentMap(tenantId, orders);
for (TradeOrder order : orders) {
PaymentRecord payment = paymentMap.get(order.getId());
String transactionId = payment != null ? payment.getTransactionId() : "";
String company = packages.stream().map(ShippingPackage::getCompany)
.filter(StringUtils::hasText).distinct().collect(joining(";"));
// transactionId 为空仍会写入 Excel,微信发货模板按位置导入时会拒收
writeRow(sheet, order, mchId, transactionId, company, ...);
}
return workbook.toByteArray();
}
```
### 正确做法
**「必填字段一次画全 + 生成前预校验 + 缺失列出业务 ID + 整体失败」**
```java
public byte[] export(Long tenantId, List<Long> orderIds) {
TenantMiniAppConfig config = miniAppConfigRepository.findByTenantId(tenantId)
.orElseThrow(() -> new BusinessException("未配置小程序"));
if (!StringUtils.hasText(config.getMchId())) {
throw new BusinessException("小程序未配置微信支付商户号,无法导出");
}
Map<Long, PaymentRecord> paymentMap = loadPaymentMap(tenantId, orders);
validateRequiredFields(orders, paymentMap);
return buildWorkbook(orders, paymentMap, config.getMchId());
}
private void validateRequiredFields(List<TradeOrder> orders, Map<Long, PaymentRecord> paymentMap) {
List<String> missingTxn = new ArrayList<>();
List<String> missingPackage = new ArrayList<>();
List<String> missingCompany = new ArrayList<>();
for (TradeOrder order : orders) {
PaymentRecord payment = paymentMap.get(order.getId());
if (payment == null || !StringUtils.hasText(payment.getTransactionId())) {
missingTxn.add(order.getOrderNumber());
}
List<ShippingPackage> packages = resolvePackages(order);
if (packages.isEmpty()) {
missingPackage.add(order.getOrderNumber());
} else if (packages.stream().anyMatch(p -> !StringUtils.hasText(p.getCompany()))) {
missingCompany.add(order.getOrderNumber());
}
}
if (!missExcerpt, first 6,000 characters of SKILL.md, verbatim from the audited commit. It is text from someone else’s repository, quoted so you can judge it before your agent reads it.
Install
Pinned to the audited commit f016c89
git clone https://github.com/doccker/cc-use-exp git -C cc-use-exp checkout f016c8907732
The author documents no install command, so this uses the repository directly. Our verdict covers commit f016c8907732 only.
Works in
The author has not said which agents this skill supports, and we have not tested it in any.
Audit history
Every audit, every source change
- ✓SAFE B 89 / 100
first audit · source
f016c8907732
README badge
For maintainers · shows the latest audit
[](https://modelsatlas.com/skills/doccker/api-design-safety/)
The badge shows our verdict and grade for this skill, and links back to this page. It changes when the audit does.
Similar skills
All coding & review skills →doccker/cc-use-exp
当设计或修改 REST API 响应结构、处理 API 返回值,或生成 Excel/CSV/PDF/对账文件等下游产物时触发。防止 API 设计缺陷导致的字段错位、类型歧义,以及生成产物时关键字段缺失但静默成功的问题。
doccker/cc-use-exp
当重构涉及字段映射(dataIndex、枚举映射、类型转换)时触发。防止字段名推测错误,确保字段映射的正确性。
doccker/cc-use-exp
结构化 bug 修复工作流,适用于显式 fix 或 debug 场景;不负责语言规范、正式 review 或运维审批。
doccker/cc-use-exp
前端开发规范,包含 Vue 3 编码规范、UI 风格约束、TypeScript 规范等
doccker/cc-use-exp
Java 开发规范,包含命名约定、异常处理、Spring Boot 最佳实践等
doccker/cc-use-exp
当代码涉及循环内查询、批量 ID 查询、IN 子句、BFS/递归遍历、嵌套 service 调用时触发。防止 N+1 查询、IN 子句过长、递归内存炸裂等性能陷阱。
Add this badge to your README
[](https://modelsatlas.com/skills/doccker/api-design-safety/)
<a href="https://modelsatlas.com/skills/doccker/api-design-safety/"><img src="https://modelsatlas.com/skills/doccker/api-design-safety/badge.svg" alt="ModelsAtlas: SAFE B"></a>
Questions about Api Design Safety
What does the Api Design Safety skill do?
Is Api Design Safety safe to install?
What can Api Design Safety access on my machine?
How current is this page?
Sources
- github.com/doccker/cc-use-exp/tree/main/.cursor/skills/api-desig — the audited source at commit f016c8907732 and every finding aboveObserved · 12 Oct 2026
Spotted something wrong? Report a correction · Methodology
Keep going in your AI
Opens with this page as the source. We add nothing else to the prompt.
- What does the Api Design Safety skill do?
- Is Api Design Safety safe to install?
- What can Api Design Safety access on my machine?