What the agent does
The agent clones the repository into its own cloud sandbox and reads how the routes are declared, because Hono's RPC client only sees routes that are chained. In the blog example of honojs/examples, src/api.ts registers GET /posts, POST /posts, GET, PUT and DELETE /posts/:id as separate statements on const api = new Hono<{ Bindings: Bindings }>(), so typeof api carries no route information. src/index.ts mounts it twice under /api, once as a middleware app that adds prettyJSON and basic auth on every non-GET request to /posts/*, and once as the routes. src/model.ts stores each Post in the BLOG_EXAMPLE KV namespace under a v1:post: prefix, and package.json has hono ^4.2.4, wrangler ^3.53.0 and Vitest 1.3.0 running through @cloudflare/vitest-pool-workers.
The repository already shows the target shape. pages-stack/functions/api/[[route]].ts writes const route = app.get('/hello', zValidator('query', ...), handler), exports type AppType = typeof route, and pages-stack/src/App.tsx calls hc<AppType>('/') and reads the response through InferResponseType. The agent applies that to the blog: it turns the five registrations into one chain assigned to routes, exports AppType = typeof routes, and adds @hono/zod-validator and zod so POST and PUT read c.req.valid('json') instead of await c.req.json() cast to model.Param. That gives the client a typed request body as well as a typed response.
It also fixes what the types reveal. PUT /posts/:id and DELETE /posts/:id return a bare new Response(null, { status: 204 }) when the post is missing, which the client cannot type, so the agent returns c.body(null, 204) and gives every c.json call an explicit status, so InferResponseType distinguishes the 201 post from the 422 error. Then it adds src/client.ts, a hc<AppType>(baseUrl, init) factory for other Workers and front ends to import, with a note that callers of non-GET routes must pass the basic auth header that index.ts enforces.
Finally it rewrites src/api.test.ts, which today calls worker.request('/posts', {}, env) and casts every body, to use testClient from hono/testing with the same env from cloudflare:test: client.posts.$post({ json: { title, body } }) and client.posts[':id'].$get({ param: { id } }), with no casts, so a route change that breaks the client fails the test. It runs npm -w blog run test and npx tsc --noEmit against the blog's tsconfig.json, and opens a pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a typed RPC client to this Hono API. Read every file under src, package.json, tsconfig.json, vitest.config.ts and the wrangler config first. Chain the route registrations so their types are exported as AppType, add @hono/zod-validator schemas for the JSON bodies of POST and PUT, give every response an explicit status code so InferResponseType can tell success from error, and add a src/client.ts that returns hc<AppType> for a base URL. Rewrite the existing Vitest tests to call the routes through testClient from hono/testing with no casts. Run the tests and a type check, and open a pull request that shows one client call with its inferred response type.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch. The diff chains src/api.ts, adds the two Zod schemas, exports AppType, adds src/client.ts, updates src/api.test.ts to the typed client and adds @hono/zod-validator and zod to package.json and the lockfile. The description shows one client.posts.$get() call with the response type the editor infers from it.
The run's record keeps the Vitest output under the Workers pool, with each route test named, and the tsc output, so a reviewer sees that the chain compiles and that the tests pass against the KV binding the pool provides. No deployment happens and no KV namespace is touched outside the test.
Before merging, a reviewer checks that the chain still mounts under /api the same way, that the basic auth middleware in index.ts still covers writes, since testClient exercises api directly and skips it, and that any external caller of the old loose response shapes is updated to the explicit status codes.
Run it on every new route file
In the console, an automation with a github trigger on pull_request.opened and pull_request.synchronize starts one run per pull request and per push to it, in the Project that has the repository, with the event appended after the prompt. The prompt asks the agent to stop when the diff touches no route, and otherwise to check that the new route is in the chain, has a validator and is covered by a typed test, and to push the fix to the branch or leave a review comment.
From your own server, each Hono service is one POST /o/{org}/sessions with the repository in resources and a request_id. The API key's webhook receives run.completed with the session_url when a turn ends, so a script can collect the pull request links for every service that got a client.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Whether a chain actually exports usable types is something only a compiler and a test run can tell you, and the failure modes are quiet: an unchained route simply does not exist on the client. The sandbox installs the workspace, runs Vitest inside the Workers pool and the TypeScript check, and keeps both outputs, so the pull request carries the proof rather than a claim.
The change crosses the routes, the validators, the client and the tests, and it has to land together. One run returns one pull request with all four and its log, and the same prompt runs against every Hono service an organisation has at once, each in its own sandbox with its own wrangler config.
Frequently asked questions
Does the client work from a browser as well as another Worker?
Yes. hc wraps fetch, so a React front end calls hc<AppType>('/') as pages-stack does, and a Worker passes a service binding's fetch through the second argument. Only the type import crosses the boundary, so no server code ships to the client bundle.
Why add Zod when the handlers already check the fields?
model.createPost returns nothing when title or body is missing, but the client cannot see that from a cast. A zValidator('json', schema) gives $post a typed json argument and answers a malformed body with 400 before the handler runs, so the check moves to the edge and into the types.
Will the chain break the mounting in index.ts?
No. app.route('/api', api) takes the same Hono instance, chained or not. The agent keeps the default export and adds a named routes export for the type, and the test still imports the app the same way.
Does it change the basic auth?
No. The auth middleware stays in index.ts on non-GET requests to /api/posts/*. The client factory documents that $post, $put and $delete need the Authorization header, and the tests call api directly, as the existing tests do, so they run without credentials.
More Hono jobs
More jobs like this: Hand off a long task
- Add an RSS Feed to a Contentlayer Blog (Contentlayer)
- Add an RSS Feed to a Starlight Docs Site (Starlight)
- Add an RSS Feed to a SvelteKit App (SvelteKit)