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/lawofall/agentcore/apigit clone --depth 1 https://github.com/Lawofall/AgentCoreWhat 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.00000 | $0.00835 |
| Opus 5 | $0.00000 | $0.00417 |
| Sonnet 5 | $0.00000 | $0.00167 |
| Haiku 4.5 | $0.00000 | $0.00084 |
Grade A, and why
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 2d 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.
What it actually says
API 开发规范
路由
- 所有路由注册在
main.py,统一prefix="/v1" - Router 是薄层:参数解析 → 调用 service → 返回结果
- 分页参数:
page: int = Query(1, ge=1),page_size: int = Query(20, ge=1, le=100) - 删除操作返回
{"status": "ok"} - RESTful 命名:
GET /list、POST /create、PUT /{id}全量、PATCH /{id}部分、DELETE /{id}
Schema 命名
| 类型 | 命名模式 |
|---|---|
| 列表项 / 详情 | {Resource}Summary / {Resource}Detail |
| 列表响应 | {Resource}ListResponse(data + total) |
| 创建 / 更新 | Create{Resource}Request / Update{Resource}Request |
- 主键统一
id,外键{entity}_id,更新请求所有字段可选 - 列表响应包含
data、total、page、page_size - 时间字段序列化为 ISO 8601
- 前端 TS 类型从 OpenAPI 生成,禁止手写(单一真相源 =
schemas.py)。改 schema 后在仓库根跑pnpm gen:types一条命令:它先 dumpapps/server/openapi.json,再经 openapi-typescript 生成packages/contract-rest-types/src/api.generated.ts(各端src/**/types/api.generated.ts只是三行透传再导出,没有独立生成脚本)。生成物入仓——CI 跑同一命令后git diff --exit-code挡漂移,故改完必须一并提交;*.generated.ts免 lint(biome ignore),无 postinstall 自动重生成。service 文件用type X = components["schemas"]["X"]取别名引用。 - ✅ 已迁移:所有 service 的 REST 类型均用生成类型别名(
type X = components["schemas"]["X"]);新增/改动一律走生成类型,勿新增手写 REST 类型。纯 SSE/事件载荷与客户端域模型(camelCase,经toX映射)不受此约束。例外:端点无response_model(如/readyz、/version)时生成类型为无类型字典,保留手写并加注。带默认值的字段在生成类型里是可选(?),读取处按需?? 兜底。
认证 & 权限
- 注入:
AuthUser(必须登录)/OptionalUser(可选)→ 见agentcore.deps - 权限在 service 层校验,不在 router 层
错误处理
- 使用
agentcore.common.errors:not_found/forbidden/bad_request - 统一响应:
{"error": {"code": N, "message": "...", "detail": "..."}}
Service 层
- ID 生成
str(uuid4()) - ORM → Pydantic 转换放 service 私有方法
- 写操作先查再改(验证存在性和权限)
- 软删除检查:
if not entity or entity.deleted_at: raise not_found(...)
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.
- 2d ago First seen · 51 lines · 0 tokens per session scan A a34217ce9452
api is a cursor rule published in the GitHub repository Lawofall/AgentCore (78 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 835 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
code-patterns
Python code style and recurring patterns (config, logging, errors, paths).
project-overview
Core project architecture, patterns, and conventions for the AI Documentation Generator.
cursorrules
You are an AI agent building the module: {{MODULENAME}} This module is part of the Mnemosyne Neural OS ecosystem by XPACEGEMS LLC.
backend-python
Python and FastAPI standards for the backend.
core-project-context
Canonical project context and ownership rules.
dashboard-typescript
React and TypeScript standards for the operator dashboard.