Go Fiber + Ent ORM + MySQL Cursor Rules Template
Copyable Cursor Rules Template for Go Fiber with Ent ORM and MySQL to guide Cursor AI-driven development.
Target User
Go developers building APIs with Go Fiber, Ent ORM, and MySQL
Use Cases
- REST API services with Go Fiber
- Ent ORM data layer with MySQL
- Cursor AI-assisted code generation and guidance
- Consistent testing and linting pipelines
Markdown Template
Go Fiber + Ent ORM + MySQL Cursor Rules Template
framework_role_context: >
You are a Go engineering assistant specialized in Go Fiber, Ent ORM, and MySQL.
Produce production-ready code scaffolding, API handlers, and Ent schemas with MySQL backing store.
code_style_and_style_guides:
- gofmt -w
- go vet ./...
- golangci-lint run
architecture_and_directory_rules:
root_structure:
- cmd/
- internal/
- infra/
- ent/
important_files:
- go.mod
- go.sum
- Makefile
authentication_and_security_rules:
- JWT-based stateless auth via middleware
- Secrets loaded from environment; do not hardcode
- Use secure cookies for web sessions when applicable
database_and_orm_patterns:
- Ent ORM used for all data access
- MySQL DSN from environment: MYSQL_DSN
- Schema migrations driven by entc; generated code under ent/
testing_and_linting_workflows:
- go test ./...
- go vet ./...
- golangci-lint run
prohibited_actions_and_anti_patterns:
- Do not embed raw SQL strings outside Ent query builders
- Do not bypass Ent schema validations
- Do not disable context timeouts in requestsOverview
Cursor rules configuration for the Go Fiber + Ent ORM + MySQL stack. This Cursor Rules Template provides a copyable .cursorrules block and stack-specific guidance so developers can paste it into the project root and start Cursor AI-assisted development immediately.
Direct answer: This template defines how Cursor AI interacts with Go Fiber services, Ent ORM schemas, and a MySQL data store, with concrete patterns for routing, data access, testing, and security.
When to Use These Cursor Rules
- Starting a new Go Fiber service that uses Ent ORM with MySQL
- Standardizing project structure, dependency injection, and API routing
- Enforcing authentication, input validation, and secure data access
- Ensuring reproducible Ent migrations and Go tooling setups
Copyable .cursorrules Configuration
framework_role_context: >
You are a Go engineering assistant specialized in Go Fiber, Ent ORM, and MySQL.
Produce production-ready code scaffolding, API handlers, and Ent schemas with MySQL backing store.
code_style_and_style_guides:
- gofmt -w
- go vet ./...
- golangci-lint run
architecture_and_directory_rules:
root_structure:
- cmd/
- internal/
- infra/
- ent/
important_files:
- go.mod
- go.sum
- Makefile
authentication_and_security_rules:
- JWT-based stateless auth via middleware
- Secrets loaded from environment; do not hardcode
- Use secure cookies for web sessions when applicable
database_and_orm_patterns:
- Ent ORM used for all data access
- MySQL DSN from environment: MYSQL_DSN
- Schema migrations driven by entc; generated code under ent/
testing_and_linting_workflows:
- go test ./...
- go vet ./...
- golangci-lint run
prohibited_actions_and_anti_patterns:
- Do not embed raw SQL strings outside Ent query builders
- Do not bypass Ent schema validations
- Do not disable context timeouts in requests
Recommended Project Structure
.
├── cmd/
│ └── app/
├── internal/
│ ├── handlers/
│ │ └── v1/
│ ├── middleware/
│ └── repository/
├── ent/
│ ├── ent.go
│ └── schema/
├── infra/
│ └── db/
│ ├── mysql.go
│ └── migrations/
├── config/
│ └── config.go
├── go.mod
Core Engineering Principles
- Strong typing and explicit interfaces enable testability and refactoring
- Separation of concerns: HTTP layer, business logic, and data access via Ent
- Idempotent migrations and deterministic builds
- Environment-based configuration; no hardcoded secrets
- Automated testing, linting, and CI validation
Code Construction Rules
- Initialize Go Fiber app and mount routes in cmd/app/main.go
- Initialize Ent client in infra/db/mysql.go using DSN from environment
- Use dependency injection to pass Ent client to handlers
- Define Ent schemas under ent/schema and generate with entc
- Return JSON with proper status codes; wrap errors with context
- Use environment-based configuration for server port, DB, and secrets
Security and Production Rules
- Enable TLS and disable debug logging in production
- JWT-based authentication on protected routes; rotate secrets
- Do not log sensitive data; mask credentials in logs
- Limit request sizes and implement rate limiting
Testing Checklist
- Unit tests for handlers and services
- Integration tests against a test MySQL database
- End-to-end tests with a minimal HTTP server
- CI runs go test, golangci-lint, and builds artifacts
Common Mistakes to Avoid
- Using raw SQL instead of Ent query builders
- Skipping migrations or bypassing ent/schema
- Hardcoding secrets or using insecure defaults
- Not validating inputs or returning opaque errors
FAQ
Is this Cursor Rules Template compatible with MySQL?
Yes. The template targets MySQL via Ent ORM, with DSN loaded from environment and migrations guided by Ent tooling.
What should I paste into my repository?
Paste the Copyable .cursorrules Configuration block into your project root as a .cursorrules file and follow the Recommended Project Structure. Cursor AI will tailor code and files accordingly for Go Fiber + Ent ORM + MySQL.
Do the rules enforce security?
Yes. JWT authentication, environment-based secrets, input validation, and rate limiting are specified in the rules for production safety.
Can I adapt this to a different ORM?
Adaptation is possible but requires updating the ORM-specific sections to match the intended framework. Maintain the architecture and testing constraints aligned with the Fiber + Ent pattern.
How do I run tests?
Run go test ./... in the project root. Use the included linting and CI steps to ensure code quality before merging changes.