skeleton-api-go-skill
2
总安装量
2
周安装量
#73815
全站排名
安装命令
npx skills add https://github.com/joseluis21/go-api-skills --skill skeleton-api-go-skill
Agent 安装分布
amp
2
github-copilot
2
codex
2
kimi-cli
2
gemini-cli
2
cursor
2
Skill 文档
Skeleton API Go Skill
This skill helps you rapidly scaffold new Go API projects with a proven, production-ready structure.
What It Sets Up
A complete Go API project with:
| Component | Tech |
|---|---|
| Framework | Fiber (lightweight, fast HTTP) |
| Database | MongoDB |
| Storage | AWS S3 / Cloudflare R2 |
| Docker | Multi-stage builds, docker-compose |
| Structure | Layered architecture (routes, middleware, services) |
| Validation | Go Playground Validator |
| Logging | Structured logging (slog + JSON) |
| UUID | UUIDv7 generation |
Directory Structure
project-name/
âââ cmd/api/main.go # Entry point
âââ internal/
â âââ container/ # Dependency injection
â âââ routes/ # Public & private routes
â âââ middleware/ # Request validation, auth, etc.
â âââ server/ # Server initialization
â âââ libraries/
â â âââ cloudflare/r2_client.go
â â âââ mongodb/mongodb_client.go
â âââ shared/
â âââ response/ # HTTP response helpers
â âââ utils/ # Utilities (MongoDB, R2, UUID, etc.)
â âââ validatorapi/ # Validation helpers
âââ .env.example
âââ Dockerfile
âââ docker-compose.yml
âââ go.mod & go.sum
âââ README.md
Usage
When asked to “create a new Go API project” or similar, Claude will:
Step 1: Gather Requirements
- Project name
- Go module name (e.g.,
github.com/username/project) - Base features (MongoDB, R2, routes structure)
Step 2: Generate Structure
This skill automates:
- Creating directory structure
- Generating
go.modwith core dependencies - Creating boilerplate files (main.go, server setup, routes)
- Docker and docker-compose files
- Environment template (.env.example)
Step 3: Provide Setup Steps
Clear commands to initialize and run the project:
cd project-name
go mod tidy
docker-compose up -d # If using MongoDB locally
go run ./cmd/api/main.go
Key Features Included
1. Layered Architecture
- Clean separation: routes â middleware â handlers â services
- Easy to test and maintain
2. Dependency Injection (container.go)
- Centralized container for all dependencies
- Pass services cleanly through the app
3. Shared Response Format
- Consistent JSON responses
- Error handling with proper HTTP status codes
4. Validation
- Input validation middleware
- Built-in request validation helpers
5. Logging
- Structured, JSON-based logging (slog)
- Debug, info, error levels
6. Database & Storage Setup
- MongoDB client initialization
- R2/S3 client initialization
- Ready-to-use utility functions
Implementation Details
The skill will generate:
- main.go: Loads .env, initializes MongoDB, R2, sets up server
- server.go: Fiber server with routes and middleware registration
- container.go: Dependency container pattern
- routes files: Separated public and private routes
- middleware/validator.go: Request validation middleware
- Dockerfile: Multi-stage build (builder + runtime Alpine)
- docker-compose.yml: Local MongoDB setup
- .env.example: Template for environment variables
Customization Points
Once generated, you can easily:
- Add more routes (edit
internal/routes/) - Add middleware (edit
internal/middleware/) - Change database operations (edit internal services)
- Modify Docker settings (edit Dockerfile & docker-compose.yml)
Next Steps After Generation
- Replace placeholder names in files (project name, module name)
- Update README.md with your specific API endpoints
- Add domain-specific handlers in
internal/routes/ - Create service layer for business logic
- Implement actual database models in MongoDB