Comprehensive knowledge base for jzero framework (enhanced go-zero)...
Structured knowledge base optimized for AI agents to help developers work effectively with the jzero framework (enhanced go-zero).
This skill provides AI agents with comprehensive jzero knowledge to:
When helping with jzero development:
Reference: references/rest-api-patterns/api-file-structure.md
go_package, group, compact_handler)When to use: Creating or modifying REST API services, implementing HTTP endpoints
When to use: Creating or modifying RPC services, working with proto files, adding validation or middleware
โ ๏ธ CRITICAL REMINDER: ALWAYS use condition.NewChain() - NEVER use condition.New()
When to use: Implementing data persistence, queries, or database operations
Reference: Project Structure
.api file with required settings:jzero gen --desc desc/api/user.apiinternal/logic/ following three-layer architectureSee detailed patterns: REST API File Structure
Choose your schema mode first:
Local SQL Mode (schema files in desc/sql/):
desc/sql/*.sqldesc/sql_migration/ (xx.up.sql & xx.down.sql) โ ๏ธjzero migrate up, production: auto in cmd/server.go)jzero gen --desc desc/sql/users.sqlRemote Datasource Mode (schema from live database):
desc/sql_migration/ (xx.up.sql & xx.down.sql) โ ๏ธjzero migrate up, production: auto in cmd/server.go)jzero genCommon steps (both modes):
โ ๏ธ Migration rules: Always create both up/down files, use consecutive numbering (1, 2, 3...)
See detailed patterns: SQL Migration Guide | Database Best Practices
etc/etc.yaml:See detailed guide: Database Connection
jzero-skills/
โโโ SKILL.md # This file - skill entry point
โโโ references/ # Detailed pattern documentation
โ โโโ rest-api-patterns/ # REST API guides
โ โ โโโ api-file-structure.md # โ ๏ธ Critical rules for .api files
โ โโโ rpc-patterns/ # RPC/Proto service guides
โ โ โโโ proto-file-structure.md # Proto standards & multi-proto
โ โ โโโ proto-validation.md # Field validation guide
โ โ โโโ proto-middleware.md # Middleware patterns
โ โโโ database-patterns/ # Database operation guides
โ โโโ best-practices.md # โ ๏ธ Critical rules with examples
โ โโโ sql-migration.md # โ ๏ธ Schema changes & migrations
โ โโโ database-connection.md # DB & Redis setup
โ โโโ model-generation.md # Generate models from SQL
โ โโโ crud-operations.md # CRUD methods reference
Typical jzero project structure:
myproject/
โโโ .jzero.yaml # CLI config: code generation, โ ๏ธ migrate settings
โโโ desc/
โ โโโ api/ # .api files โ generates handlers
โ โโโ sql/ # .sql files โ generates models (local SQL mode)
โ โโโ sql_migration/ # xx.up.sql & xx.down.sql for schema changes โ ๏ธ
โ โโโ proto/ # .proto files โ generates RPC code
โโโ internal/
โ โโโ handler/ # HTTP handlers (generated)
โ โโโ logic/ # Business logic (implement here)
โ โโโ model/ # Data models (generated)
โ โโโ svc/ # Service context (dependencies)
โ โโโ config/ # Config structs
โ โโโ middleware/ # Custom middleware
โโโ etc/
โ โโโ etc.yaml # Configuration
โโโ .jzero.yaml # jzero CLI config
condition.NewChain(), NEVER use condition.New() - THIS IS CRITICAL ๐จgo_package, group, compact_handler: truexxmodel "project/internal/model/xx"errors.Is(err, model.ErrNotFound) from github.com/pkg/errorsjzero gen --desc before implementing logicusersmodel.Id)condition.New() - This is error-prone and deprecated. ALWAYS use condition.NewChain()go_package, group, or compact_handler in .api files"project/internal/model/users" (wrong)== for error comparison: if err == ErrNotFound (wrong)New to jzero?
jzero new myapi --frame apiBuilding REST APIs?
Creating RPC services?
Working with databases?
Production deployment?