| name | ts-backend-standard |
| description | Standardize or review TypeScript backend repositories that use or want to use Hono, Zod, strict TypeScript, and strict ESLint. Use when users ask to scaffold, refactor, audit, tighten compiler or lint settings, or fix build/lint drift while preserving an existing backend's runtime choices. |
TS Backend Standard
Apply a portable backend baseline for existing repositories first and greenfield work second.
Use This Skill
Use this skill when the task is to:
- standardize a TypeScript backend structure
- add or refactor Hono routes
- introduce or tighten Zod validation boundaries
- harden
tsconfig or eslint.config.*
- fix
npm run build, npm run typecheck, or npm run lint regressions without weakening standards
Do not import Reblock-specific business rules, storage conventions, or domain models into the target repository.
Pre-Read Order
Read these sources before analysis or edits:
README.md
AGENTS.md
package.json
tsconfig*.json
eslint.config.*
src/ directory layout
Then load only the reference files needed for the task:
references/architecture.md for layering, service boundaries, pagination, or DRY refactors
references/typescript-eslint.md for compiler flags, lint tightening, and dependency policy
references/hono-zod.md for route design, validation handoff, OpenAPI, and error responses
references/project-layout.md for directory layout and naming
references/verification-workflow.md for script order and final reporting
Workflow
-
Identify the current stack and preserve it where possible.
If the repo already uses @hono/zod-openapi, keep OpenAPIHono plus createRoute.
If it uses plain hono, keep that style and still enforce Zod request boundaries.
-
Map the repository onto these responsibilities:
routes -> schemas -> services -> models
Equivalent folder names are acceptable if the responsibilities stay separated.
-
Enforce the core rules:
- routers own HTTP mapping, status codes, and response formatting only
- schemas own request contract definitions
- services own business logic and orchestration
- models own persistence only
- services must not depend on Hono
Context
- routers must not access models directly
- validated request data must be passed forward, not reparsed in services
-
Tighten standards with minimal necessary change.
Prefer targeted fixes, extracted helpers, and type narrowing over broad rewrites.
Do not relax TypeScript or ESLint rules to silence errors unless the user explicitly requests a softer policy.
-
Keep changes portable.
Favor pure JavaScript dependencies.
Reject native or WASM packages unless the user explicitly overrides that constraint.
Implementation Rules
- Each endpoint should define a schema object with
body, params, and/or query as needed.
- Validation output should be attached to request context through middleware or an equivalent typed helper.
- Keep JSON error responses consistent. If the repo already uses machine-readable error codes, preserve them.
- Prefer extraction over duplication. If similar logic appears twice, consolidate it.
- Preserve existing runtime/module choices unless the user explicitly asks to replatform them.
Verification
Always verify with repository scripts instead of ad hoc substitutes.
Default order:
npm run typecheck
npm run lint
npm run test
npm run test:hurl when route, API contract, or error-path behavior changed
If a script does not exist, report that clearly and continue with the remaining available scripts.
Output Contract
Return results in this order:
Summary
Changes
Verification
Risks
Keep the response implementation-focused and concise.