hono-gateway

hono-gateway is a cursor rule for Cursor from louisbrulenaudet/monorepo-template. It costs 0 tokens per session (1,802 once invoked), scanned A, original, Apache-2.0.

Rules for building Hono HTTP gateway Workers, which are small server programs that handle web requests on Cloudflare. They define the order of request checks and how routes call other services.

In plain words
What is it for?
They guide middleware order, request IDs, security headers, cross-origin access, CSRF protection, body limits, input validation, thin handlers, and service bindings.
Why use it?
They keep request handling consistent and ensure security, validation, limits, timeouts, and logging happen before business logic.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit They guide middleware order, request IDs, security headers, cross-origin access, CSRF protection, body limits, input validation, thin handlers, and service bindings.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/louisbrulenaudet/monorepo-template/hono-gateway
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.

Clone the repo
git clone --depth 1 https://github.com/louisbrulenaudet/monorepo-template

Made for: Cursor.

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

agentmods badge for hono-gateway

README.md
[![agentmods](https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/hono-gateway/github.svg)](https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/hono-gateway)
Your own site
<a href="https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/hono-gateway"><img src="https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/hono-gateway/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.

agentmods 80×15 button for hono-gateway

Your own site · 80×15
<a href="https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/hono-gateway"><img src="https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/hono-gateway.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,802 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01802
Opus 5 $0.00000 $0.00901
Sonnet 5 $0.00000 $0.00360
Haiku 4.5 $0.00000 $0.00180

Measured 11d ago against content hash 708f7890a854, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

hono-gateway 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 11d 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.

.cursor/rules/backend/hono-gateway.mdc · 91 lines

How it starts

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

Hono Gateway (Workers) Rules

worker-api and sibling worker-* / webhook-* apps use Hono on Cloudflare Workers. For deep patterns load the hono and workers-best-practices skills.

Request lifecycle

flowchart TD
  Client["Client / front-app"] --> ReqId["request-id"]
  ReqId --> Sec["secure headers"]
  Sec --> CORS["CORS (/api/*)"]
  CORS --> CSRF["CSRF (unsafe methods)"]
  CSRF --> Timing["timing (dev only)"]
  Timing --> Timeout["timeout"]
  Timeout --> Body["body limit"]
  Body --> Validation["zValidator at boundary"]
  Validation --> Handler["thin route handler"]
  Handler --> Binding["service binding (optional)"]
  Handler --> Response["c.json()"]

Middleware order (src/index.ts)

Register in this order. The onion model runs "before" logic top-down and "after" logic (response mutation) bottom-up.

Root app (every route):

  1. requestId() (hono/request-id) - first, so every error log and response can reference it. Sets c.get("requestId") and echoes the X-Request-Id response header. Add RequestIdVariables to the Hono generic's Variables so c.get("requestId") is typed.
  2. secureHeaders() (hono/secure-headers) - HSTS, nosniff, no-referrer, COOP/CORP on by default (and X-Powered-By removed). Add a locked-down contentSecurityPolicy (default-src 'none'; frame-ancestors 'none') - harmless for JSON, hardening if a response is ever rendered. Set permissionsPolicy to deny camera/mic/geolocation/payment. CORP same-origin is fine for CORS-mode fetch from front-app; do not disable it to fix SPA reads.
  3. cors() on /api/* - preflight OPTIONS must clear before auth/routes. Read the allowlist from c.env.CORS_ORIGINS per request (env is not available at module scope on Workers). Put X-Request-Id in exposeHeaders so browsers can read the id. Empty allowlist is permissive (*) in dev only; any other ENVIRONMENT (including staging / production and typos) must set origins or /api/* returns 503.
  4. Origin / CSRF gate on /api/* - unsafe methods only (any Content-Type, including application/json); must not block CORS preflight. Allows when Origin is on the allowlist or Sec-Fetch-Site is same-origin / same-site. Hono built-in csrf() only covers form content-types - do not rely on it alone for this JSON SPA gateway.

Read the full file on GitHub · 91 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. 11d ago First seen · 91 lines · 0 tokens per session scan A 708f7890a854

Subscribe to this mod's changes

hono-gateway is a cursor rule published in the GitHub repository louisbrulenaudet/monorepo-template (19 stars, last pushed 10d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,802 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.