/echonext:echonext-databasefrom echonext
Helps work with EchoNext's database layer: GORM models, generic Repository[T] pattern, and Atlas migrations/seeds via the CLI. Useful when defining models, querying/persisting data, or applying migrations.
Ships in echonext. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
EchoNext uses GORM for persistence and Atlas for migrations. The optional
pkg/contrib/database package adds a generic, type-safe Repository[T] so you
don't rewrite CRUD per model.
Plain GORM structs (see the echonext-domain skill for the conventional layout):
type User struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Email string `gorm:"unique;not null"`
Name string `gorm:"not null"`
}
func (User) TableName() string { return "users" }
pkg/contrib/database provides a generic repository. Construct it with the
model type and a *gorm.DB:
import "github.com/abdussamadbello/echonext/pkg/contrib/database"
repo := database.NewRepository[User](db)
Core methods (from the Repository[T] interface):
repo.Create(&user) // INSERT
user, err := repo.Find(1) // by primary key -> (*User, error)
users, err := repo.FindAll() // -> ([]*User, error)
repo.Update(&user) // UPDATE
repo.Delete(1) // DELETE by id
count, err := repo.Count() // -> (int64, error)
Chainable query builders return the repository so you can compose, then call a terminal method:
// All active users, newest first, page 2 of 20.
recent, err := repo.
Where("active = ?", true).
Order("created_at DESC").
Limit(20).
Offset(20).
FindAll()
// Run inside a transaction:
err := db.Transaction(func(tx *gorm.DB) error {
return repo.WithTx(tx).Create(&user)
})
Available builders: Where(query, args...), Order(value), Limit(n),
Offset(n), WithTx(tx); DB() returns the underlying *gorm.DB for anything
the repository doesn't cover.
Use
Repository[T]for generic CRUD. The defaultechonext generate domainservice holds a raw*gorm.DBinstead — either is fine; pick one per project and stay consistent.
echonext db init # one-time: set up Atlas migration files
echonext db migrate:diff add_users # diff Go models -> a new migration
echonext db migrate # apply pending migrations
echonext db migrate:status # what's applied / pending
echonext db migrate:down # roll back
echonext db migrate:new add_index # hand-write an empty migration
echonext db migrate:lint # check migrations for issues
echonext db schema:inspect # dump the current DB schema
Typical loop: edit model.go → db migrate:diff <name> → review the generated
SQL → db migrate.
echonext db seed # insert sample/seed data
For loading fixtures in tests, use the contrib testing helpers instead (see
the echonext-testing skill), not the seed command.
TableName(); use pointers/omitempty only
where semantics require it.database.NewRepository[T](db) for CRUD; drop to repo.DB() for
bespoke queries.db migrate:diff <name> then db migrate.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
echonext, gorm, repository-pattern, atlas-migrations, database
npx claudepluginhub abdussamadbello/echonext --plugin echonext9 skills in this plugin
/echonext-cliUse the EchoNext CLI to scaffold projects and code, run the dev loop, build, test, and manage the database. Use when creating a new echonext project, generating code (domain/handler/service/model/dto/middleware/openapi/graphql/ websocket/upload), or running dev/build/test/db commands./echonext-domainScaffold and wire up a complete EchoNext domain (model + service + handler + DTO) following the framework's conventional layout. Use when adding a new resource, feature, or entity to an echonext project (e.g. "add a users endpoint", "create a products domain")./echonext-handlersWrite and register type-safe EchoNext HTTP handlers, request structs, and routes. Use when adding, editing, or debugging an echonext handler function, a request/response struct, validation tags, or a route registration (GET/POST/PUT/PATCH/DELETE)./echonext-integrationsAdd WebSocket, GraphQL, or file-upload endpoints to an EchoNext app. Use when building real-time/WebSocket handlers (Hub pattern), wiring a gqlgen GraphQL schema, or accepting multipart file uploads with validation./echonext-middleware-configRegister, order and write EchoNext middleware, and load application configuration. Use when adding middleware (auth, CORS, logging, request IDs, metrics, tracing) to an echonext app or group, writing a custom echo.MiddlewareFunc, or loading config from YAML/env with the contrib config package./echonext-openapi-securityConfigure EchoNext's auto-generated OpenAPI spec and authentication. Use when setting API metadata (title/servers/contact), serving the OpenAPI JSON or Swagger UI, or adding auth (bearer/JWT, API key, OAuth2, OpenID Connect) via security schemes and per-route or global security requirements.Other plugins' skills for the same job