go-feature
Skill3 starsChanged 9 months agoMITView on GitHub
Use when implementing a new feature, endpoint, or use case in a Go/Fiber backend with clean architecture and PostgreSQL
In this repository36 other files it gives its agents.
- adrSkill
- analyticsSkill
- api-contractSkill
- api-designSkill
- ci-pipelineSkill
- claude-mdSkill
- code-qualitySkill
- data-modelSkill
- db-migrateSkill
- debugSkill
- deploySkill
- dep-updateSkill
- disk-cleanupSkill
- docker-buildSkill
- eng-leadSkill
- event-drivenSkill
- fullstack-healthcheckSkill
- go-integration-testSkill
- go-refactorSkill
- go-scaffoldSkill
- incident-responseSkill
- interactive-clarifySkill
- observabilitySkill
- onboardingSkill
- product-specSkill
- py-featureSkill
- py-integration-testSkill
- py-migrateSkill
- py-refactorSkill
- py-scaffoldSkill
- react-featureSkill
- react-refactorSkill
- react-scaffoldSkill
- review-codeSkill
- securitySkill
- system-designSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Core principle: Every layer gets its own test before implementation.
- Very specific: line 87
Test with mocks: Use testify/mock or manual mocks for the repository interface.
- Very specific: line 132
Every handler MUST have swaggo annotations: Add example tags to DTO structs.
- Very specific: line 134
Use generic pkg.ValidateBody[T], pkg.ValidateQuery[T], pkg.ValidateParams[T] — never manually parse + validate.
- Very specific: line 136
Test: Use app.Test(httptest.NewRequest(...)) for HTTP-level tests.
- Very specific: line 166
REQUIRED: Follow code-quality standards — no N+1 queries, batch operations, pre-allocated slices, indexed columns, O(n) not O(n^2)
- Very specific: line 167
REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (claude-md)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Feature Development
Overview
Layer-by-layer TDD workflow for Go/Fiber backends following clean architecture. Build inside-out: domain → application → infrastructure → interfaces.
Core principle: Every layer gets its own test before implementation. Never skip a layer.
When to Use
- Adding a new API endpoint to a Go/Fiber service
- Implementing a new use case or business logic
- Adding CRUD operations with PostgreSQL
- Building domain entities with validation
Layer-by-Layer Workflow
1. Domain Entity + Validation
// internal/domain/user.go
type User struct {
ID uuid.UUID
Email string
Name string
CreatedAt time.Time
}
func NewUser(email, name string) (*User, error) {
if email == "" {
return nil, ErrEmptyEmail
}
// validation...
}Test first: Table-driven tests for all validation rules.
func TestNewUser(t *testing.T) {
tests := []struct {
name string
email string
wantErr error
}{
{"valid", "a@b.com", nil},
{"empty email", "", ErrEmptyEmail},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := NewUser(tt.email, "name")
assert.ErrorIs(t, err, tt.wantErr)
})
}
}2. Repository Interface (in domain)
// internal/domain/user_repository.go
type UserRepository interface {
Create(ctx context.Context, user *User) error
GetByID(ctx context.Context, id uuid.UUID) (*User, error)
GetByEmail(ctx context.Context, email string) (*User, error)
}3. Use Case + Mock Tests
// internal/application/create_user.go
type CreateUserUseCase struct {
repo domain.UserRepository
}
func (uc *CreateUserUseCase) Execute(ctx context.Context, input CreateUserInput) (*domain.User, error) {
// validate, create entity, persist
}Test with mocks: Use testify/mock or manual mocks for the repository interface.
4. PostgreSQL Repository + Integration Test
// internal/infrastructure/postgres/user_repository.go
type userRepository struct {
pool *pgxpool.Pool
}Test with testcontainers: Real Postgres, real queries.
REQUIRED: Invoke go-integration-test for testcontainers patterns.
5. Fiber Handler + HTTP Test
// internal/interfaces/http/user_handler.go
// CreateUser godoc
// @Summary Create a new user
// @Description Create a new user account
// @Tags users
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param request body dto.CreateUserRequest true "Create user request"
// @Success 201 {object} dto.UserResponse
// @Failure 400 {object} pkg.ErrorResponse "Validation error"
// @Failure 401 {object} pkg.ErrorResponse "Unauthorized"
// @Failure 500 {object} pkg.ErrorResponse "Internal server error"
// @Router /api/v1/users [post]
func (h *UserHandler) Create(c fiber.Ctx) error {
body, err := pkg.ValidateBody[CreateUserRequest](c)
if err != nil {
return err // returns structured ErrorResponse automatically
}
result, err := h.useCase.Execute(c.Context(), body.ToDomain())
if err != nil {
return mapDomainError(err)
}
return c.Status(201).JSON(result.ToResponse())
}Every handler MUST have swaggo annotations. Add example tags to DTO structs. Run swag init -g cmd/api/main.go -o docs after adding/changing handlers. See api-design for full annotation reference.
Use generic pkg.ValidateBody[T], pkg.ValidateQuery[T], pkg.ValidateParams[T] — never manually parse + validate. Validation uses struct tags (validate:"required,email") with go-playground/validator/v10. Supports default tags for zero-value defaults.
Test: Use app.Test(httptest.NewRequest(...)) for HTTP-level tests.
6. Route Registration
api := app.Group("/api/v1")
users := api.Group("/users")
users.Post("/", userHandler.Create)
users.Get("/:id", userHandler.GetByID)Quick Reference
| Layer | Package | Tests | Dependencies |
| Domain | internal/domain/ | Unit (table-driven) | None |
| Application | internal/application/ | Unit (mocked repo) | Domain |
| Infrastructure | internal/infrastructure/ | Integration (testcontainers) | Domain |
| Interfaces | internal/interfaces/http/ | HTTP (fiber test) | Application |
Common Patterns
- DTOs: Request/Response structs in interfaces layer, never expose domain directly
- Errors: Domain errors → HTTP status mapping in handler middleware
- Pagination: Offset-based (
limit/offset), repo returns(items, total, error), handler wraps inPaginatedResponse - Transactions:
UnitOfWorkinterface in domain, implemented in infrastructure
Chains
- REQUIRED: Invoke
superpowers:test-driven-developmentat each layer - REQUIRED: Follow
code-qualitystandards — no N+1 queries, batch operations, pre-allocated slices, indexed columns, O(n) not O(n^2) - REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (
claude-md) - Schema changes: Invoke
db-migratebefore implementing repository - API conventions: Reference
api-designfor request/response patterns
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

