百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

clhoria-template

> 后端框架
开源

生产就绪的 Hono 后端模板同时也是一个 AI 代理平台,提供正向指导、反馈传感器和逐步专业化,以满足 m

189 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

生产就绪的 Hono 后端模板同时也是一个 AI 代理平台,提供正向指导、反馈传感器和逐步专业化,以满足 m

Clhoria - Harness-Engineered Backend Template

English | 简体中文

Production-ready Hono backend template that doubles as an AI agent harness — providing feedforward guides, feedback sensors, and progressive specialization to make AI coding agents reliably produce architecture-conformant code.

"The software engineering team's primary job is no longer to write code, but to design environments, specify intent, and build feedback loops." — OpenAI

Frontend admin panel based on Refine + Shadcn: https://github.com/zhe-qi/refine-project

Harness Engineering

Agent = Model + Harness — Birgitta Böckeler, Martin Fowler

An AI coding agent's reliability depends not on the model alone, but on the harness surrounding it: everything that steers the agent before it acts (Guides / Feedforward) and observes after it acts (Sensors / Feedback). This template is a project-level specialization layer — the bridge between generic AI capabilities and project-specific correctness.

This Template as a Harness

Harness Role Component What It Does
Guide (Feedforward) CLAUDE.md Context engineering: rules, conventions, response patterns
Guide (Feedforward) Skills (/crud, /db-schema, /bullmq, /drizzle-v1) Structured templates that pre-steer code generation
Guide (Feedforward) OpenSpec (/opsx:propose → /opsx:apply) Planning layer: specs become the primary artifact
Guide (Feedforward) Schema Pipeline (Drizzle → Zod → OpenAPI → Types) Architectural constraints that narrow the solution space
Guide (Feedforward) VSCode Snippets IDE-level feedforward for manual coding
Sensor (Feedback) TypeScript + tsgo Compile-time type checking catches structural errors
Sensor (Feedback) ESLint + nano-staged Style and convention enforcement on every commit
Sensor (Feedback) Vitest Behavioral verification: does the code do what we intend?
Sensor (Feedback) Casbin RBAC + Tier Routing Permission guardrails: architecture-enforced boundaries

Progressive Specialization > Generalization

Generic AI + blank project = high variance output. Specialized template + harness = predictable, architecture-conformant output.

  • Deeper project understanding — agents reason within established patterns, not from scratch
  • Higher code quality — narrower solution space = fewer hallucinations, more correct code
  • Consistent patterns — every module follows the same structure, every schema the same layering
  • Better testability — conventions enable templated, comprehensive test generation
  • More reliable output — guides prevent common mistakes; sensors catch the rest

The more you invest in specializing the harness (adding skills, refining CLAUDE.md, expanding tests), the more reliably the AI agent produces correct code. This applies to any AI coding agent — not just Claude Code.

Features

Feedforward Guides (Steer Before Acting)

  • Schema-Driven Pipeline: Drizzle ORM (v1) → Zod v4 → OpenAPI 3.1 → TypeScript types, single source of truth from database to API documentation
  • Structured Skills: /crud, /db-schema, /bullmq, /drizzle-v1 — pre-built templates that guide AI agents through standardized code generation
  • OpenSpec Workflow: OpenSpec AI-native change management (/opsx:propose → /opsx:apply → /opsx:archive), turning specifications into the primary development artifact
  • CLAUDE.md Context Engineering: Comprehensive project rules, conventions, response patterns, and workflow orchestration for AI agent alignment
  • Declarative DSL Architecture: defineConfig drives application assembly, defineMiddleware declares middleware chains, entry file stays minimal
  • VSCode Code Snippets: IDE-level templates for rapid CRUD scaffolding

Feedback Sensors (Observe After Acting)

  • Full-Chain Type Safety: Hono + Zod + TypeScript + tsgo, compile-time error detection across the entire request-response pipeline
  • Vitest Test Infrastructure: Unit tests and integration tests, co-located with route modules, AI-generated and AI-verifiable
  • ESLint + Pre-commit Hooks: nano-staged enforces lint and typecheck on every commit
  • Multi-Layer Auth Sensors: Dual JWT keys (Admin/Client isolation) + Casbin RBAC + KeyMatch3 RESTful path matching — architecture-enforced permission boundaries

