From gopilot
Add a new business domain to the Go backend with repository, service, and types following domain-driven architecture. Use when adding a new feature area like items, bookings, users, etc.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gopilot:domainThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are adding a new domain to the Go backend. Domains are isolated business areas with their own types, repository (DB access), and service (business logic).
You are adding a new domain to the Go backend. Domains are isolated business areas with their own types, repository (DB access), and service (business logic).
skills/_shared/go-patterns.md for conventionsreferences/architecture.md for the architecture overviewbackend/internal/api/router.go to see existing domainsParse $ARGUMENTS as: [domain-name]
item, booking, user)Create the domain package at backend/internal/domain/[name]/:
package [name]
import "time"
type [Name] struct {
ID string `json:"id"`
// Add fields based on user's description
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
package [name]
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
)
type Repository struct {
pool *pgxpool.Pool
}
func NewRepository(pool *pgxpool.Pool) *Repository {
return &Repository{pool: pool}
}
// Add methods: List, GetByID, Create, Update, Delete
// Use pgx directly — no ORM
// Always accept context.Context as first parameter
// Return (result, error) tuples
package [name]
type Service struct {
repo *Repository
}
func NewService(repo *Repository) *Service {
return &Service{repo: repo}
}
// Business logic methods that call repository
// Validation, authorization checks, side effects go here
// Services know nothing about HTTP
Add the table to backend/schema.sql:
CREATE TABLE IF NOT EXISTS [name]s (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
-- fields based on domain types
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
TEXT for IDs (UUIDs stored as text)TIMESTAMPTZ for all timestampsUpdate backend/internal/api/router.go:
[name]Repo := [name].NewRepository(pool)[name]Svc := [name].NewService([name]Repo)/gopilot:api)go vet ./... in backendgo build ./... to check compilation[name] created. Add API endpoints with /gopilot:api [name] list|get|create|update|delete."http.Request, no status codesnpx claudepluginhub bishwas-py/gopilot --plugin gopilotProvides Go backend patterns for HTTP services (net/http, Chi/Gin/Echo, middleware), concurrency (goroutines, channels, errgroup), database access (sqlx, pgx), and project structure. Detects stack from go.mod.
Provides idiomatic Go patterns for backend APIs with Gin, Echo, Fiber: standard project structure, custom error handling, handler dependency injection, concurrency best practices.