app_layer_rules

A set of rules for FastAPI application modules that receive web requests and return HTTP responses.

In plain words
What is it for?
Implementing or reviewing API endpoints in backend/apps, including routes, input validation, service calls, domain-error handling, configuration access, and JSON responses.
Why use it?
It keeps the web boundary focused on validating input, calling services, and translating errors instead of putting core business logic in endpoint code.

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/modelengine-group/nexent/app_layer_rules
Clone the repo
git clone --depth 1 https://github.com/ModelEngine-Group/nexent

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,420 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.00000 $0.01420
Opus 5 $0.00000 $0.00710
Sonnet 5 $0.00000 $0.00284
Haiku 4.5 $0.00000 $0.00142

Measured yesterday against content hash 108d98af8447, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

app_layer_rules 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 yesterday.

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.

.cursor/rules/backend/app_layer_rules.mdc · 114 lines

How it starts

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

Purpose and Scope

  • The App layer is the HTTP boundary for the backend. It applies to files under backend/apps/*.py.
  • Responsibilities:
    • Parse and validate HTTP inputs.
    • Call underlying services; do not implement core business logic here.
    • Translate domain/service exceptions into HTTPException with proper status codes.
    • Return JSONResponse(status_code=HTTPStatus.OK, content=payload) on success.
  • Configuration: Do not access environment variables directly. Read configuration via consts.const or pass values through from the request to services.

References: backend/consts/exceptions.py

Routing and URL Design

  • Keep existing top-level prefixes for compatibility (e.g., "/agent", "/memory"). When adding new modules or endpoints, follow these rules:
    • Use plural nouns for collection-style resources (e.g., "/agents", "/memories").
    • Use snake_case for all path segments. Avoid hyphens and camelCase.
    • Prefer resource-oriented paths for CRUD-style operations. Example: "/agents" (collection), "/agents/{agent_id}" (single resource).
    • Use action-style paths only when necessary to match current patterns or when the operation is not naturally CRUD (e.g., "/agent/run", "/agent/stop/{conversation_id}").
    • Path parameters must be singular, semantic nouns: "/agents/{agent_id}", "/memories/{memory_id}".
    • Keep backwards compatibility: do not rename existing routes; new routes should follow these conventions.

HTTP Methods

  • GET: Read and list operations only. Maintain existing special cases where GET performs safe actions (e.g., GET /agent/stop/{conversation_id}), but do not introduce new side-effecting GETs.
  • POST: Create resources, perform searches, or trigger actions with side effects (e.g., POST /memory/add, POST /memory/search, POST /agent/run).
  • DELETE: Delete resources or clear collections (e.g., DELETE /memory/clear). Ensure idempotency.
  • PUT/PATCH: Update resources. Prefer PUT for full updates and PATCH for partial updates. Preserve legacy POST /update endpoints for compatibility but favor PUT/PATCH for new code.

Read the full file on GitHub · 114 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. yesterday First seen · 114 lines · 0 tokens per session scan A 108d98af8447

Subscribe to this mod's changes

app_layer_rules is a cursor rule published in the GitHub repository ModelEngine-Group/nexent (5,841 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,420 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.