This skill provides comprehensive knowledge for building type-safe APIs with Hono, focusing on routing patterns, middleware composition, request validation, RPC client/server patterns, error handling, and context management. Use when: building APIs with Hono (any runtime), setting up request validation with Zod/Valibot/Typia/ArkType validators, creating type-safe RPC client/server communication, implementing custom middleware, handling errors with HTTPException, extending Hono context with custom variables, or encountering middleware type inference issues, validation hook confusion, or RPC performance problems. Keywords: hono, hono routing, hono middleware, hono rpc, hono validator, zod validator, valibot validator, type-safe api, hono context, hono error handling, HTTPException, c.req.valid, middleware composition, hono hooks, typed routes, hono client, middleware response not typed, hono validation failed, hono rpc type inference
Status: Production Ready ✅ Last Updated: 2025-10-22 Production Tested: Used across Cloudflare Workers, Deno, Bun, and Node.js applications
Claude Code automatically discovers this skill when you mention:
This skill provides comprehensive knowledge for building type-safe APIs with Hono, focusing on routing patterns, middleware composition, request validation, RPC client/server patterns, error handling, and context management.
✅ Routing Patterns - Route parameters, query params, wildcards, route grouping ✅ Middleware Composition - Built-in middleware, custom middleware, chaining strategies ✅ Request Validation - Zod, Valibot, Typia, ArkType validators with custom error hooks ✅ Typed Routes (RPC) - Type-safe client/server communication with full type inference ✅ Error Handling - HTTPException, onError hooks, custom error responses ✅ Context Extension - c.set/c.get patterns, custom context types, type-safe variables
| Issue | Why It Happens | Source | How Skill Fixes It |
|-------|---------------|---------|-------------------|
| RPC Type Inference Slow | Complex type instantiation from many routes | hono#guides/rpc | Use route variable pattern: const route = app.get(...) |
| Middleware Response Not Typed | RPC mode doesn't infer middleware responses | hono#2719 | Export specific route types for RPC client |
| Validation Hook Confusion | Multiple validator libraries, different hook patterns | Context7 research | Provides consistent patterns for all validators |
| HTTPException Misuse | Throwing errors without proper status/message | Official docs | Shows proper HTTPException patterns |
| Context Type Safety | c.set/c.get without proper typing | Official docs | Demonstrates type-safe context extension |
| Error After Next | Not checking c.error after middleware | Official docs | Shows proper error checking pattern |
| Query/Param Validation | Direct access without validation | Official docs | Always use c.req.valid() after validation |
| Middleware Order | Incorrect middleware execution order | Official docs | Explains middleware flow and chaining |
cloudflare-worker-base instead)cloudflare-nextjs or Next.js docs)cloudflare-d1, cloudflare-kv, etc.)clerk-auth or other auth skills)import { Hono } from 'hono'
import { zValidator } from '@hono/zod-validator'
import { z } from 'zod'
const app = new Hono()
// Route with validation
const schema = z.object({
name: z.string(),
age: z.number(),
})
app.post('/user', zValidator('json', schema), (c) => {
const data = c.req.valid('json')
return c.json({ success: true, data })
})
// Type-safe RPC export
export type AppType = typeof app
Result: Fully type-safe API with validation, ready for RPC client
Full instructions: See SKILL.md
| Approach | Tokens Used | Errors Encountered | Time to Complete | |----------|------------|-------------------|------------------| | Manual Setup | ~8,000 | 3-5 | ~2-3 hours | | With This Skill | ~3,500 | 0 ✅ | ~15 minutes | | Savings | ~56% | 100% | ~85% |
| Package | Version | Status | |---------|---------|--------| | hono | 4.10.2 | ✅ Latest stable | | zod | 4.1.12 | ✅ Latest stable | | valibot | 1.1.0 | ✅ Latest stable | | @hono/zod-validator | 0.7.4 | ✅ Latest stable | | @hono/valibot-validator | 0.5.3 | ✅ Latest stable | | @hono/typia-validator | 0.1.2 | ✅ Latest stable | | @hono/arktype-validator | 2.0.1 | ✅ Latest stable |
Prerequisites: None (framework-agnostic)
Integrates With:
hono-routing/
├── SKILL.md # Complete documentation
├── README.md # This file
├── templates/
│ ├── routing-patterns.ts # Route params, query, wildcards
│ ├── middleware-composition.ts # Middleware chaining, built-ins
│ ├── validation-zod.ts # Zod validation with hooks
│ ├── validation-valibot.ts # Valibot validation
│ ├── rpc-pattern.ts # Type-safe RPC client/server
│ ├── error-handling.ts # HTTPException, onError, custom
│ ├── context-extension.ts # c.set/c.get, custom types
│ └── package.json # All dependencies
├── references/
│ ├── middleware-catalog.md # Built-in Hono middleware
│ ├── validation-libraries.md # Zod vs Valibot vs others
│ ├── rpc-guide.md # RPC pattern deep dive
│ └── top-errors.md # Common errors + solutions
└── scripts/
└── check-versions.sh # Verify package versions
/llmstxt/hono_dev_llms-full_txtFound an issue or have a suggestion?
MIT License - See main repo LICENSE file
Production Tested: Cloudflare Workers, Deno, Bun, Node.js Token Savings: ~56% Error Prevention: 100% Ready to use! See SKILL.md for complete setup.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer