hono

A set of coding rules for Hono, a small web framework for JavaScript and TypeScript applications, including services deployed at the edge. It covers routes, middleware, and application structure.

In plain words
What is it for?
Use it when defining API routes, route groups, URL parameters, middleware, CORS, logging, redirects, and not-found responses.
Why use it?
It keeps route code easy to extend and makes important request steps, such as authentication and security headers, run in the right order.

Cursor rule

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/nedcodes-ok/cursorrules-collection/hono
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 669 This file is loaded in full into every session.
When invoked 669 The same file — it is already loaded in full.
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.00669 $0.00669
Opus 5 $0.00334 $0.00334
Sonnet 5 $0.00134 $0.00134
Haiku 4.5 $0.00067 $0.00067

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

Security

Grade A, and why

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

rules-mdc/frameworks/hono.mdc · 61 lines

How it starts

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

Hono Cursor Rules

You are an expert in the Hono web framework. Follow these rules:

App Structure

  • Create the app with new Hono() and export default app (or export default { fetch: app.fetch })
  • Group related routes with app.route('/api/users', usersRoute)
  • Define route files as separate Hono instances: const route = new Hono()
  • Use app.basePath('/api/v1') for API versioning
  • Keep the main app file thin — just mounting route groups and global middleware

Routing

  • Use path parameters with type validation: app.get('/users/:id{[0-9]+}', handler)
  • Chain methods for same-path different-methods: app.get('/users', list).post('/users', create)
  • Use c.req.param('id') for path params, c.req.query('page') for query strings
  • Return responses with c.json(), c.text(), c.html() — never raw Response unless needed
  • Use c.notFound() and c.redirect() helpers

Middleware

  • Write middleware as: async (c, next) => { /* before / await next(); / after */ }
  • Use Hono's built-in middleware: cors(), logger(), prettyJSON(), secureHeaders()
  • Apply middleware to route groups, not globally when possible
  • Order matters: auth middleware before route handlers, CORS before everything
  • Use c.set('user', user) and c.get('user') for passing data through middleware

Validation

  • Use Hono's validator with Zod: validator('json', schema) or @hono/zod-validator
  • Validate params, query, json, and headers separately
  • Return 400 with clear error messages on validation failure
  • Type the validated data — Hono infers types from validators automatically

Edge/Runtime Patterns

  • Keep handlers stateless — no in-memory caches that assume single-instance
  • Use c.env to access runtime bindings (Cloudflare Workers: D1, KV, R2)
  • Use c.executionCtx.waitUntil() for background tasks that shouldn't block response
  • Keep cold start minimal: lazy-import heavy dependencies

Error Handling

  • Use app.onError() for global error handling — return proper JSON error responses
  • Use HTTPException for expected errors: throw new HTTPException(404, { message: 'Not found' })
  • Never expose stack traces in production error responses
  • Log errors in onError before returning the response

Read the full file on GitHub · 61 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 · 61 lines · 669 tokens per session scan A 4f50342dc956

Subscribe to this mod's changes

hono is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 669 tokens to every session, about $0.0033 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.