| name | zero-skills |
| description | Comprehensive knowledge base for go-zero microservices framework. Use this skill when working with go-zero to understand correct patterns for REST APIs (Handler/Logic/Context architecture), RPC services (service discovery, load balancing), database operations (sqlx, MongoDB, caching), resilience patterns (circuit breaker, rate limiting), and troubleshooting common issues. Essential for generating production-ready go-zero code that follows framework conventions. |
| license | Apache-2.0 |
go-zero Skills for AI Agents
Structured knowledge base optimized for AI agents to help developers work effectively with the go-zero microservices framework.
Overview
This skill provides AI agents with comprehensive go-zero knowledge to:
- Generate accurate code following go-zero conventions
- Understand the three-layer architecture (Handler → Logic → Model)
- Apply best practices for microservices development
- Troubleshoot common issues efficiently
- Build production-ready applications
Quick Start
When helping with go-zero development:
- For new projects: Start with getting-started/quick-start.md
- For specific patterns: Reference the appropriate pattern guide
- For issues: Check troubleshooting/common-issues.md
- For best practices: See best-practices/overview.md
Core Patterns
REST API Development
Reference: references/rest-api-patterns.md
- Handler/Logic/Context three-layer architecture
- Request validation and error handling
- Middleware implementation (auth, logging, metrics)
- Response formatting with httpx
- Complete CRUD examples with ✅ correct and ❌ incorrect patterns
When to use: Creating or modifying REST API services, implementing HTTP endpoints
RPC Services
Reference: references/rpc-patterns.md
- Protocol Buffers definitions and code generation
- Service discovery with etcd/consul
- Load balancing strategies
- Error handling and timeout configuration
- Client-server communication patterns
When to use: Building gRPC services, implementing service-to-service communication
Database Operations
Reference: references/database-patterns.md
- SQL operations with sqlx (CRUD, transactions, batch operations)
- MongoDB integration patterns
- Redis caching strategies
- Connection pooling and performance optimization
- Model generation with goctl
When to use: Implementing data persistence, caching, or database queries
Resilience Patterns
Reference: references/resilience-patterns.md
- Circuit breaker configuration
- Rate limiting and throttling
- Load shedding under high load
- Timeout and retry strategies
- Graceful degradation
When to use: Ensuring service reliability, handling failures, managing system load
Integration with AI Tools
This skill works seamlessly with the go-zero AI ecosystem:
- ai-context: Concise instructions for GitHub Copilot, Cursor, Windsurf
- mcp-zero: Runtime tools for Claude Desktop/Code (goctl integration)
See articles/ai-ecosystem-guide.md for complete integration guide.
Project Structure
zero-skills/
├── SKILL.md # This file - skill entry point
├── getting-started/ # Quick start guides
│ └── quick-start.md
├── references/ # Detailed pattern documentation
│ ├── rest-api-patterns.md
│ ├── rpc-patterns.md
│ ├── database-patterns.md
│ └── resilience-patterns.md
├── best-practices/ # Production recommendations
│ └── overview.md
├── troubleshooting/ # Common issues and solutions
│ └── common-issues.md
├── articles/ # In-depth guides
│ └── ai-ecosystem-guide.md
└── examples/ # Demo projects and scripts
├── verify-tutorial.sh
└── demo-project/
Common Workflows
Creating a New REST API Service
- Define API specification in
.apifile - Generate code with
goctl api go -api user.api -dir . - Implement business logic in
logiclayer - Add validation and error handling
- Test with httpx utilities
See complete workflow in references/rest-api-patterns.md
Implementing Database Operations
- Design database schema
- Generate model with
goctl model mysql datasource - Inject model into ServiceContext
- Use sqlx for queries in logic layer
- Handle transactions and errors properly
See complete patterns in references/database-patterns.md
Adding Middleware
- Create middleware function in
internal/middleware/ - Register in route configuration
- Implement authentication/authorization logic
- Pass data through request context
- Handle errors appropriately
See middleware patterns in references/rest-api-patterns.md#middleware
Key Principles
✅ Always Follow
- Three-layer architecture: Handler → Logic → Model separation
- Error handling: Use structured errors, not
fmt.Errorfin APIs - Configuration: Load config with
conf.MustLoad - Context propagation: Pass
ctxthrough all layers - Type safety: Define types in
.apifiles, generate with goctl
❌ Never Do
- Put business logic in handlers
- Ignore errors or use bare
fmt.Errorffor HTTP errors - Hard-code configuration values
- Skip validation of user inputs
- Bypass the three-layer architecture
Progressive Learning
New to go-zero?
- Start with getting-started/quick-start.md
- Build a simple REST API using references/rest-api-patterns.md
- Add database operations from references/database-patterns.md
Building production services?
- Review best-practices/overview.md
- Implement resilience patterns from references/resilience-patterns.md
- Reference troubleshooting/common-issues.md for common pitfalls
Extending capabilities?
- Check articles/ai-ecosystem-guide.md
- Use examples/demo-project/ to test configurations
- Run examples/verify-tutorial.sh to validate setup
Resources
- Official documentation: go-zero.dev
- GitHub repository: zeromicro/go-zero
- Community: Join go-zero developer community (see main repo README)
Version Compatibility
This skill targets go-zero 1.5+. Patterns are updated regularly to reflect framework evolution. Always check official documentation for the latest API changes.