ts-backend-standard
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.
适合你,如果正在维护或搭建 TypeScript 后端项目,需要统一代码规范
npx oh-my-skill add quanxiaoxiao/quan-skills/ts-backend-standardcurl -fsSL https://oh-my-skill.com/install.sh | bash -s -- quanxiaoxiao/quan-skills/ts-backend-standardnpx oh-my-skill verify quanxiaoxiao/quan-skills/ts-backend-standard怎么用
技能原文 SKILL.md
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
tsconfigoreslint.config.* - fix
npm run build,npm run typecheck, ornpm run lintregressions 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.mdAGENTS.mdpackage.jsontsconfig*.jsoneslint.config.*src/directory layout
Then load only the reference files needed for the task:
references/architecture.mdfor layering, service boundaries, pagination, or DRY refactorsreferences/typescript-eslint.mdfor compiler flags, lint tightening, and dependency policyreferences/hono-zod.mdfor route design, validation handoff, OpenAPI, and error responsesreferences/project-layout.mdfor directory layout and namingreferences/verification-workflow.mdfor script order and final reporting
Workflow
- Identify the current stack and preserve it where possible. If the repo already uses
@hono/zod-openapi, keepOpenAPIHonopluscreateRoute. If it uses plainhono, keep that style and still enforce Zod request boundaries.
- Map the repository onto these responsibilities:
routes -> schemas -> services -> modelsEquivalent 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
- JavaScript / TypeScript backend code must use functional programming style.
- Do not generate
classorabstract class. - Do not create service classes.
- Services must be functions or factory functions.
- To support unit testing, prefer splitting business logic into small functions with single responsibilities.
- Service-level validation, mapping, branching, and derived-value logic should be extracted into directly testable helpers or pure functions where practical.
- Prefer dependency injection via function parameters.
- Prefer composition over inheritance.
- Avoid constructor-based architecture.
Example service pattern:
export const createResourceService = (deps) => {
const createResource = async (input) => {
...
}
const queryResource = async (input) => {
...
}
return {
createResource,
queryResource
}
}
Never generate:
class ResourceService {}
- Each endpoint should define a schema object with
body,params, and/orqueryas 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 typechecknpm run lintnpm run testnpm run test:hurlwhen 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:
SummaryChangesVerificationRisks
Keep the response implementation-focused and concise.