hono-typescript — Claude Code skill for Hono and TypeScript APIs
Hands your agent a rulebook for building Hono and TypeScript APIs on Cloudflare Workers, Deno, Bun and Node.js. Useful once the project already runs on Hono.
npx skills add Mindrally/skills --skill hono-typescript -a claude-codeWhat hono-typescript does
The skill feeds the agent a set of coding conventions: declare types for variables and functions, skip any, use import type for type-only imports, prefer interfaces over type aliases for object shapes, and reach for maps or const objects instead of enums. Naming is pinned down too — PascalCase for types, camelCase for functions, kebab-case for files, UPPERCASE for environment variables. Handlers and middleware are arrow functions, and the RO-RO pattern (receive an object, return an object) is the default shape.
A second block covers Hono itself: a project layout with routes, middleware, services and types folders, typed Bindings and Variables at app init, and route groups wired up with app.route(). Request validation goes through @hono/zod-validator with Zod schemas and inferred types. Errors are thrown as HTTPException and caught by a global app.onError. There are examples for Workers KV, D1 and R2, integration tests with testClient and Vitest, plus the four runtime entry points.
The skill installs nothing into your project and pulls no dependencies. It only describes how code should be written, so a fresh repo with no Hono and no Zod gets little out of it — the stack has to exist first. In a project that already uses Hono, though, it is a reason to check how far your current routes and validators drift from what the agent will start generating.
What it helps with
- keep agent-generated TypeScript consistent across a Hono codebase
- lay out folders for routes, middleware and services
- validate request bodies with Zod and infer the types
- route expected errors through a single HTTPException handler
- run the same app on Workers, Deno, Bun and Node.js
Example prompts for the agent
- add a POST /api/users route with zValidator and a Zod schema
- move auth into a typed middleware and apply it to /api/*
- set up a global onError so HTTPException returns JSON with the right status
How to install hono-typescript
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill hono-typescript -a claude-code2Manually: put the files in place
~/.claude/skills/hono-typescript/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/hono-typescript/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill hono-typescript -a codex2Manually: put the files in place
.agents/skills/hono-typescript/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill hono-typescript -a cursor2Manually: put the files in place
.cursor/skills/hono-typescript/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install Mindrally/skills hono-typescript2Manually: put the files in place
.github/skills/hono-typescript/SKILL.md1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill hono-typescript -a gemini-cli2Platform CLI
gemini skills install https://github.com/Mindrally/skills --path hono-typescriptManually: put the files in place
.devin/skills/hono-typescript/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add Mindrally/skills --skill hono-typescript -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about hono-typescript
How do I install hono-typescript in Claude?
Run npx skills add Mindrally/skills --skill hono-typescript -a claude-code. The skill file lands at ~/.claude/skills/hono-typescript/SKILL.md.
What does hono-typescript do?
It gives the agent rules for Hono and TypeScript API work: typing, naming, project structure, Zod validation, error handling and tests.
Which runtimes does the skill cover?
Cloudflare Workers, Deno, Bun and Node.js, each with its own way of starting the app.
Source text
SKILL.md · Apache-2.0
---
name: hono-typescript
description: Guidelines for building edge-first, high-performance APIs with Hono and TypeScript for Cloudflare Workers, Deno, Bun, and Node.js
metadata:
maintainer: Mindrally
source: https://github.com/Mindrally/skills
---
# Hono TypeScript Development
You are an expert in Hono and TypeScript development with deep knowledge of building ultrafast, edge-first APIs that run on Cloudflare Workers, Deno, Bun, and Node.js.
## TypeScript General Guidelines
### Basic Principles
- Use English for all code and documentation
- Always declare types for variables and functions (parameters and return values)
- Avoid using `any` type - create necessary types instead
- Use JSDoc to document public classes and methods
- Write concise, maintainable, and technically accurate code
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization to adhere to DRY principles
### Nomenclature
- Use PascalCase for types and interfaces
- Use camelCase for variables, functions, and methods
- Use kebab-case for file and directory names
- Use UPPERCASE for environment variables
- Use descriptive variable names with auxiliary verbs: `isLoading`, `hasError`, `canDelete`
- Start each function with a verb
### Functions
- Write short functions with a single purpose
- Use arrow functions for handlers and middleware
- Prefer the RO-RO pattern: Receive an Object, Return an Object
- Use default parameters instead of null checks
### Types and Interfaces
- Prefer interfaces over types for object shapes
- Avoid enums; use maps or const objects instead for better type safety
- Use Zod for runtime validation with inferred types
- Use `readonly` for immutable properties
- Use `import type` for type-only imports
## Hono-Specific Guidelines
### Project Structure
```
src/
routes/
{resource}/
index.ts
handlers.ts
validators.ts
middleware/
auth.ts
cors.ts
logger.ts
services/
{domain}Service.ts
types/
index.ts
utils/
config/
index.ts
```
### App Initialization
```typescript
import { Hono } from 'hono';
// Type your environment bindings
type Bindings = {
DB: D1Database;
KV: KVNamespace;
JWT_SECRET: string;
};
type Variables = {
user: User;
};
const app = new Hono<{ Bindings: Bindings; Variables: Variables }>();
```
### Routing
- Use method chaining for clean route definitions
- Group related routes with `app.route()`
- Use route parameters with proper typing
```typescript
const users = new Hono<{ Bindings: Bindings }>();
users.get('/', listUsers);
users.get('/:id', getUser);
users.post('/', zValidator('json', createUserSchema), createUser);
users.put('/:id', zValidator('json', updateUserSchema), updateUser);
users.delete('/:id', deleteUser);
app.route('/api/users', users);
```
### Middleware
- Use Hono's built-in middleware where available
- Create typed middleware for custom logic
- Chain middleware for composability
```typescript
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
import { jwt } from 'hono/jwt';
app.use('*', logger());
app.use('/api/*', cors());
app.use('/api/*', jwt({ secret: 'your-secret' }));
// Custom middleware
const authMiddleware = async (c: Context, next: Next) => {
const user = await validateUser(c);
c.set('user', user);
await next();
};
```
### Request Validation with Zod
- Use `@hono/zod-validator` for request validation
- Define schemas for all request inputs
- Infer types from Zod schemas
```typescript
import { z } from 'zod';
import { zValidator } from '@hono/zod-validator';
const createUserSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
role: z.enum(['user', 'admin']).default('user'),
});
type CreateUserInput = z.infer<typeof createUserSchema>;
app.post('/users', zValidator('json', createUserSchema), async (c) => {
const data = c.req.valid('json');
// data is typed as CreateUserInput
});
```
### Context and Response Handling
- Use typed context for better type safety
- Use helper methods for responses: `c.json()`, `c.text()`, `c.html()`
- Access environment bindings through context
```typescript
app.get('/users/:id', async (c) => {
const id = c.req.param('id');
const db = c.env.DB;
const user = await db.prepare('SELECT * FROM users WHERE id = ?')
.bind(id)
.first();
if (!user) {
return c.json({ error: 'User not found' }, 404);
}
return c.json(user);
});
```
### Error Handling
- Use Hono's `HTTPException` for expected errors
- Create global error handler middleware
- Return consistent error responses
```typescript
import { HTTPException } from 'hono/http-exception';
// Throwing errors
if (!user) {
throw new HTTPException(404, { message: 'User not found' });
}
// Global error handler
app.onError((err, c) => {
if (err instanceof HTTPException) {
return c.json({ error: err.message }, err.status);
}
console.error(err);
return c.json({ error: 'Internal Server Error' }, 500);
});
```
### Cloudflare Workers Integration
- Use Workers KV for key-value storage
- Use D1 for SQL databases
- Use R2 for object storage
- Use Durable Objects for stateful applications
```typescript
// D1 Database
const result = await c.env.DB.prepare('SELECT * FROM users').all();
// KV Storage
await c.env.KV.put('key', 'value');
const value = await c.env.KV.get('key');
// R2 Storage
await c.env.BUCKET.put('file.txt', content);
```
### Testing
- Use Hono's test client for integration tests
- Use Vitest or Jest as test runner
- Test handlers and middleware separately
```typescript
import { testClient } from 'hono/testing';
import { describe, it, expect } from 'vitest';
describe('User API', () => {
const client = testClient(app);
it('should list users', async () => {
const res = await client.api.users.$get();
expect(res.status).toBe(200);
const data = await res.json();
expect(Array.isArray(data)).toBe(true);
});
});
```
### Performance
- Hono is ultrafast with minimal overhead
- Use streaming responses for large data
- Leverage edge caching with Cache API
- Use `hono/tiny` preset for minimal bundle size
### Security
- Use `hono/secure-headers` middleware
- Implement rate limiting
- Validate all inputs with Zod
- Use JWT for authentication
- Enable CORS appropriately
### Multi-Runtime Support
Hono runs on multiple runtimes. Configure appropriately:
```typescript
// Cloudflare Workers
export default app;
// Node.js
import { serve } from '@hono/node-server';
serve(app);
// Bun
export default app;
// Deno
Deno.serve(app.fetch);
```
© Mindrally · Apache-2.0 · Mindrally/skills