Skip to Content
hono-bento

Working with agents

Why the layout suits coding agents, and the files and endpoints that help them.

hono-bento's layout is designed so a coding agent can work in it without exploring the codebase first. Each convention answers a question an agent would otherwise have to search for:

QuestionAnswer
Where is PATCH /v1/todos/:id?Its contract in features/todos/spec.ts, its handler in the <operation>.ts it names.
Where does a new endpoint go?A contract in that feature's spec.ts and a handler file beside it.
What types does a handler use?Its contract's: defineHandler<Session, typeof contracts.<operation>>.
Where do request shapes go?packages/schemas/src/<feature>.ts.
How do I register a new feature?One line in specs.ts.
What may this code import?Its own folder, app-level code and packages. Never another feature.

Because a change stays inside one folder, an agent's diff is small and easy to review. And because the rules are tested, an agent that breaks one finds out at once, from a message that tells it what to do.

Give your app an AGENTS.md

The example ships an AGENTS.md written to be copied into your app. It has the layout, the rules, and step-by-step checklists for adding an endpoint and adding a feature. Most coding agents read AGENTS.md automatically. For Claude Code, add a CLAUDE.md that imports it:

CLAUDE.md
@AGENTS.md

Let the checks do the reviewing

hono-bento check, run by the example's structure.test.ts, fails with instructions, not just assertions:

src/features/projects/create.ts handler-file: Put the handler for POST /v1/projects/ in this file.

Tell agents to run the tests before they finish. A layout mistake then gets fixed in the same session rather than in code review.

Type errors that say what's wrong

When a handler drifts from its route, route() reports the problem in words, with what the route provides next to what the handler declares:

Type 'RouteHandler<Session, ...>' is not assignable to type 'HandlerMismatch<"The route allows anonymous
callers, so the handler must accept a null identity: declare it with defineHandler<Identity | null>, or from
this route's contract.", Session | null, Session>'.

Startup checks

Some mistakes are caught when the app boots, before any request:

  • mountSpecs throws if two routes share a method and path, or an operation id. That's what happens when a feature folder is copied without being renamed.
  • Routes that require scopes throw if no authorizer is configured, so a missing permission check can't ship unnoticed.
  • A route that names an unregistered strategy, needs authentication with no strategies configured, or allows anonymous callers while requiring scopes, throws too.

And with validateResponses on in tests, a handler whose response doesn't match its documented schema fails its feature test.

These docs, for agents

This site serves machine-readable versions of every page:

  • /llms.txt is an index of every page.
  • /llms-full.txt has the full text of the docs in one file.
  • Any docs page with .md appended, such as /docs/layout.md, returns that page as Markdown. Requests that prefer text/markdown get Markdown from the normal URL too.

Point your agent at https://honobento.com/llms-full.txt when it's building with hono-bento for the first time.

On this page