[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AN2Z2BFD67SMFZAYP5MHJA":3,"skill-same:01M7AN2Z2BFD67SMFZAYP5MHJA":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":5,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M7AN2Z2BFD67SMFZAYP5MHJA","hono-routing",null,"This skill provides comprehensive knowledge for building type-safe APIs with Hono, focusing on routing patterns, middleware composition, request validation, RPC client\u002Fserver patterns, error handling, and context management.\n\nUse when: building APIs with Hono (any runtime), setting up request validation with Zod\u002FValibot\u002FTypia\u002FArkType validators, creating type-safe RPC client\u002Fserver 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.\n\nKeywords: 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","davidanthonyn\u002Fclaude-skills","davidanthonyn","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F55152980?v=4","01M7AJ4MY8S5C2RJCGX6626J0G","01M7AJ7JE1K98GRPH9Z57Z0R0W",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fhono-routing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: hono-routing\ndescription: |\n  This skill provides comprehensive knowledge for building type-safe APIs with Hono, focusing on routing patterns, middleware composition, request validation, RPC client\u002Fserver patterns, error handling, and context management.\n\n  Use when: building APIs with Hono (any runtime), setting up request validation with Zod\u002FValibot\u002FTypia\u002FArkType validators, creating type-safe RPC client\u002Fserver 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.\n\n  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\n\nlicense: MIT\n---\n\n# Hono Routing & Middleware\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-10-22\n**Dependencies**: None (framework-agnostic)\n**Latest Versions**: hono@4.10.2, zod@4.1.12, valibot@1.1.0, @hono\u002Fzod-validator@0.7.4, @hono\u002Fvalibot-validator@0.5.3\n\n---\n\n## Quick Start (15 Minutes)\n\n### 1. Install Hono\n\n```bash\nnpm install hono@4.10.2\n```\n\n**Why Hono:**\n- **Fast**: Built on Web Standards, runs on any JavaScript runtime\n- **Lightweight**: ~10KB, no dependencies\n- **Type-safe**: Full TypeScript support with type inference\n- **Flexible**: Works on Cloudflare Workers, Deno, Bun, Node.js, Vercel\n\n### 2. Create Basic App\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\napp.get('\u002F', (c) => {\n  return c.json({ message: 'Hello Hono!' })\n})\n\nexport default app\n```\n\n**CRITICAL:**\n- Use `c.json()`, `c.text()`, `c.html()` for responses\n- Return the response (don't use `res.send()` like Express)\n- Export app for runtime (Cloudflare Workers, Deno, Bun, Node.js)\n\n### 3. Add Request Validation\n\n```bash\nnpm install zod@4.1.12 @hono\u002Fzod-validator@0.7.4\n```\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\napp.post('\u002Fuser', zValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Why Validation:**\n- Type-safe request data\n- Automatic error responses\n- Runtime validation, not just TypeScript\n\n---\n\n## The 6-Part Hono Mastery Guide\n\n### Part 1: Routing Patterns\n\n#### Basic Routes\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\n\u002F\u002F GET request\napp.get('\u002Fposts', (c) => c.json({ posts: [] }))\n\n\u002F\u002F POST request\napp.post('\u002Fposts', (c) => c.json({ created: true }))\n\n\u002F\u002F PUT request\napp.put('\u002Fposts\u002F:id', (c) => c.json({ updated: true }))\n\n\u002F\u002F DELETE request\napp.delete('\u002Fposts\u002F:id', (c) => c.json({ deleted: true }))\n\n\u002F\u002F Multiple methods\napp.on(['GET', 'POST'], '\u002Fmulti', (c) => c.text('GET or POST'))\n\n\u002F\u002F All methods\napp.all('\u002Fcatch-all', (c) => c.text('Any method'))\n```\n\n**Key Points:**\n- Always return a Response (c.json, c.text, c.html, etc.)\n- Routes are matched in order (first match wins)\n- Use specific routes before wildcard routes\n\n#### Route Parameters\n\n```typescript\n\u002F\u002F Single parameter\napp.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n  return c.json({ userId: id })\n})\n\n\u002F\u002F Multiple parameters\napp.get('\u002Fposts\u002F:postId\u002Fcomments\u002F:commentId', (c) => {\n  const { postId, commentId } = c.req.param()\n  return c.json({ postId, commentId })\n})\n\n\u002F\u002F Optional parameters (using wildcards)\napp.get('\u002Ffiles\u002F*', (c) => {\n  const path = c.req.param('*')\n  return c.json({ filePath: path })\n})\n```\n\n**CRITICAL:**\n- `c.req.param('name')` returns single parameter\n- `c.req.param()` returns all parameters as object\n- Parameters are always strings (cast to number if needed)\n\n#### Query Parameters\n\n```typescript\napp.get('\u002Fsearch', (c) => {\n  \u002F\u002F Single query param\n  const q = c.req.query('q')\n\n  \u002F\u002F Multiple query params\n  const { page, limit } = c.req.query()\n\n  \u002F\u002F Query param array (e.g., ?tag=js&tag=ts)\n  const tags = c.req.queries('tag')\n\n  return c.json({ q, page, limit, tags })\n})\n```\n\n**Best Practice:**\n- Use validation for query params (see Part 4)\n- Provide defaults for optional params\n- Parse numbers\u002Fbooleans from query strings\n\n#### Wildcard Routes\n\n```typescript\n\u002F\u002F Match any path after \u002Fapi\u002F\napp.get('\u002Fapi\u002F*', (c) => {\n  const path = c.req.param('*')\n  return c.json({ catchAll: path })\n})\n\n\u002F\u002F Named wildcard\napp.get('\u002Ffiles\u002F:filepath{.+}', (c) => {\n  const filepath = c.req.param('filepath')\n  return c.json({ file: filepath })\n})\n```\n\n#### Route Grouping (Sub-apps)\n\n```typescript\n\u002F\u002F Create sub-app\nconst api = new Hono()\n\napi.get('\u002Fusers', (c) => c.json({ users: [] }))\napi.get('\u002Fposts', (c) => c.json({ posts: [] }))\n\n\u002F\u002F Mount sub-app\nconst app = new Hono()\napp.route('\u002Fapi', api)\n\n\u002F\u002F Result: \u002Fapi\u002Fusers, \u002Fapi\u002Fposts\n```\n\n**Why Group Routes:**\n- Organize large applications\n- Share middleware for specific routes\n- Better code structure and maintainability\n\n---\n\n### Part 2: Middleware Composition\n\n#### Middleware Flow\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\n\u002F\u002F Global middleware (runs for all routes)\napp.use('*', async (c, next) => {\n  console.log(`[${c.req.method}] ${c.req.url}`)\n  await next() \u002F\u002F CRITICAL: Must call next()\n  console.log('Response sent')\n})\n\n\u002F\u002F Route-specific middleware\napp.use('\u002Fadmin\u002F*', async (c, next) => {\n  \u002F\u002F Auth check\n  const token = c.req.header('Authorization')\n  if (!token) {\n    return c.json({ error: 'Unauthorized' }, 401)\n  }\n  await next()\n})\n\napp.get('\u002Fadmin\u002Fdashboard', (c) => {\n  return c.json({ message: 'Admin Dashboard' })\n})\n```\n\n**CRITICAL:**\n- **Always call `await next()`** in middleware\n- Middleware runs BEFORE the handler\n- Return early to prevent handler execution\n- Check `c.error` AFTER `next()` for error handling\n\n#### Built-in Middleware\n\n```typescript\nimport { Hono } from 'hono'\nimport { logger } from 'hono\u002Flogger'\nimport { cors } from 'hono\u002Fcors'\nimport { prettyJSON } from 'hono\u002Fpretty-json'\nimport { compress } from 'hono\u002Fcompress'\nimport { cache } from 'hono\u002Fcache'\n\nconst app = new Hono()\n\n\u002F\u002F Request logging\napp.use('*', logger())\n\n\u002F\u002F CORS\napp.use('\u002Fapi\u002F*', cors({\n  origin: 'https:\u002F\u002Fexample.com',\n  allowMethods: ['GET', 'POST', 'PUT', 'DELETE'],\n  allowHeaders: ['Content-Type', 'Authorization'],\n}))\n\n\u002F\u002F Pretty JSON (dev only)\napp.use('*', prettyJSON())\n\n\u002F\u002F Compression (gzip\u002Fdeflate)\napp.use('*', compress())\n\n\u002F\u002F Cache responses\napp.use(\n  '\u002Fstatic\u002F*',\n  cache({\n    cacheName: 'my-app',\n    cacheControl: 'max-age=3600',\n  })\n)\n```\n\n**Built-in Middleware Reference**: See `references\u002Fmiddleware-catalog.md`\n\n#### Middleware Chaining\n\n```typescript\n\u002F\u002F Multiple middleware in sequence\napp.get(\n  '\u002Fprotected',\n  authMiddleware,\n  rateLimitMiddleware,\n  (c) => {\n    return c.json({ data: 'Protected data' })\n  }\n)\n\n\u002F\u002F Middleware factory pattern\nconst authMiddleware = async (c, next) => {\n  const token = c.req.header('Authorization')\n  if (!token) {\n    throw new HTTPException(401, { message: 'Unauthorized' })\n  }\n\n  \u002F\u002F Set user in context\n  c.set('user', { id: 1, name: 'Alice' })\n\n  await next()\n}\n\nconst rateLimitMiddleware = async (c, next) => {\n  \u002F\u002F Rate limit logic\n  await next()\n}\n```\n\n**Why Chain Middleware:**\n- Separation of concerns\n- Reusable across routes\n- Clear execution order\n\n#### Custom Middleware\n\n```typescript\n\u002F\u002F Timing middleware\nconst timing = async (c, next) => {\n  const start = Date.now()\n  await next()\n  const elapsed = Date.now() - start\n  c.res.headers.set('X-Response-Time', `${elapsed}ms`)\n}\n\n\u002F\u002F Request ID middleware\nconst requestId = async (c, next) => {\n  const id = crypto.randomUUID()\n  c.set('requestId', id)\n  await next()\n  c.res.headers.set('X-Request-ID', id)\n}\n\n\u002F\u002F Error logging middleware\nconst errorLogger = async (c, next) => {\n  await next()\n  if (c.error) {\n    console.error('Error:', c.error)\n    \u002F\u002F Send to error tracking service\n  }\n}\n\napp.use('*', timing)\napp.use('*', requestId)\napp.use('*', errorLogger)\n```\n\n**Best Practices:**\n- Keep middleware focused (single responsibility)\n- Use `c.set()` to share data between middleware\n- Check `c.error` AFTER `next()` for error handling\n- Return early to short-circuit execution\n\n---\n\n### Part 3: Type-Safe Context Extension\n\n#### Using c.set() and c.get()\n\n```typescript\nimport { Hono } from 'hono'\n\ntype Bindings = {\n  DATABASE_URL: string\n}\n\ntype Variables = {\n  user: {\n    id: number\n    name: string\n  }\n  requestId: string\n}\n\nconst app = new Hono\u003C{ Bindings: Bindings; Variables: Variables }>()\n\n\u002F\u002F Middleware sets variables\napp.use('*', async (c, next) => {\n  c.set('requestId', crypto.randomUUID())\n  await next()\n})\n\napp.use('\u002Fapi\u002F*', async (c, next) => {\n  c.set('user', { id: 1, name: 'Alice' })\n  await next()\n})\n\n\u002F\u002F Route accesses variables\napp.get('\u002Fapi\u002Fprofile', (c) => {\n  const user = c.get('user') \u002F\u002F Type-safe!\n  const requestId = c.get('requestId') \u002F\u002F Type-safe!\n\n  return c.json({ user, requestId })\n})\n```\n\n**CRITICAL:**\n- Define `Variables` type for type-safe `c.get()`\n- Define `Bindings` type for environment variables (Cloudflare Workers)\n- `c.set()` in middleware, `c.get()` in handlers\n\n#### Custom Context Extension\n\n```typescript\nimport { Hono } from 'hono'\nimport type { Context } from 'hono'\n\ntype Env = {\n  Variables: {\n    logger: {\n      info: (message: string) => void\n      error: (message: string) => void\n    }\n  }\n}\n\nconst app = new Hono\u003CEnv>()\n\n\u002F\u002F Create logger middleware\napp.use('*', async (c, next) => {\n  const logger = {\n    info: (msg: string) => console.log(`[INFO] ${msg}`),\n    error: (msg: string) => console.error(`[ERROR] ${msg}`),\n  }\n\n  c.set('logger', logger)\n  await next()\n})\n\napp.get('\u002F', (c) => {\n  const logger = c.get('logger')\n  logger.info('Hello from route')\n\n  return c.json({ message: 'Hello' })\n})\n```\n\n**Advanced Pattern**: See `templates\u002Fcontext-extension.ts`\n\n---\n\n### Part 4: Request Validation\n\n#### Validation with Zod\n\n```bash\nnpm install zod@4.1.12 @hono\u002Fzod-validator@0.7.4\n```\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\n\u002F\u002F Define schema\nconst userSchema = z.object({\n  name: z.string().min(1).max(100),\n  email: z.string().email(),\n  age: z.number().int().min(18).optional(),\n})\n\n\u002F\u002F Validate JSON body\napp.post('\u002Fusers', zValidator('json', userSchema), (c) => {\n  const data = c.req.valid('json') \u002F\u002F Type-safe!\n  return c.json({ success: true, data })\n})\n\n\u002F\u002F Validate query params\nconst searchSchema = z.object({\n  q: z.string(),\n  page: z.string().transform((val) => parseInt(val, 10)),\n  limit: z.string().transform((val) => parseInt(val, 10)).optional(),\n})\n\napp.get('\u002Fsearch', zValidator('query', searchSchema), (c) => {\n  const { q, page, limit } = c.req.valid('query')\n  return c.json({ q, page, limit })\n})\n\n\u002F\u002F Validate route params\nconst idSchema = z.object({\n  id: z.string().uuid(),\n})\n\napp.get('\u002Fusers\u002F:id', zValidator('param', idSchema), (c) => {\n  const { id } = c.req.valid('param')\n  return c.json({ userId: id })\n})\n\n\u002F\u002F Validate headers\nconst headerSchema = z.object({\n  'authorization': z.string().startsWith('Bearer '),\n  'content-type': z.string(),\n})\n\napp.post('\u002Fauth', zValidator('header', headerSchema), (c) => {\n  const headers = c.req.valid('header')\n  return c.json({ authenticated: true })\n})\n```\n\n**CRITICAL:**\n- **Always use `c.req.valid()`** after validation (type-safe)\n- Validation targets: `json`, `query`, `param`, `header`, `form`, `cookie`\n- Use `z.transform()` to convert strings to numbers\u002Fdates\n- Validation errors return 400 automatically\n\n#### Custom Validation Hooks\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\n\u002F\u002F Custom error handler\napp.post(\n  '\u002Fusers',\n  zValidator('json', schema, (result, c) => {\n    if (!result.success) {\n      \u002F\u002F Custom error response\n      return c.json(\n        {\n          error: 'Validation failed',\n          issues: result.error.issues,\n        },\n        400\n      )\n    }\n  }),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data })\n  }\n)\n\n\u002F\u002F Throw HTTPException\napp.post(\n  '\u002Fusers',\n  zValidator('json', schema, (result, c) => {\n    if (!result.success) {\n      throw new HTTPException(400, { cause: result.error })\n    }\n  }),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data })\n  }\n)\n```\n\n#### Validation with Valibot\n\n```bash\nnpm install valibot@1.1.0 @hono\u002Fvalibot-validator@0.5.3\n```\n\n```typescript\nimport { vValidator } from '@hono\u002Fvalibot-validator'\nimport * as v from 'valibot'\n\nconst schema = v.object({\n  name: v.string(),\n  age: v.number(),\n})\n\napp.post('\u002Fusers', vValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Zod vs Valibot**: See `references\u002Fvalidation-libraries.md`\n\n#### Validation with Typia\n\n```bash\nnpm install typia @hono\u002Ftypia-validator@0.1.2\n```\n\n```typescript\nimport { typiaValidator } from '@hono\u002Ftypia-validator'\nimport typia from 'typia'\n\ninterface User {\n  name: string\n  age: number\n}\n\nconst validate = typia.createValidate\u003CUser>()\n\napp.post('\u002Fusers', typiaValidator('json', validate), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Why Typia:**\n- Fastest validation (compile-time)\n- No runtime schema definition\n- AOT (Ahead-of-Time) compilation\n\n#### Validation with ArkType\n\n```bash\nnpm install arktype @hono\u002Farktype-validator@2.0.1\n```\n\n```typescript\nimport { arktypeValidator } from '@hono\u002Farktype-validator'\nimport { type } from 'arktype'\n\nconst schema = type({\n  name: 'string',\n  age: 'number',\n})\n\napp.post('\u002Fusers', arktypeValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Comparison**: See `references\u002Fvalidation-libraries.md` for detailed comparison\n\n---\n\n### Part 5: Typed Routes (RPC)\n\n#### Why RPC?\n\nHono's RPC feature allows **type-safe client\u002Fserver communication** without manual API type definitions. The client infers types directly from the server routes.\n\n#### Server-Side Setup\n\n```typescript\n\u002F\u002F app.ts\nimport { Hono } from 'hono'\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\nconst app = new Hono()\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\n\u002F\u002F Define route and export type\nconst route = app.post(\n  '\u002Fusers',\n  zValidator('json', schema),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data }, 201)\n  }\n)\n\n\u002F\u002F Export app type for RPC client\nexport type AppType = typeof route\n\n\u002F\u002F OR export entire app\n\u002F\u002F export type AppType = typeof app\n\nexport default app\n```\n\n**CRITICAL:**\n- **Must use `const route = app.get(...)` for RPC type inference**\n- Export `typeof route` or `typeof app`\n- Don't use anonymous route definitions\n\n#### Client-Side Setup\n\n```typescript\n\u002F\u002F client.ts\nimport { hc } from 'hono\u002Fclient'\nimport type { AppType } from '.\u002Fapp'\n\nconst client = hc\u003CAppType>('http:\u002F\u002Flocalhost:8787')\n\n\u002F\u002F Type-safe API call\nconst res = await client.users.$post({\n  json: {\n    name: 'Alice',\n    age: 30,\n  },\n})\n\n\u002F\u002F Response is typed!\nconst data = await res.json() \u002F\u002F { success: boolean, data: { name: string, age: number } }\n```\n\n**Why RPC:**\n- ✅ Full type inference (request + response)\n- ✅ No manual type definitions\n- ✅ Compile-time error checking\n- ✅ Auto-complete in IDE\n\n#### RPC with Multiple Routes\n\n```typescript\n\u002F\u002F Server\nconst app = new Hono()\n\nconst getUsers = app.get('\u002Fusers', (c) => {\n  return c.json({ users: [] })\n})\n\nconst createUser = app.post(\n  '\u002Fusers',\n  zValidator('json', userSchema),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data }, 201)\n  }\n)\n\nconst getUser = app.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n  return c.json({ id, name: 'Alice' })\n})\n\n\u002F\u002F Export combined type\nexport type AppType = typeof getUsers | typeof createUser | typeof getUser\n\n\u002F\u002F Client\nconst client = hc\u003CAppType>('http:\u002F\u002Flocalhost:8787')\n\n\u002F\u002F GET \u002Fusers\nconst usersRes = await client.users.$get()\n\n\u002F\u002F POST \u002Fusers\nconst createRes = await client.users.$post({\n  json: { name: 'Alice', age: 30 },\n})\n\n\u002F\u002F GET \u002Fusers\u002F:id\nconst userRes = await client.users[':id'].$get({\n  param: { id: '123' },\n})\n```\n\n#### RPC Performance Optimization\n\n**Problem**: Large apps with many routes cause slow type inference\n\n**Solution**: Export specific route groups instead of entire app\n\n```typescript\n\u002F\u002F ❌ Slow: Export entire app\nexport type AppType = typeof app\n\n\u002F\u002F ✅ Fast: Export specific routes\nconst userRoutes = app.get('\u002Fusers', ...).post('\u002Fusers', ...)\nexport type UserRoutes = typeof userRoutes\n\nconst postRoutes = app.get('\u002Fposts', ...).post('\u002Fposts', ...)\nexport type PostRoutes = typeof postRoutes\n\n\u002F\u002F Client imports specific routes\nimport type { UserRoutes } from '.\u002Fapp'\nconst userClient = hc\u003CUserRoutes>('http:\u002F\u002Flocalhost:8787')\n```\n\n**Deep Dive**: See `references\u002Frpc-guide.md`\n\n---\n\n### Part 6: Error Handling\n\n#### HTTPException\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\napp.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n\n  \u002F\u002F Throw HTTPException for client errors\n  if (!id) {\n    throw new HTTPException(400, { message: 'ID is required' })\n  }\n\n  \u002F\u002F With custom response\n  if (id === 'invalid') {\n    const res = new Response('Custom error body', { status: 400 })\n    throw new HTTPException(400, { res })\n  }\n\n  return c.json({ id })\n})\n```\n\n**CRITICAL:**\n- Use HTTPException for **expected errors** (400, 401, 403, 404)\n- Don't use for **unexpected errors** (500) - use `onError` instead\n- HTTPException stops execution immediately\n\n#### Global Error Handler (onError)\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\n\u002F\u002F Custom error handler\napp.onError((err, c) => {\n  \u002F\u002F Handle HTTPException\n  if (err instanceof HTTPException) {\n    return err.getResponse()\n  }\n\n  \u002F\u002F Handle unexpected errors\n  console.error('Unexpected error:', err)\n\n  return c.json(\n    {\n      error: 'Internal Server Error',\n      message: err.message,\n    },\n    500\n  )\n})\n\napp.get('\u002Ferror', (c) => {\n  throw new Error('Something went wrong!')\n})\n```\n\n**Why onError:**\n- Centralized error handling\n- Consistent error responses\n- Error logging and tracking\n\n#### Middleware Error Checking\n\n```typescript\napp.use('*', async (c, next) => {\n  await next()\n\n  \u002F\u002F Check for errors after handler\n  if (c.error) {\n    console.error('Error in route:', c.error)\n    \u002F\u002F Send to error tracking service\n  }\n})\n```\n\n#### Not Found Handler\n\n```typescript\napp.notFound((c) => {\n  return c.json({ error: 'Not Found' }, 404)\n})\n```\n\n#### Error Handling Best Practices\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\n\u002F\u002F Validation errors\napp.post('\u002Fusers', zValidator('json', schema), (c) => {\n  \u002F\u002F zValidator automatically returns 400 on validation failure\n  const data = c.req.valid('json')\n  return c.json({ data })\n})\n\n\u002F\u002F Authorization errors\napp.use('\u002Fadmin\u002F*', async (c, next) => {\n  const token = c.req.header('Authorization')\n  if (!token) {\n    throw new HTTPException(401, { message: 'Unauthorized' })\n  }\n  await next()\n})\n\n\u002F\u002F Not found errors\napp.get('\u002Fusers\u002F:id', async (c) => {\n  const id = c.req.param('id')\n  const user = await db.getUser(id)\n\n  if (!user) {\n    throw new HTTPException(404, { message: 'User not found' })\n  }\n\n  return c.json({ user })\n})\n\n\u002F\u002F Server errors\napp.get('\u002Fdata', async (c) => {\n  try {\n    const data = await fetchExternalAPI()\n    return c.json({ data })\n  } catch (error) {\n    \u002F\u002F Let onError handle it\n    throw error\n  }\n})\n\n\u002F\u002F Global error handler\napp.onError((err, c) => {\n  if (err instanceof HTTPException) {\n    return err.getResponse()\n  }\n\n  console.error('Unexpected error:', err)\n  return c.json({ error: 'Internal Server Error' }, 500)\n})\n\n\u002F\u002F 404 handler\napp.notFound((c) => {\n  return c.json({ error: 'Not Found' }, 404)\n})\n```\n\n---\n\n## Critical Rules\n\n### Always Do\n\n✅ **Call `await next()` in middleware** - Required for middleware chain execution\n✅ **Return Response from handlers** - Use `c.json()`, `c.text()`, `c.html()`\n✅ **Use `c.req.valid()` after validation** - Type-safe validated data\n✅ **Export route types for RPC** - `export type AppType = typeof route`\n✅ **Throw HTTPException for client errors** - 400, 401, 403, 404 errors\n✅ **Use `onError` for global error handling** - Centralized error responses\n✅ **Define Variables type for c.set\u002Fc.get** - Type-safe context variables\n✅ **Use const route = app.get(...)** - Required for RPC type inference\n\n### Never Do\n\n❌ **Forget `await next()` in middleware** - Breaks middleware chain\n❌ **Use `res.send()` like Express** - Not compatible with Hono\n❌ **Access request data without validation** - Use validators for type safety\n❌ **Export entire app for large RPC** - Slow type inference, export specific routes\n❌ **Use plain throw new Error()** - Use HTTPException instead\n❌ **Skip onError handler** - Leads to inconsistent error responses\n❌ **Use c.set\u002Fc.get without Variables type** - Loses type safety\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **8** documented issues:\n\n### Issue #1: RPC Type Inference Slow\n**Error**: IDE becomes slow with many routes\n**Source**: [hono\u002Fdocs\u002Fguides\u002Frpc](https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Frpc)\n**Why It Happens**: Complex type instantiation from `typeof app` with many routes\n**Prevention**: Export specific route groups instead of entire app\n\n```typescript\n\u002F\u002F ❌ Slow\nexport type AppType = typeof app\n\n\u002F\u002F ✅ Fast\nconst userRoutes = app.get(...).post(...)\nexport type UserRoutes = typeof userRoutes\n```\n\n### Issue #2: Middleware Response Not Typed in RPC\n**Error**: Middleware responses not inferred by RPC client\n**Source**: [honojs\u002Fhono#2719](https:\u002F\u002Fgithub.com\u002Fhonojs\u002Fhono\u002Fissues\u002F2719)\n**Why It Happens**: RPC mode doesn't infer middleware responses by default\n**Prevention**: Export specific route types that include middleware\n\n```typescript\nconst route = app.get(\n  '\u002Fdata',\n  myMiddleware,\n  (c) => c.json({ data: 'value' })\n)\nexport type AppType = typeof route\n```\n\n### Issue #3: Validation Hook Confusion\n**Error**: Different validator libraries have different hook patterns\n**Source**: Context7 research\n**Why It Happens**: Each validator (@hono\u002Fzod-validator, @hono\u002Fvalibot-validator, etc.) has slightly different APIs\n**Prevention**: This skill provides consistent patterns for all validators\n\n### Issue #4: HTTPException Misuse\n**Error**: Throwing plain Error instead of HTTPException\n**Source**: Official docs\n**Why It Happens**: Developers familiar with Express use `throw new Error()`\n**Prevention**: Always use `HTTPException` for client errors (400-499)\n\n```typescript\n\u002F\u002F ❌ Wrong\nthrow new Error('Unauthorized')\n\n\u002F\u002F ✅ Correct\nthrow new HTTPException(401, { message: 'Unauthorized' })\n```\n\n### Issue #5: Context Type Safety Lost\n**Error**: `c.set()` and `c.get()` without type inference\n**Source**: Official docs\n**Why It Happens**: Not defining `Variables` type in Hono generic\n**Prevention**: Always define Variables type\n\n```typescript\ntype Variables = {\n  user: { id: number; name: string }\n}\n\nconst app = new Hono\u003C{ Variables: Variables }>()\n```\n\n### Issue #6: Missing Error Check After Middleware\n**Error**: Errors in handlers not caught\n**Source**: Official docs\n**Why It Happens**: Not checking `c.error` after `await next()`\n**Prevention**: Check `c.error` in middleware\n\n```typescript\napp.use('*', async (c, next) => {\n  await next()\n  if (c.error) {\n    console.error('Error:', c.error)\n  }\n})\n```\n\n### Issue #7: Direct Request Access Without Validation\n**Error**: Accessing `c.req.param()` or `c.req.query()` without validation\n**Source**: Best practices\n**Why It Happens**: Developers skip validation for speed\n**Prevention**: Always use validators and `c.req.valid()`\n\n```typescript\n\u002F\u002F ❌ Wrong\nconst id = c.req.param('id') \u002F\u002F string, no validation\n\n\u002F\u002F ✅ Correct\napp.get('\u002Fusers\u002F:id', zValidator('param', idSchema), (c) => {\n  const { id } = c.req.valid('param') \u002F\u002F validated UUID\n})\n```\n\n### Issue #8: Incorrect Middleware Order\n**Error**: Middleware executing in wrong order\n**Source**: Official docs\n**Why It Happens**: Misunderstanding middleware chain execution\n**Prevention**: Remember middleware runs top-to-bottom, `await next()` runs handler, then bottom-to-top\n\n```typescript\napp.use('*', async (c, next) => {\n  console.log('1: Before handler')\n  await next()\n  console.log('4: After handler')\n})\n\napp.use('*', async (c, next) => {\n  console.log('2: Before handler')\n  await next()\n  console.log('3: After handler')\n})\n\napp.get('\u002F', (c) => {\n  console.log('Handler')\n  return c.json({})\n})\n\n\u002F\u002F Output: 1, 2, Handler, 3, 4\n```\n\n---\n\n## Configuration Files Reference\n\n### package.json (Full Example)\n\n```json\n{\n  \"name\": \"hono-app\",\n  \"version\": \"1.0.0\",\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \"tsx watch src\u002Findex.ts\",\n    \"build\": \"tsc\",\n    \"start\": \"node dist\u002Findex.js\"\n  },\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^5.9.0\",\n    \"tsx\": \"^4.19.0\",\n    \"@types\u002Fnode\": \"^22.10.0\"\n  }\n}\n```\n\n### package.json with Validation (Zod)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"zod\": \"^4.1.12\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\"\n  }\n}\n```\n\n### package.json with Validation (Valibot)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\"\n  }\n}\n```\n\n### package.json with All Validators\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"zod\": \"^4.1.12\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\",\n    \"@hono\u002Ftypia-validator\": \"^0.1.2\",\n    \"@hono\u002Farktype-validator\": \"^2.0.1\"\n  }\n}\n```\n\n### tsconfig.json\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"module\": \"ES2022\",\n    \"lib\": [\"ES2022\"],\n    \"moduleResolution\": \"bundler\",\n    \"resolveJsonModule\": true,\n    \"allowJs\": true,\n    \"checkJs\": false,\n    \"strict\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"isolatedModules\": true,\n    \"outDir\": \".\u002Fdist\"\n  },\n  \"include\": [\"src\u002F**\u002F*\"],\n  \"exclude\": [\"node_modules\"]\n}\n```\n\n---\n\n## File Templates\n\nAll templates are available in the `templates\u002F` directory:\n\n- **routing-patterns.ts** - Route params, query params, wildcards, grouping\n- **middleware-composition.ts** - Middleware chaining, built-in middleware\n- **validation-zod.ts** - Zod validation with custom hooks\n- **validation-valibot.ts** - Valibot validation\n- **rpc-pattern.ts** - Type-safe RPC client\u002Fserver\n- **error-handling.ts** - HTTPException, onError, custom errors\n- **context-extension.ts** - c.set\u002Fc.get, custom context types\n- **package.json** - All dependencies\n\nCopy these files to your project and customize as needed.\n\n---\n\n## Reference Documentation\n\nFor deeper understanding, see:\n\n- **middleware-catalog.md** - Complete built-in Hono middleware reference\n- **validation-libraries.md** - Zod vs Valibot vs Typia vs ArkType comparison\n- **rpc-guide.md** - RPC pattern deep dive, performance optimization\n- **top-errors.md** - Common Hono errors with solutions\n\n---\n\n## Official Documentation\n\n- **Hono**: https:\u002F\u002Fhono.dev\n- **Hono Routing**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fapi\u002Frouting\n- **Hono Middleware**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Fmiddleware\n- **Hono Validation**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Fvalidation\n- **Hono RPC**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Frpc\n- **Hono Context**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fapi\u002Fcontext\n- **Context7 Library ID**: `\u002Fllmstxt\u002Fhono_dev_llms-full_txt`\n\n---\n\n## Dependencies (Latest Verified 2025-10-22)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\"\n  },\n  \"optionalDependencies\": {\n    \"zod\": \"^4.1.12\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\",\n    \"@hono\u002Ftypia-validator\": \"^0.1.2\",\n    \"@hono\u002Farktype-validator\": \"^2.0.1\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^5.9.0\"\n  }\n}\n```\n\n---\n\n## Production Example\n\nThis skill is validated across multiple runtime environments:\n\n- **Cloudflare Workers**: Routing, middleware, RPC patterns\n- **Deno**: All validation libraries tested\n- **Bun**: Performance benchmarks completed\n- **Node.js**: Full test suite passing\n\nAll patterns in this skill have been validated in production.\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Ftop-errors.md` first\n2. Verify all steps in the setup process\n3. Ensure `await next()` is called in middleware\n4. Ensure RPC routes use `const route = app.get(...)` pattern\n5. Check official docs: https:\u002F\u002Fhono.dev\n","# Hono Routing & Middleware\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-10-22\n**Dependencies**: None (framework-agnostic)\n**Latest Versions**: hono@4.10.2, zod@4.1.12, valibot@1.1.0, @hono\u002Fzod-validator@0.7.4, @hono\u002Fvalibot-validator@0.5.3\n\n---\n\n## Quick Start (15 Minutes)\n\n### 1. Install Hono\n\n```bash\nnpm install hono@4.10.2\n```\n\n**Why Hono:**\n- **Fast**: Built on Web Standards, runs on any JavaScript runtime\n- **Lightweight**: ~10KB, no dependencies\n- **Type-safe**: Full TypeScript support with type inference\n- **Flexible**: Works on Cloudflare Workers, Deno, Bun, Node.js, Vercel\n\n### 2. Create Basic App\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\napp.get('\u002F', (c) => {\n  return c.json({ message: 'Hello Hono!' })\n})\n\nexport default app\n```\n\n**CRITICAL:**\n- Use `c.json()`, `c.text()`, `c.html()` for responses\n- Return the response (don't use `res.send()` like Express)\n- Export app for runtime (Cloudflare Workers, Deno, Bun, Node.js)\n\n### 3. Add Request Validation\n\n```bash\nnpm install zod@4.1.12 @hono\u002Fzod-validator@0.7.4\n```\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\napp.post('\u002Fuser', zValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Why Validation:**\n- Type-safe request data\n- Automatic error responses\n- Runtime validation, not just TypeScript\n\n---\n\n## The 6-Part Hono Mastery Guide\n\n### Part 1: Routing Patterns\n\n#### Basic Routes\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\n\u002F\u002F GET request\napp.get('\u002Fposts', (c) => c.json({ posts: [] }))\n\n\u002F\u002F POST request\napp.post('\u002Fposts', (c) => c.json({ created: true }))\n\n\u002F\u002F PUT request\napp.put('\u002Fposts\u002F:id', (c) => c.json({ updated: true }))\n\n\u002F\u002F DELETE request\napp.delete('\u002Fposts\u002F:id', (c) => c.json({ deleted: true }))\n\n\u002F\u002F Multiple methods\napp.on(['GET', 'POST'], '\u002Fmulti', (c) => c.text('GET or POST'))\n\n\u002F\u002F All methods\napp.all('\u002Fcatch-all', (c) => c.text('Any method'))\n```\n\n**Key Points:**\n- Always return a Response (c.json, c.text, c.html, etc.)\n- Routes are matched in order (first match wins)\n- Use specific routes before wildcard routes\n\n#### Route Parameters\n\n```typescript\n\u002F\u002F Single parameter\napp.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n  return c.json({ userId: id })\n})\n\n\u002F\u002F Multiple parameters\napp.get('\u002Fposts\u002F:postId\u002Fcomments\u002F:commentId', (c) => {\n  const { postId, commentId } = c.req.param()\n  return c.json({ postId, commentId })\n})\n\n\u002F\u002F Optional parameters (using wildcards)\napp.get('\u002Ffiles\u002F*', (c) => {\n  const path = c.req.param('*')\n  return c.json({ filePath: path })\n})\n```\n\n**CRITICAL:**\n- `c.req.param('name')` returns single parameter\n- `c.req.param()` returns all parameters as object\n- Parameters are always strings (cast to number if needed)\n\n#### Query Parameters\n\n```typescript\napp.get('\u002Fsearch', (c) => {\n  \u002F\u002F Single query param\n  const q = c.req.query('q')\n\n  \u002F\u002F Multiple query params\n  const { page, limit } = c.req.query()\n\n  \u002F\u002F Query param array (e.g., ?tag=js&tag=ts)\n  const tags = c.req.queries('tag')\n\n  return c.json({ q, page, limit, tags })\n})\n```\n\n**Best Practice:**\n- Use validation for query params (see Part 4)\n- Provide defaults for optional params\n- Parse numbers\u002Fbooleans from query strings\n\n#### Wildcard Routes\n\n```typescript\n\u002F\u002F Match any path after \u002Fapi\u002F\napp.get('\u002Fapi\u002F*', (c) => {\n  const path = c.req.param('*')\n  return c.json({ catchAll: path })\n})\n\n\u002F\u002F Named wildcard\napp.get('\u002Ffiles\u002F:filepath{.+}', (c) => {\n  const filepath = c.req.param('filepath')\n  return c.json({ file: filepath })\n})\n```\n\n#### Route Grouping (Sub-apps)\n\n```typescript\n\u002F\u002F Create sub-app\nconst api = new Hono()\n\napi.get('\u002Fusers', (c) => c.json({ users: [] }))\napi.get('\u002Fposts', (c) => c.json({ posts: [] }))\n\n\u002F\u002F Mount sub-app\nconst app = new Hono()\napp.route('\u002Fapi', api)\n\n\u002F\u002F Result: \u002Fapi\u002Fusers, \u002Fapi\u002Fposts\n```\n\n**Why Group Routes:**\n- Organize large applications\n- Share middleware for specific routes\n- Better code structure and maintainability\n\n---\n\n### Part 2: Middleware Composition\n\n#### Middleware Flow\n\n```typescript\nimport { Hono } from 'hono'\n\nconst app = new Hono()\n\n\u002F\u002F Global middleware (runs for all routes)\napp.use('*', async (c, next) => {\n  console.log(`[${c.req.method}] ${c.req.url}`)\n  await next() \u002F\u002F CRITICAL: Must call next()\n  console.log('Response sent')\n})\n\n\u002F\u002F Route-specific middleware\napp.use('\u002Fadmin\u002F*', async (c, next) => {\n  \u002F\u002F Auth check\n  const token = c.req.header('Authorization')\n  if (!token) {\n    return c.json({ error: 'Unauthorized' }, 401)\n  }\n  await next()\n})\n\napp.get('\u002Fadmin\u002Fdashboard', (c) => {\n  return c.json({ message: 'Admin Dashboard' })\n})\n```\n\n**CRITICAL:**\n- **Always call `await next()`** in middleware\n- Middleware runs BEFORE the handler\n- Return early to prevent handler execution\n- Check `c.error` AFTER `next()` for error handling\n\n#### Built-in Middleware\n\n```typescript\nimport { Hono } from 'hono'\nimport { logger } from 'hono\u002Flogger'\nimport { cors } from 'hono\u002Fcors'\nimport { prettyJSON } from 'hono\u002Fpretty-json'\nimport { compress } from 'hono\u002Fcompress'\nimport { cache } from 'hono\u002Fcache'\n\nconst app = new Hono()\n\n\u002F\u002F Request logging\napp.use('*', logger())\n\n\u002F\u002F CORS\napp.use('\u002Fapi\u002F*', cors({\n  origin: 'https:\u002F\u002Fexample.com',\n  allowMethods: ['GET', 'POST', 'PUT', 'DELETE'],\n  allowHeaders: ['Content-Type', 'Authorization'],\n}))\n\n\u002F\u002F Pretty JSON (dev only)\napp.use('*', prettyJSON())\n\n\u002F\u002F Compression (gzip\u002Fdeflate)\napp.use('*', compress())\n\n\u002F\u002F Cache responses\napp.use(\n  '\u002Fstatic\u002F*',\n  cache({\n    cacheName: 'my-app',\n    cacheControl: 'max-age=3600',\n  })\n)\n```\n\n**Built-in Middleware Reference**: See `references\u002Fmiddleware-catalog.md`\n\n#### Middleware Chaining\n\n```typescript\n\u002F\u002F Multiple middleware in sequence\napp.get(\n  '\u002Fprotected',\n  authMiddleware,\n  rateLimitMiddleware,\n  (c) => {\n    return c.json({ data: 'Protected data' })\n  }\n)\n\n\u002F\u002F Middleware factory pattern\nconst authMiddleware = async (c, next) => {\n  const token = c.req.header('Authorization')\n  if (!token) {\n    throw new HTTPException(401, { message: 'Unauthorized' })\n  }\n\n  \u002F\u002F Set user in context\n  c.set('user', { id: 1, name: 'Alice' })\n\n  await next()\n}\n\nconst rateLimitMiddleware = async (c, next) => {\n  \u002F\u002F Rate limit logic\n  await next()\n}\n```\n\n**Why Chain Middleware:**\n- Separation of concerns\n- Reusable across routes\n- Clear execution order\n\n#### Custom Middleware\n\n```typescript\n\u002F\u002F Timing middleware\nconst timing = async (c, next) => {\n  const start = Date.now()\n  await next()\n  const elapsed = Date.now() - start\n  c.res.headers.set('X-Response-Time', `${elapsed}ms`)\n}\n\n\u002F\u002F Request ID middleware\nconst requestId = async (c, next) => {\n  const id = crypto.randomUUID()\n  c.set('requestId', id)\n  await next()\n  c.res.headers.set('X-Request-ID', id)\n}\n\n\u002F\u002F Error logging middleware\nconst errorLogger = async (c, next) => {\n  await next()\n  if (c.error) {\n    console.error('Error:', c.error)\n    \u002F\u002F Send to error tracking service\n  }\n}\n\napp.use('*', timing)\napp.use('*', requestId)\napp.use('*', errorLogger)\n```\n\n**Best Practices:**\n- Keep middleware focused (single responsibility)\n- Use `c.set()` to share data between middleware\n- Check `c.error` AFTER `next()` for error handling\n- Return early to short-circuit execution\n\n---\n\n### Part 3: Type-Safe Context Extension\n\n#### Using c.set() and c.get()\n\n```typescript\nimport { Hono } from 'hono'\n\ntype Bindings = {\n  DATABASE_URL: string\n}\n\ntype Variables = {\n  user: {\n    id: number\n    name: string\n  }\n  requestId: string\n}\n\nconst app = new Hono\u003C{ Bindings: Bindings; Variables: Variables }>()\n\n\u002F\u002F Middleware sets variables\napp.use('*', async (c, next) => {\n  c.set('requestId', crypto.randomUUID())\n  await next()\n})\n\napp.use('\u002Fapi\u002F*', async (c, next) => {\n  c.set('user', { id: 1, name: 'Alice' })\n  await next()\n})\n\n\u002F\u002F Route accesses variables\napp.get('\u002Fapi\u002Fprofile', (c) => {\n  const user = c.get('user') \u002F\u002F Type-safe!\n  const requestId = c.get('requestId') \u002F\u002F Type-safe!\n\n  return c.json({ user, requestId })\n})\n```\n\n**CRITICAL:**\n- Define `Variables` type for type-safe `c.get()`\n- Define `Bindings` type for environment variables (Cloudflare Workers)\n- `c.set()` in middleware, `c.get()` in handlers\n\n#### Custom Context Extension\n\n```typescript\nimport { Hono } from 'hono'\nimport type { Context } from 'hono'\n\ntype Env = {\n  Variables: {\n    logger: {\n      info: (message: string) => void\n      error: (message: string) => void\n    }\n  }\n}\n\nconst app = new Hono\u003CEnv>()\n\n\u002F\u002F Create logger middleware\napp.use('*', async (c, next) => {\n  const logger = {\n    info: (msg: string) => console.log(`[INFO] ${msg}`),\n    error: (msg: string) => console.error(`[ERROR] ${msg}`),\n  }\n\n  c.set('logger', logger)\n  await next()\n})\n\napp.get('\u002F', (c) => {\n  const logger = c.get('logger')\n  logger.info('Hello from route')\n\n  return c.json({ message: 'Hello' })\n})\n```\n\n**Advanced Pattern**: See `templates\u002Fcontext-extension.ts`\n\n---\n\n### Part 4: Request Validation\n\n#### Validation with Zod\n\n```bash\nnpm install zod@4.1.12 @hono\u002Fzod-validator@0.7.4\n```\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\n\u002F\u002F Define schema\nconst userSchema = z.object({\n  name: z.string().min(1).max(100),\n  email: z.string().email(),\n  age: z.number().int().min(18).optional(),\n})\n\n\u002F\u002F Validate JSON body\napp.post('\u002Fusers', zValidator('json', userSchema), (c) => {\n  const data = c.req.valid('json') \u002F\u002F Type-safe!\n  return c.json({ success: true, data })\n})\n\n\u002F\u002F Validate query params\nconst searchSchema = z.object({\n  q: z.string(),\n  page: z.string().transform((val) => parseInt(val, 10)),\n  limit: z.string().transform((val) => parseInt(val, 10)).optional(),\n})\n\napp.get('\u002Fsearch', zValidator('query', searchSchema), (c) => {\n  const { q, page, limit } = c.req.valid('query')\n  return c.json({ q, page, limit })\n})\n\n\u002F\u002F Validate route params\nconst idSchema = z.object({\n  id: z.string().uuid(),\n})\n\napp.get('\u002Fusers\u002F:id', zValidator('param', idSchema), (c) => {\n  const { id } = c.req.valid('param')\n  return c.json({ userId: id })\n})\n\n\u002F\u002F Validate headers\nconst headerSchema = z.object({\n  'authorization': z.string().startsWith('Bearer '),\n  'content-type': z.string(),\n})\n\napp.post('\u002Fauth', zValidator('header', headerSchema), (c) => {\n  const headers = c.req.valid('header')\n  return c.json({ authenticated: true })\n})\n```\n\n**CRITICAL:**\n- **Always use `c.req.valid()`** after validation (type-safe)\n- Validation targets: `json`, `query`, `param`, `header`, `form`, `cookie`\n- Use `z.transform()` to convert strings to numbers\u002Fdates\n- Validation errors return 400 automatically\n\n#### Custom Validation Hooks\n\n```typescript\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\n\u002F\u002F Custom error handler\napp.post(\n  '\u002Fusers',\n  zValidator('json', schema, (result, c) => {\n    if (!result.success) {\n      \u002F\u002F Custom error response\n      return c.json(\n        {\n          error: 'Validation failed',\n          issues: result.error.issues,\n        },\n        400\n      )\n    }\n  }),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data })\n  }\n)\n\n\u002F\u002F Throw HTTPException\napp.post(\n  '\u002Fusers',\n  zValidator('json', schema, (result, c) => {\n    if (!result.success) {\n      throw new HTTPException(400, { cause: result.error })\n    }\n  }),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data })\n  }\n)\n```\n\n#### Validation with Valibot\n\n```bash\nnpm install valibot@1.1.0 @hono\u002Fvalibot-validator@0.5.3\n```\n\n```typescript\nimport { vValidator } from '@hono\u002Fvalibot-validator'\nimport * as v from 'valibot'\n\nconst schema = v.object({\n  name: v.string(),\n  age: v.number(),\n})\n\napp.post('\u002Fusers', vValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Zod vs Valibot**: See `references\u002Fvalidation-libraries.md`\n\n#### Validation with Typia\n\n```bash\nnpm install typia @hono\u002Ftypia-validator@0.1.2\n```\n\n```typescript\nimport { typiaValidator } from '@hono\u002Ftypia-validator'\nimport typia from 'typia'\n\ninterface User {\n  name: string\n  age: number\n}\n\nconst validate = typia.createValidate\u003CUser>()\n\napp.post('\u002Fusers', typiaValidator('json', validate), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Why Typia:**\n- Fastest validation (compile-time)\n- No runtime schema definition\n- AOT (Ahead-of-Time) compilation\n\n#### Validation with ArkType\n\n```bash\nnpm install arktype @hono\u002Farktype-validator@2.0.1\n```\n\n```typescript\nimport { arktypeValidator } from '@hono\u002Farktype-validator'\nimport { type } from 'arktype'\n\nconst schema = type({\n  name: 'string',\n  age: 'number',\n})\n\napp.post('\u002Fusers', arktypeValidator('json', schema), (c) => {\n  const data = c.req.valid('json')\n  return c.json({ success: true, data })\n})\n```\n\n**Comparison**: See `references\u002Fvalidation-libraries.md` for detailed comparison\n\n---\n\n### Part 5: Typed Routes (RPC)\n\n#### Why RPC?\n\nHono's RPC feature allows **type-safe client\u002Fserver communication** without manual API type definitions. The client infers types directly from the server routes.\n\n#### Server-Side Setup\n\n```typescript\n\u002F\u002F app.ts\nimport { Hono } from 'hono'\nimport { zValidator } from '@hono\u002Fzod-validator'\nimport { z } from 'zod'\n\nconst app = new Hono()\n\nconst schema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\n\u002F\u002F Define route and export type\nconst route = app.post(\n  '\u002Fusers',\n  zValidator('json', schema),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data }, 201)\n  }\n)\n\n\u002F\u002F Export app type for RPC client\nexport type AppType = typeof route\n\n\u002F\u002F OR export entire app\n\u002F\u002F export type AppType = typeof app\n\nexport default app\n```\n\n**CRITICAL:**\n- **Must use `const route = app.get(...)` for RPC type inference**\n- Export `typeof route` or `typeof app`\n- Don't use anonymous route definitions\n\n#### Client-Side Setup\n\n```typescript\n\u002F\u002F client.ts\nimport { hc } from 'hono\u002Fclient'\nimport type { AppType } from '.\u002Fapp'\n\nconst client = hc\u003CAppType>('http:\u002F\u002Flocalhost:8787')\n\n\u002F\u002F Type-safe API call\nconst res = await client.users.$post({\n  json: {\n    name: 'Alice',\n    age: 30,\n  },\n})\n\n\u002F\u002F Response is typed!\nconst data = await res.json() \u002F\u002F { success: boolean, data: { name: string, age: number } }\n```\n\n**Why RPC:**\n- ✅ Full type inference (request + response)\n- ✅ No manual type definitions\n- ✅ Compile-time error checking\n- ✅ Auto-complete in IDE\n\n#### RPC with Multiple Routes\n\n```typescript\n\u002F\u002F Server\nconst app = new Hono()\n\nconst getUsers = app.get('\u002Fusers', (c) => {\n  return c.json({ users: [] })\n})\n\nconst createUser = app.post(\n  '\u002Fusers',\n  zValidator('json', userSchema),\n  (c) => {\n    const data = c.req.valid('json')\n    return c.json({ success: true, data }, 201)\n  }\n)\n\nconst getUser = app.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n  return c.json({ id, name: 'Alice' })\n})\n\n\u002F\u002F Export combined type\nexport type AppType = typeof getUsers | typeof createUser | typeof getUser\n\n\u002F\u002F Client\nconst client = hc\u003CAppType>('http:\u002F\u002Flocalhost:8787')\n\n\u002F\u002F GET \u002Fusers\nconst usersRes = await client.users.$get()\n\n\u002F\u002F POST \u002Fusers\nconst createRes = await client.users.$post({\n  json: { name: 'Alice', age: 30 },\n})\n\n\u002F\u002F GET \u002Fusers\u002F:id\nconst userRes = await client.users[':id'].$get({\n  param: { id: '123' },\n})\n```\n\n#### RPC Performance Optimization\n\n**Problem**: Large apps with many routes cause slow type inference\n\n**Solution**: Export specific route groups instead of entire app\n\n```typescript\n\u002F\u002F ❌ Slow: Export entire app\nexport type AppType = typeof app\n\n\u002F\u002F ✅ Fast: Export specific routes\nconst userRoutes = app.get('\u002Fusers', ...).post('\u002Fusers', ...)\nexport type UserRoutes = typeof userRoutes\n\nconst postRoutes = app.get('\u002Fposts', ...).post('\u002Fposts', ...)\nexport type PostRoutes = typeof postRoutes\n\n\u002F\u002F Client imports specific routes\nimport type { UserRoutes } from '.\u002Fapp'\nconst userClient = hc\u003CUserRoutes>('http:\u002F\u002Flocalhost:8787')\n```\n\n**Deep Dive**: See `references\u002Frpc-guide.md`\n\n---\n\n### Part 6: Error Handling\n\n#### HTTPException\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\napp.get('\u002Fusers\u002F:id', (c) => {\n  const id = c.req.param('id')\n\n  \u002F\u002F Throw HTTPException for client errors\n  if (!id) {\n    throw new HTTPException(400, { message: 'ID is required' })\n  }\n\n  \u002F\u002F With custom response\n  if (id === 'invalid') {\n    const res = new Response('Custom error body', { status: 400 })\n    throw new HTTPException(400, { res })\n  }\n\n  return c.json({ id })\n})\n```\n\n**CRITICAL:**\n- Use HTTPException for **expected errors** (400, 401, 403, 404)\n- Don't use for **unexpected errors** (500) - use `onError` instead\n- HTTPException stops execution immediately\n\n#### Global Error Handler (onError)\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\n\u002F\u002F Custom error handler\napp.onError((err, c) => {\n  \u002F\u002F Handle HTTPException\n  if (err instanceof HTTPException) {\n    return err.getResponse()\n  }\n\n  \u002F\u002F Handle unexpected errors\n  console.error('Unexpected error:', err)\n\n  return c.json(\n    {\n      error: 'Internal Server Error',\n      message: err.message,\n    },\n    500\n  )\n})\n\napp.get('\u002Ferror', (c) => {\n  throw new Error('Something went wrong!')\n})\n```\n\n**Why onError:**\n- Centralized error handling\n- Consistent error responses\n- Error logging and tracking\n\n#### Middleware Error Checking\n\n```typescript\napp.use('*', async (c, next) => {\n  await next()\n\n  \u002F\u002F Check for errors after handler\n  if (c.error) {\n    console.error('Error in route:', c.error)\n    \u002F\u002F Send to error tracking service\n  }\n})\n```\n\n#### Not Found Handler\n\n```typescript\napp.notFound((c) => {\n  return c.json({ error: 'Not Found' }, 404)\n})\n```\n\n#### Error Handling Best Practices\n\n```typescript\nimport { Hono } from 'hono'\nimport { HTTPException } from 'hono\u002Fhttp-exception'\n\nconst app = new Hono()\n\n\u002F\u002F Validation errors\napp.post('\u002Fusers', zValidator('json', schema), (c) => {\n  \u002F\u002F zValidator automatically returns 400 on validation failure\n  const data = c.req.valid('json')\n  return c.json({ data })\n})\n\n\u002F\u002F Authorization errors\napp.use('\u002Fadmin\u002F*', async (c, next) => {\n  const token = c.req.header('Authorization')\n  if (!token) {\n    throw new HTTPException(401, { message: 'Unauthorized' })\n  }\n  await next()\n})\n\n\u002F\u002F Not found errors\napp.get('\u002Fusers\u002F:id', async (c) => {\n  const id = c.req.param('id')\n  const user = await db.getUser(id)\n\n  if (!user) {\n    throw new HTTPException(404, { message: 'User not found' })\n  }\n\n  return c.json({ user })\n})\n\n\u002F\u002F Server errors\napp.get('\u002Fdata', async (c) => {\n  try {\n    const data = await fetchExternalAPI()\n    return c.json({ data })\n  } catch (error) {\n    \u002F\u002F Let onError handle it\n    throw error\n  }\n})\n\n\u002F\u002F Global error handler\napp.onError((err, c) => {\n  if (err instanceof HTTPException) {\n    return err.getResponse()\n  }\n\n  console.error('Unexpected error:', err)\n  return c.json({ error: 'Internal Server Error' }, 500)\n})\n\n\u002F\u002F 404 handler\napp.notFound((c) => {\n  return c.json({ error: 'Not Found' }, 404)\n})\n```\n\n---\n\n## Critical Rules\n\n### Always Do\n\n✅ **Call `await next()` in middleware** - Required for middleware chain execution\n✅ **Return Response from handlers** - Use `c.json()`, `c.text()`, `c.html()`\n✅ **Use `c.req.valid()` after validation** - Type-safe validated data\n✅ **Export route types for RPC** - `export type AppType = typeof route`\n✅ **Throw HTTPException for client errors** - 400, 401, 403, 404 errors\n✅ **Use `onError` for global error handling** - Centralized error responses\n✅ **Define Variables type for c.set\u002Fc.get** - Type-safe context variables\n✅ **Use const route = app.get(...)** - Required for RPC type inference\n\n### Never Do\n\n❌ **Forget `await next()` in middleware** - Breaks middleware chain\n❌ **Use `res.send()` like Express** - Not compatible with Hono\n❌ **Access request data without validation** - Use validators for type safety\n❌ **Export entire app for large RPC** - Slow type inference, export specific routes\n❌ **Use plain throw new Error()** - Use HTTPException instead\n❌ **Skip onError handler** - Leads to inconsistent error responses\n❌ **Use c.set\u002Fc.get without Variables type** - Loses type safety\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **8** documented issues:\n\n### Issue #1: RPC Type Inference Slow\n**Error**: IDE becomes slow with many routes\n**Source**: [hono\u002Fdocs\u002Fguides\u002Frpc](https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Frpc)\n**Why It Happens**: Complex type instantiation from `typeof app` with many routes\n**Prevention**: Export specific route groups instead of entire app\n\n```typescript\n\u002F\u002F ❌ Slow\nexport type AppType = typeof app\n\n\u002F\u002F ✅ Fast\nconst userRoutes = app.get(...).post(...)\nexport type UserRoutes = typeof userRoutes\n```\n\n### Issue #2: Middleware Response Not Typed in RPC\n**Error**: Middleware responses not inferred by RPC client\n**Source**: [honojs\u002Fhono#2719](https:\u002F\u002Fgithub.com\u002Fhonojs\u002Fhono\u002Fissues\u002F2719)\n**Why It Happens**: RPC mode doesn't infer middleware responses by default\n**Prevention**: Export specific route types that include middleware\n\n```typescript\nconst route = app.get(\n  '\u002Fdata',\n  myMiddleware,\n  (c) => c.json({ data: 'value' })\n)\nexport type AppType = typeof route\n```\n\n### Issue #3: Validation Hook Confusion\n**Error**: Different validator libraries have different hook patterns\n**Source**: Context7 research\n**Why It Happens**: Each validator (@hono\u002Fzod-validator, @hono\u002Fvalibot-validator, etc.) has slightly different APIs\n**Prevention**: This skill provides consistent patterns for all validators\n\n### Issue #4: HTTPException Misuse\n**Error**: Throwing plain Error instead of HTTPException\n**Source**: Official docs\n**Why It Happens**: Developers familiar with Express use `throw new Error()`\n**Prevention**: Always use `HTTPException` for client errors (400-499)\n\n```typescript\n\u002F\u002F ❌ Wrong\nthrow new Error('Unauthorized')\n\n\u002F\u002F ✅ Correct\nthrow new HTTPException(401, { message: 'Unauthorized' })\n```\n\n### Issue #5: Context Type Safety Lost\n**Error**: `c.set()` and `c.get()` without type inference\n**Source**: Official docs\n**Why It Happens**: Not defining `Variables` type in Hono generic\n**Prevention**: Always define Variables type\n\n```typescript\ntype Variables = {\n  user: { id: number; name: string }\n}\n\nconst app = new Hono\u003C{ Variables: Variables }>()\n```\n\n### Issue #6: Missing Error Check After Middleware\n**Error**: Errors in handlers not caught\n**Source**: Official docs\n**Why It Happens**: Not checking `c.error` after `await next()`\n**Prevention**: Check `c.error` in middleware\n\n```typescript\napp.use('*', async (c, next) => {\n  await next()\n  if (c.error) {\n    console.error('Error:', c.error)\n  }\n})\n```\n\n### Issue #7: Direct Request Access Without Validation\n**Error**: Accessing `c.req.param()` or `c.req.query()` without validation\n**Source**: Best practices\n**Why It Happens**: Developers skip validation for speed\n**Prevention**: Always use validators and `c.req.valid()`\n\n```typescript\n\u002F\u002F ❌ Wrong\nconst id = c.req.param('id') \u002F\u002F string, no validation\n\n\u002F\u002F ✅ Correct\napp.get('\u002Fusers\u002F:id', zValidator('param', idSchema), (c) => {\n  const { id } = c.req.valid('param') \u002F\u002F validated UUID\n})\n```\n\n### Issue #8: Incorrect Middleware Order\n**Error**: Middleware executing in wrong order\n**Source**: Official docs\n**Why It Happens**: Misunderstanding middleware chain execution\n**Prevention**: Remember middleware runs top-to-bottom, `await next()` runs handler, then bottom-to-top\n\n```typescript\napp.use('*', async (c, next) => {\n  console.log('1: Before handler')\n  await next()\n  console.log('4: After handler')\n})\n\napp.use('*', async (c, next) => {\n  console.log('2: Before handler')\n  await next()\n  console.log('3: After handler')\n})\n\napp.get('\u002F', (c) => {\n  console.log('Handler')\n  return c.json({})\n})\n\n\u002F\u002F Output: 1, 2, Handler, 3, 4\n```\n\n---\n\n## Configuration Files Reference\n\n### package.json (Full Example)\n\n```json\n{\n  \"name\": \"hono-app\",\n  \"version\": \"1.0.0\",\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \"tsx watch src\u002Findex.ts\",\n    \"build\": \"tsc\",\n    \"start\": \"node dist\u002Findex.js\"\n  },\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^5.9.0\",\n    \"tsx\": \"^4.19.0\",\n    \"@types\u002Fnode\": \"^22.10.0\"\n  }\n}\n```\n\n### package.json with Validation (Zod)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"zod\": \"^4.1.12\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\"\n  }\n}\n```\n\n### package.json with Validation (Valibot)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\"\n  }\n}\n```\n\n### package.json with All Validators\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\",\n    \"zod\": \"^4.1.12\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\",\n    \"@hono\u002Ftypia-validator\": \"^0.1.2\",\n    \"@hono\u002Farktype-validator\": \"^2.0.1\"\n  }\n}\n```\n\n### tsconfig.json\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"module\": \"ES2022\",\n    \"lib\": [\"ES2022\"],\n    \"moduleResolution\": \"bundler\",\n    \"resolveJsonModule\": true,\n    \"allowJs\": true,\n    \"checkJs\": false,\n    \"strict\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"isolatedModules\": true,\n    \"outDir\": \".\u002Fdist\"\n  },\n  \"include\": [\"src\u002F**\u002F*\"],\n  \"exclude\": [\"node_modules\"]\n}\n```\n\n---\n\n## File Templates\n\nAll templates are available in the `templates\u002F` directory:\n\n- **routing-patterns.ts** - Route params, query params, wildcards, grouping\n- **middleware-composition.ts** - Middleware chaining, built-in middleware\n- **validation-zod.ts** - Zod validation with custom hooks\n- **validation-valibot.ts** - Valibot validation\n- **rpc-pattern.ts** - Type-safe RPC client\u002Fserver\n- **error-handling.ts** - HTTPException, onError, custom errors\n- **context-extension.ts** - c.set\u002Fc.get, custom context types\n- **package.json** - All dependencies\n\nCopy these files to your project and customize as needed.\n\n---\n\n## Reference Documentation\n\nFor deeper understanding, see:\n\n- **middleware-catalog.md** - Complete built-in Hono middleware reference\n- **validation-libraries.md** - Zod vs Valibot vs Typia vs ArkType comparison\n- **rpc-guide.md** - RPC pattern deep dive, performance optimization\n- **top-errors.md** - Common Hono errors with solutions\n\n---\n\n## Official Documentation\n\n- **Hono**: https:\u002F\u002Fhono.dev\n- **Hono Routing**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fapi\u002Frouting\n- **Hono Middleware**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Fmiddleware\n- **Hono Validation**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Fvalidation\n- **Hono RPC**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fguides\u002Frpc\n- **Hono Context**: https:\u002F\u002Fhono.dev\u002Fdocs\u002Fapi\u002Fcontext\n- **Context7 Library ID**: `\u002Fllmstxt\u002Fhono_dev_llms-full_txt`\n\n---\n\n## Dependencies (Latest Verified 2025-10-22)\n\n```json\n{\n  \"dependencies\": {\n    \"hono\": \"^4.10.2\"\n  },\n  \"optionalDependencies\": {\n    \"zod\": \"^4.1.12\",\n    \"valibot\": \"^1.1.0\",\n    \"@hono\u002Fzod-validator\": \"^0.7.4\",\n    \"@hono\u002Fvalibot-validator\": \"^0.5.3\",\n    \"@hono\u002Ftypia-validator\": \"^0.1.2\",\n    \"@hono\u002Farktype-validator\": \"^2.0.1\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^5.9.0\"\n  }\n}\n```\n\n---\n\n## Production Example\n\nThis skill is validated across multiple runtime environments:\n\n- **Cloudflare Workers**: Routing, middleware, RPC patterns\n- **Deno**: All validation libraries tested\n- **Bun**: Performance benchmarks completed\n- **Node.js**: Full test suite passing\n\nAll patterns in this skill have been validated in production.\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Ftop-errors.md` first\n2. Verify all steps in the setup process\n3. Ensure `await next()` is called in middleware\n4. Ensure RPC routes use `const route = app.get(...)` pattern\n5. Check official docs: https:\u002F\u002Fhono.dev\n",{"name":5,"license":14,"description":23},"This skill provides comprehensive knowledge for building type-safe APIs with Hono, focusing on routing patterns, middleware composition, request validation, RPC client\u002Fserver patterns, error handling, and context management.\n\nUse when: building APIs with Hono (any runtime), setting up request validation with Zod\u002FValibot\u002FTypia\u002FArkType validators, creating type-safe RPC client\u002Fserver 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.\n\nKeywords: 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\n","main","45d5ac830c3e238eeba6d0b4e6fd7cf6b56bf380","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn","2026-09-09 16:05:56",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add davidanthonyn\u002Fclaude-skills --skill hono-routing",{"tool":35,"command":36},"bunx","bunx skills add davidanthonyn\u002Fclaude-skills --skill hono-routing",{"tool":38,"command":39},"pnpm","pnpm dlx skills add davidanthonyn\u002Fclaude-skills --skill hono-routing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fhono-routing\u002FSKILL.md",true,[43,49,53],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"README.md","REFERENCE","参考文档",7643,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fhono-routing\u002FREADME.md",{"path":50,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":51,"sourceHtmlUrl":52},"SKILL.json",32118,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fhono-routing\u002FSKILL.json",{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"SKILL.md.backup","OTHER","其他",28957,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fhono-routing\u002FSKILL.md.backup",[60,67,75,82,89,98],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M7AQPHJF528A4MD52YZEZV3R","zustand-state-management","Production-tested setup for Zustand state management in React applications with TypeScript.\nThis skill provides comprehensive patterns for building scalable, type-safe global state.\n\nUse when: setting up global state in React, migrating from Redux or Context API, implementing\nstate persistence with localStorage, configuring TypeScript with Zustand, using slices pattern\nfor modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration,\nor encountering hydration errors, TypeScript inference issues, or persist middleware problems.\n\nPrevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses\nsyntax errors, persist middleware export errors, infinite render loops, and slices pattern\ntype inference failures.\n\nKeywords: zustand, state management, React state, TypeScript state, persist middleware,\ndevtools, slices pattern, global state, React hooks, create store, useBoundStore,\nStateCreator, hydration error, text content mismatch, infinite render, localStorage,\nsessionStorage, immer middleware, shallow equality, selector pattern, zustand v5","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M7AQP2XJRPNYEH323GJ81NN5","zetic-mlange","Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin\u002FJava) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android\u002FiOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch\u002FONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M7AQNEJHD27NNF5PYQDSW8B9","youtube-downloader","Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3\u002FM4A\u002FFLAC, downloading entire playlists\u002Fchannels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M7AQJQSD2H04EE2EPNAQ8A3M","wordpress-plugin-core","This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks\u002Ffilters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types\u002Ftaxonomies, building admin interfaces, or working with the WordPress database.\n\nUse when: Creating new WordPress plugins, implementing nonces\u002Fsanitization\u002Fescaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation\u002Fdeactivation issues, preventing SQL injection\u002FXSS\u002FCSRF vulnerabilities.\n\nKeywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":93,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M7AQJ91T970QCFMN9R1EHZXV","webapp-testing","Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":18},"01M7AQJ5E89MS8C5K3GZTY4B48","web-performance-audit","Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fweb-performance-audit\u002FSKILL.md",[],[]]