overview

A set of backend development rules covering how an application is divided into controllers, services, repositories, models, and a database. It also describes common API response formats, status codes, authentication, and authorization.

In plain words
What is it for?
Use it when planning backend layers, REST-style API routes, response bodies, HTTP status codes, or access-control mechanisms.
Why use it?
It provides shared conventions for designing backend code and HTTP APIs, making responsibilities and error handling clearer.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/zenobia000/cursor-agentic-coding-template/overview
Clone the repo
git clone --depth 1 https://github.com/Zenobia000/cursor-agentic-coding-template

Made for: Cursor.

Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,667 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.01667
Opus 5 $0.00012 $0.00834
Sonnet 5 $0.00005 $0.00333
Haiku 4.5 $0.00002 $0.00167

Measured 2d ago against content hash 8e9d05145857, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

overview 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • overview — 100% identical, 0 lines differ
.cursor/rules/backend/overview.mdc · 257 lines

How it starts

The opening of the file, as written. The whole thing — 257 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🏗️ 後端架構

分層架構

Controller → Service → Repository → Database
    ↓           ↓           ↓
   DTO      Business    Entity/Model
            Logic

職責分離

  • Controller: 處理 HTTP 請求/回應
  • Service: 業務邏輯處理
  • Repository: 資料存取層
  • Model: 資料模型定義

🔐 API 設計

RESTful 原則

// ✅ Good
GET    /api/users       // 列表
GET    /api/users/:id   // 詳情
POST   /api/users       // 創建
PUT    /api/users/:id   // 完整更新
PATCH  /api/users/:id   // 部分更新
DELETE /api/users/:id   // 刪除

// ❌ Bad
GET /api/getUserList
POST /api/deleteUser

回應格式

// 成功回應
{
  "success": true,
  "data": { /* actual data */ },
  "meta": {
    "timestamp": "2024-01-01T00:00:00Z",
    "version": "1.0.0"
  }
}

// 錯誤回應
{
  "success": false,
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "User not found",
    "details": { /* additional info */ }
  }
}

狀態碼使用

  • 200 OK: 成功取得資源
  • 201 Created: 成功創建資源
  • 204 No Content: 成功但無內容
  • 400 Bad Request: 請求參數錯誤
  • 401 Unauthorized: 未認證
  • 403 Forbidden: 無權限
  • 404 Not Found: 資源不存在
  • 422 Unprocessable Entity: 驗證失敗
  • 500 Internal Server Error: 伺服器錯誤

🛡️ 安全措施

認證授權

  • JWT Token: 無狀態認證
  • Refresh Token: 長期有效性
  • 權限檢查: RBAC/ABAC
  • Session 管理: Redis 儲存

資料驗證

// 使用 Zod 驗證
const createUserSchema = z.object({
  email: z.string().email(),
  password: z.string().min(8),
  name: z.string().min(2).max(50),
  age: z.number().min(0).max(150)
})

// 中間件驗證
const validate = (schema) => (req, res, next) => {
  try {
    schema.parse(req.body)
    next()
  } catch (error) {
    res.status(422).json({ error })
  }
}

SQL 注入防護

// ✅ Good: 參數化查詢
const user = await db.query(
  'SELECT * FROM users WHERE id = $1',
  [userId]
)

// ❌ Bad: 字串串接
const user = await db.query(
  `SELECT * FROM users WHERE id = ${userId}`
)

💾 資料庫設計

Schema 設計原則

  • 正規化: 至少到 3NF
  • 索引策略: 查詢欄位建立索引
  • 軟刪除: deleted_at 欄位
  • 審計欄位: created_at, updated_at, created_by

Read the full file on GitHub · 257 lines

Changes

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.

  1. 2d ago First seen · 257 lines · 24 tokens per session scan A 8e9d05145857

Subscribe to this mod's changes

overview is a cursor rule published in the GitHub repository Zenobia000/cursor-agentic-coding-template (30 stars, last pushed 2mo ago), licensed MIT. It adds 24 tokens to every session and 1,667 once invoked, about $0.0001 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-30.