This guide explains how to use zero-skills with OpenAI Codex, the AI coding agent from OpenAI.
cd your-gozero-project/
# Clone to a local directory
git clone https://github.com/zeromicro/zero-skills.git .ai-context/zero-skillsCreate AGENTS.md in your project root:
# go-zero Development Instructions
You are an expert in go-zero microservices framework development.
## Architecture
Follow the three-layer architecture strictly:
- **Handler**: HTTP routing and request/response handling only
- **Logic**: All business logic goes here, injected via ServiceContext
- **Model**: Data access and database operations, generated by goctl
## Code Patterns
### REST API Logic
```go
func (l *UserLogic) GetUser(req *types.GetUserReq) (*types.GetUserResp, error) {
user, err := l.svcCtx.UserModel.FindOne(l.ctx, req.Id)
if err != nil {
return nil, err
}
return &types.GetUserResp{
Id: user.Id,
Name: user.Name,
}, nil
}- Use
httpx.Error(w, err)for HTTP errors - Use
httpx.OkJson(w, resp)for success responses - Never use
fmt.Fprintf()orw.Write()directly
- Load with
conf.MustLoad(&c, *configFile) - Never hard-code ports, hosts, or credentials
- Use environment-specific YAML files
- Always pass
ctx context.Contextthrough all layers - Use context for tracing, cancellation, and timeouts
# Generate API service code
goctl api go -api user.api -dir .
# Generate RPC service code
goctl rpc protoc user.proto --go_out=. --go-grpc_out=. --zrpc_out=.
# Generate model from database
goctl model mysql datasource -url="user:pass@tcp(localhost:3306)/db" -table="users" -dir="./model"- Never put business logic in handlers
- Always use ServiceContext for dependency injection
- Always pass ctx through all layers
- Use goctl for code generation, never hand-write boilerplate
- API definitions go in
.apifiles; RPC definitions go in.protofiles
Detailed patterns are in .ai-context/zero-skills/:
- REST APIs:
references/rest-api-patterns.md - RPC services:
references/rpc-patterns.md - Database:
references/database-patterns.md - Resilience:
references/resilience-patterns.md - Troubleshooting:
troubleshooting/common-issues.md
## Usage
### Running Codex
Run Codex from your project directory:
```bash
codex "Create a user management REST API with go-zero including CRUD operations"
Codex will read AGENTS.md automatically and apply go-zero patterns to all generated code.
For detailed patterns, tell Codex to read the relevant file:
Read .ai-context/zero-skills/references/rest-api-patterns.md and help me implement a user API
Creating a REST API:
Create a user management REST API with CRUD operations following go-zero patterns
Adding RPC service:
Add a gRPC user service following the go-zero rpc patterns in .ai-context/zero-skills/references/rpc-patterns.md
Database integration:
Read .ai-context/zero-skills/references/database-patterns.md and add MySQL support with caching to my user service
Troubleshooting:
Read .ai-context/zero-skills/troubleshooting/common-issues.md and help me fix this error: ...
-
Define the API file:
Create a user.api file for a user management service with login, register, and profile endpoints -
Generate code:
goctl api go -api user.api -dir . -
Implement logic:
Implement the business logic for all user handlers following go-zero patterns
-
Generate the model:
goctl model mysql datasource -url="user:pass@tcp(localhost:3306)/db" -table="users" -dir="./model"
-
Wire it up:
Add the user model to ServiceContext and implement data access in the logic layer
Codex reads AGENTS.md for every task. Keep it concise:
- Core principles only
- Short code examples
- Reference external files for detailed patterns
Codex handles multi-file changes well. Describe the full feature:
Add JWT authentication to all protected API routes, following go-zero middleware patterns
For a richer context setup, use ai-context alongside zero-skills:
git clone https://github.com/zeromicro/ai-context.git .ai-context/ai-contextThen reference both in AGENTS.md:
Follow workflows from .ai-context/ai-context/
For detailed go-zero patterns, see .ai-context/zero-skills/Compared to Claude Code, Codex:
- No native skills support (YAML frontmatter not used)
- No automatic skill loading by file type
- No subagent workflows
- Manual file references needed for detailed patterns
Problem: Codex doesn't follow go-zero patterns.
Solutions:
- Ensure
AGENTS.mdexists in the project root where you runcodex - Check that the file is valid Markdown
- Reference pattern files explicitly in your prompt
Problem: Instructions are too long and patterns are ignored.
Solutions:
- Keep
AGENTS.mdunder 500 lines - Move detailed patterns to separate files in
.ai-context/zero-skills/ - Reference them on demand in prompts