backend-api

Backend API rules for a server built with Hono, Drizzle ORM, PostgreSQL, and Better Auth. An API lets software exchange data, while an ORM helps code work with a database.

In plain words
What is it for?
Use them when adding API features, organizing routes and controllers, validating requests, querying PostgreSQL, and documenting responses.
Why use it?
They keep routes, validation, database access, authentication, and API documentation consistent across the project.

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/usekaneo/kaneo/backend-api
Clone the repo
git clone --depth 1 https://github.com/usekaneo/kaneo

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,524 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.01524
Opus 5 $0.00000 $0.00762
Sonnet 5 $0.00000 $0.00305
Haiku 4.5 $0.00000 $0.00152

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

Security

Grade A, and why

backend-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 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-api.mdc · 248 lines

How it starts

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

Backend API Guidelines

The Kaneo API is built with Hono, Drizzle ORM, PostgreSQL, and Better Auth. This document outlines conventions and patterns for backend development.

Framework: Hono

Hono is a lightweight web framework. Follow these patterns:

Route Structure

Routes are organized by feature in apps/api/src/:

// apps/api/src/task/index.ts
import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
import createTask from "./controllers/create-task";
import getTask from "./controllers/get-task";

const task = new Hono<{
  Variables: {
    userId: string;
  };
}>()
  .get(
    "/:id",
    describeRoute({
      operationId: "getTask",
      tags: ["Tasks"],
      description: "Get a specific task by ID",
      responses: {
        200: {
          description: "Task details",
          content: {
            "application/json": { schema: resolver(taskSchema) },
          },
        },
      },
    }),
    validator("param", v.object({ id: v.string() })),
    async (c) => {
      const { id } = c.req.valid("param");
      const task = await getTask(id);
      return c.json(task);
    },
  );

export default task;

Best Practices

  1. Always use OpenAPI decorators: Use describeRoute for all endpoints
  2. Validate inputs: Use validator with Valibot schemas
  3. Extract controllers: Keep route handlers thin, move logic to controller files
  4. Type safety: Use Hono's type system for context variables
// Good: Thin route handler
.get("/:id", validator("param", v.object({ id: v.string() })), async (c) => {
  const { id } = c.req.valid("param");
  const task = await getTask(id);
  return c.json(task);
})

// Bad: Business logic in route handler
.get("/:id", async (c) => {
  const id = c.req.param("id");
  const task = await db.select().from(taskTable).where(eq(taskTable.id, id));
  // ... more logic
  return c.json(task);
})

Database: Drizzle ORM

Read the full file on GitHub · 248 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 · 248 lines · 0 tokens per session scan A f04d4bca484f

Subscribe to this mod's changes

backend-api is a cursor rule published in the GitHub repository usekaneo/kaneo (8,786 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,524 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.