Production Infrastructure

  • Modern Tech Stack: Hono + Node.js 25 + TypeScript 6.0+ + Vite + PostgreSQL
  • Progressive Layering: Functional development standards, multi-tier routing structure, optional DDD for complex business logic
  • Automated Documentation: OpenAPI 3.1 spec + Scalar UI, code as documentation with online debugging and type generation
  • Declarative Paginator: Secure declarative queries based on Refine spec, extended Refine query with backend-only JOIN support
  • Complete Permission System: User management + Role management + Casbin policies + Refine Resource compile-time menu routing, zero runtime overhead
  • Business + System Dictionary: Business dictionaries support runtime dynamic configuration (JSONB + Redis cache), system dictionaries use PostgreSQL Enum for compile-time type checking
  • Logging Middleware: Collects logs with support for multiple log storage backends (AWS CloudWatch, Loki, TimescaleDB, etc.)
  • High-performance Cache: Redis caching + multi-layer rate limiting + permission caching + session management + distributed locks
  • Task Queue & Scheduling: Background task queue management and scheduled tasks based on BullMQ + Redis (distributed-safe, supports repeatable jobs, Bull Board UI)
  • Functional Infrastructure: Infrastructure layer built on Effect-TS with type-safe dependency injection, composable error handling, structured concurrency
  • Object Storage: Integrated S3-compatible object storage (supports Cloudflare R2, AWS S3, MinIO, etc.)
  • Smart CAPTCHA: Integrated Cap.js, lightweight modern CAPTCHA based on SHA-256 proof-of-work, privacy-friendly with zero tracking
  • Monitoring System: Integrated Sentry error tracking, supports self-hosted or cloud-native solutions (cloud services recommended for small teams, maintenance-free)
  • Excel Processing: High-performance Excel processing based on excelize-wasm, singleton lazy loading, powered by Go-native excelize via WASM
  • Instant Feedback Development: Vite-powered hot-reload dev environment, millisecond-level code updates for ultimate development experience

Drizzle ORM Version

This project provides two Drizzle ORM versions for you to choose from:

Branch Drizzle Version Description
main v1 (1.0.0-beta) Latest version with Relations v2, through many-to-many, predefined filters
drizzle-v0 v0 (0.x stable) Stable version with classic Relations API, battle-tested
bash
# Use Drizzle v1 (default)
git clone https://github.com/zhe-qi/clhoria-template.git

# Use Drizzle v0 (stable)
git clone -b drizzle-v0 https://github.com/zhe-qi/clhoria-template.git

Migration Note: Drizzle v1 introduces breaking changes in the Relations API. See the Drizzle v1 migration guide for details.

Quick Start

Local Development Environment

  • Node.js >= 24 (latest recommended)
  • pnpm >= 10 (use the version specified in packageManager field of package.json)
  • PostgreSQL >= 18 (if using 17, refer to the downgrade guide in this README for easy downgrade)
  • Redis >= 7 (7 or latest both work)

Installation Steps

  1. Clone the repository

    bash
    git clone https://github.com/zhe-qi/clhoria-template
    cd clhoria-template
  2. Install dependencies

    bash
    npm i -g corepack
    pnpm install
  3. Configure environment variables

    bash
    cp .env.example .env
  4. Initialize database

    bash
    # Start PostgreSQL service (optional, quickly set up PostgreSQL database in local Docker environment)
    docker compose --env-file .env run -d --service-ports postgres
    
    # Start Redis service (optional, quickly set up Redis in local Docker environment)
    docker compose --env-file .env run -d --service-ports redis

    Note: If using Docker services above, update your .env to use localhost instead of container hostnames:

    • DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
    • REDIS_URL="redis://localhost:6379/0"
    bash
    # Execute database migration (for rapid dev iteration use pnpm push directly, reserve generate and migrate for important milestones)
    pnpm migrate
    
    # Seed initial data (optional, app will auto-check and initialize on startup)
    pnpm seed

Production Deployment

For production deployment, use migration files instead of pnpm push:

bash
pnpm generate  # Generate migration files
pnpm migrate   # Execute migrations
  1. Start development server
    bash
    pnpm dev

Visit to view the API documentation.

TypeScript 6.0+ and ts-go Support

This project supports using the experimental ts-go to enhance TypeScript type checking and language service performance. At the current project scale, ts-go provides very significant performance improvements and the language service is relatively stable, so it is recommended.

Using ts-go (Recommended)

Install the VSCode extension: TypeScript Native Preview

Note: Currently ts-go is only used for type checking and language service. Development and bundling are based on Vite (Rolldown).

Cache Issues: If you encounter TS service errors or type cache anomalies, use Cmd + Shift + P to open the command palette, type restart, and find TypeScript: Restart TS Server to restart the TS service and restore normal operation.

Performance Tip: Zod has significant performance overhead on type services. ts-go notably improves this. If you can tolerate occasional cache issues, it is still recommended to use ts-go for a better development experience.

Not Using ts-go

If you prefer not to use ts-go, follow these steps to revert:

  1. Remove "js/ts.experimental.useTsgo": true from .vscode/settings.json
  2. Run pnpm remove @typescript/native-preview
  3. Modify the typecheck command in package.json, changing pnpm exec tsgo --noEmit to tsc --noEmit

Development Methodology: SDD + TDD

This project combines Specification-Driven Development (SDD) with Test-Driven Development (TDD), orchestrated through the harness system. Specifications become the primary artifact; tests become the verification layer; code becomes an implementation detail.

SDD inverts the traditional development hierarchy — specifications define what before how. TDD adds a verification dimension — tests define _expected behavio

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptbackend-boilerplatebackend-templatehono-boilerplate

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架