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.
git clone --depth 1 https://github.com/HaiDong-Once/cursor-rules-collectionWrote 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/haidong-once/cursor-rules-collection/100-api)<a href="https://agentmods.dev/rules/haidong-once/cursor-rules-collection/100-api"><img src="https://agentmods.dev/badge/rules/haidong-once/cursor-rules-collection/100-api/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/haidong-once/cursor-rules-collection/100-api"><img src="https://agentmods.dev/badge/rules/haidong-once/cursor-rules-collection/100-api.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00000 | $0.01068 |
| Opus 5.5 | $0.00000 | $0.00427 |
| Sonnet 5.5 | $0.00000 | $0.00214 |
| Haiku 4.5 | $0.00000 | $0.00107 |
Grade A, and why
100-API 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 1mo 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 — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.
API集成规则 (100)
规则概述
本规则定义了API设计、调用和错误处理的最佳实践,旨在提高API的可用性、一致性和鲁棒性。
API设计原则
1.1 RESTful API设计
- 使用HTTP动词表示操作(GET, POST, PUT, DELETE等)
- 使用名词复数形式作为资源标识符(例如:/users, /orders)
- 使用嵌套路由表示资源关系(例如:/users/{id}/orders)
- 使用查询参数进行过滤、排序和分页
# 不推荐
GET /getUser/123
POST /createOrder
DELETE /deleteProduct/456
# 推荐
GET /users/123
POST /orders
DELETE /products/456
1.2 API版本控制
- 在URI中包含API版本(例如:/api/v1/users)
- 或通过请求头指定版本(例如:Accept: application/vnd.company.v1+json)
- 避免破坏性变更,优先使用向后兼容的设计
1.3 响应格式
- 使用一致的响应格式(通常为JSON)
- 包含状态码、数据和元数据
- 使用适当的HTTP状态码表示请求结果
// 推荐的响应格式
{
"status": 200,
"data": {
"id": 123,
"name": "示例用户"
},
"meta": {
"timestamp": "2024-05-07T12:34:56Z"
}
}
API调用实践
2.1 请求构建
- 使用专门的HTTP客户端库(例如:Axios, Fetch API, Requests)
- 设置合适的超时时间
- 实现重试机制处理临时性故障
// JavaScript示例:带有超时和重试的API请求
async function fetchWithRetry(url, options = {}, retries = 3, timeout = 5000) {
options.timeout = timeout;
try {
return await axios(url, options);
} catch (error) {
if (retries <= 0) throw error;
if (error.code === 'ECONNABORTED' || error.response?.status >= 500) {
await new Promise(r => setTimeout(r, 1000));
return fetchWithRetry(url, options, retries - 1, timeout);
}
throw error;
}
}
2.2 身份验证
- 使用OAuth 2.0或JWT进行身份验证
- 存储敏感凭据时使用安全存储机制
- 实现令牌刷新机制
- 避免在客户端存储长期有效的令牌
2.3 并发控制
- 实现请求限流和批处理
- 管理并发请求数量
- 考虑后端API限制,避免触发限流
错误处理
3.1 错误类型
区分不同类型的错误:
- 网络错误(连接失败、超时)
- 服务器错误(500系列状态码)
- 客户端错误(400系列状态码)
- 业务逻辑错误(特定错误码或消息)
3.2 错误处理策略
- 实现全局错误处理机制
- 对不同类型的错误应用不同的处理策略
- 提供有意义的错误消息给用户
- 记录详细错误信息用于调试
// JavaScript错误处理示例
try {
const response = await api.getUser(userId);
// 处理正常响应
} catch (error) {
if (error.isNetworkError) {
// 处理网络错误
showNetworkErrorMessage();
logError('Network', error);
} else if (error.status === 401) {
// 处理认证错误
redirectToLogin();
logError('Auth', error);
} else {
// 处理其他错误
showGenericErrorMessage();
logError('General', error);
}
}
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.
- 1mo ago First seen · 157 lines · 0 tokens per session scan A d6c28f550f6f
100-API is a cursor rule published in the GitHub repository HaiDong-Once/cursor-rules-collection (24 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,068 tokens. 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-30.
Other cursor rules, from other repositories
api-property-optionality-hygiene
Fix ApiProperty/ApiPropertyOptional optionality mismatches in DTO files; use for scheduled batch fixes or DTO edits.
python
Python best practices and patterns for modern software development with Flask and SQLite.
cursor
You are working on the checkout service. Preserve transaction integrity and auditability.
django
Definitive guidelines for writing maintainable, performant, and secure Django applications, emphasizing modern best practices, clear code organization, and efficient patterns.
shared-libraries
Shared libraries - condition framework, inventory containers, file-backed DB, itinerary, references.
selectools-providers
Rules for working with LLM provider adapters in selectools.