hono-typescript
Skill275 starsChanged 53 days agoApache-2.0View on GitHub
Guidelines for building edge-first, high-performance APIs with Hono and TypeScript for Cloudflare Workers, Deno, Bun, and Node.js
- Reads credentials
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
41 rules. About 0 are common, 33 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈33
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use English for all code and documentation
- Distinctive: line 18
Always declare types for variables and functions (parameters and return values)
- Very specific: line 19
Avoid using any type - create necessary types instead
- Distinctive: line 20
Use JSDoc to document public classes and methods
- Distinctive: line 21
Write concise, maintainable, and technically accurate code
- Distinctive: line 22
Use functional and declarative programming patterns.
- Distinctive: line 23
Prefer iteration and modularization to adhere to DRY principles
- Distinctive: line 27
Use PascalCase for types and interfaces
- Distinctive: line 28
Use camelCase for variables, functions, and methods
- Distinctive: line 29
Use kebab-case for file and directory names
- Distinctive: line 30
Use UPPERCASE for environment variables
- Very specific: line 31
Use descriptive variable names with auxiliary verbs: isLoading, hasError, canDelete
- Distinctive: line 32
Start each function with a verb
- Distinctive: line 36
Write short functions with a single purpose
- Distinctive: line 37
Use arrow functions for handlers and middleware
- Distinctive: line 38
Prefer the RO-RO pattern: Receive an Object, Return an Object
- Distinctive: line 39
Use default parameters instead of null checks
- Distinctive: line 43
Prefer interfaces over types for object shapes
- Distinctive: line 44
Avoid enums; use maps or const objects instead for better type safety
- Distinctive: line 45
Use Zod for runtime validation with inferred types
- Very specific: line 46
Use readonly for immutable properties
- Very specific: line 47
Use import type for type-only imports
- Distinctive: line 94
Use method chaining for clean route definitions
- Distinctive: line 96
Use route parameters with proper typing
- Distinctive: line 112
Use Hono's built-in middleware where available
- Distinctive: line 113
Create typed middleware for custom logic
- Very specific: line 135
Use @hono/zod-validator for request validation
- Distinctive: line 159
Use typed context for better type safety
- Very specific: line 160
Use helper methods for responses: c.json(), c.text(), c.html()
- Very specific: line 182
Use Hono's HTTPException for expected errors
- Distinctive: line 183
Create global error handler middleware
- Distinctive: line 206
Use Workers KV for key-value storage
- Distinctive: line 207
Use D1 for SQL databases
- Distinctive: line 208
Use R2 for object storage
- Distinctive: line 209
Use Durable Objects for stateful applications
- Distinctive: line 225
Use Hono's test client for integration tests
- Distinctive: line 226
Use Vitest or Jest as test runner
- Distinctive: line 227
Test handlers and middleware separately
- Distinctive: line 248
Use streaming responses for large data
- Very specific: line 250
Use hono/tiny preset for minimal bundle size
- Distinctive: line 257
Use JWT for authentication
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
anytype - 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
readonlyfor immutable properties - Use
import typefor 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.tsApp Initialization
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
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
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-validatorfor request validation - Define schemas for all request inputs
- Infer types from Zod schemas
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
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
HTTPExceptionfor expected errors - Create global error handler middleware
- Return consistent error responses
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
// 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
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/tinypreset for minimal bundle size
Security
- Use
hono/secure-headersmiddleware - 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:
// Cloudflare Workers
export default app;
// Node.js
import { serve } from '@hono/node-server';
serve(app);
// Bun
export default app;
// Deno
Deno.serve(app.fetch);Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

