This tool updates Go models using the DBX ORM generator, verifies the output, and reports on diffs and compilation errors.
Install
mkdir -p .claude/skills/dbx-regenerate && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3776" && unzip -o skill.zip -d .claude/skills/dbx-regenerate && rm skill.zipInstalls to .claude/skills/dbx-regenerate
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Regenerate DBX code after making changes to .dbx schema files. Runs code generation, shows diff summary, validates compilation, and reports any errors.Key capabilities
- →Generate Go code from.dbx schema definition files
- →Perform schema migration validation for DB interfaces
- →Generate cross-platform SQL for PostgreSQL and CockroachDB
- →Check generated code against build-time compilation requirements
- →Review diffs of auto-generated ORM method signatures
How it works
Triggers the DBX compiler via the Go generate tool to parse schema files and inject updated type-safe methods into the project codebase.
Inputs & outputs
When to use dbx-regenerate
- →Update database access layer after schema changes
- →Validate generated Go code for compilation errors
- →Review diffs of database interface changes
About this skill
DBX Regenerate
You are helping regenerate the DBX-generated code after changes to .dbx schema files.
Overview
DBX (Database Extension) is Storj's schema-first ORM that generates Go code from .dbx schema files. When developers modify .dbx files in satellite/satellitedb/dbx/, the generated code in satellitedb.dbx.go must be regenerated.
This skill:
- Runs the DBX code generator
- Shows a summary of what changed
- Validates the generated code compiles
- Reports any errors with helpful context
Instructions
Follow these steps to regenerate DBX code:
1. Check for Modified .dbx Files
First, check which .dbx files have been modified (optional but helpful for context):
git status satellite/satellitedb/dbx/
This helps understand what schema changes triggered the regeneration.
2. Run DBX Code Generation
Execute the code generation:
cd satellite/satellitedb/dbx && go generate
This runs the DBX compiler which:
- Parses all .dbx schema files
- Generates SQL for PostgreSQL and CockroachDB
- Produces Go code with type-safe methods
- Creates the ~50,000 line
satellitedb.dbx.gofile
Expected output: Should see messages about code generation progress.
3. Show Diff Summary
After generation completes, show a summary of what changed:
git diff --stat satellite/satellitedb/dbx/satellitedb.dbx.go
Also show a preview of the changes:
git diff satellite/satellitedb/dbx/satellitedb.dbx.go | head -100
What to look for:
- New methods added (e.g.,
Create_,Get_,Update_,Delete_methods) - Modified method signatures
- New model structs
- Changes to existing queries
4. Validate Compilation
Ensure the generated code compiles successfully:
go build ./satellite/satellitedb/dbx
If compilation succeeds, the regeneration was successful.
5. Report Results
Provide a clear summary to the user:
If successful:
- Confirm DBX regeneration completed
- Summarize what changed (e.g., "Added 3 new methods for the
userstable") - Show key new/modified methods
- Confirm compilation succeeded
- Suggest next steps (e.g., "You may want to create a database migration for the schema changes")
If errors occurred:
- Show the full error output
- Identify which .dbx file has the issue (look for file references in error)
- Explain the error in plain language
- Suggest fixes based on common DBX errors (see below)
Common DBX Errors and Fixes
Syntax Error in .dbx File
Error pattern: parse error, unexpected token, invalid syntax
Cause: Incorrect .dbx syntax (missing commas, invalid field types, etc.)
Fix:
- Check the .dbx file line number mentioned in the error
- Verify syntax matches DBX documentation patterns
- Common issues: missing commas between fields, invalid field type names, incorrect query syntax
Duplicate Model/Query Definition
Error pattern: already defined, duplicate definition
Cause: Model or query defined multiple times across .dbx files
Fix:
- Search for the duplicate definition across all .dbx files
- Remove or rename the duplicate
- Ensure model names are unique across all .dbx files
Invalid Field Type
Error pattern: unknown type, invalid type
Cause: Using a field type that DBX doesn't recognize
Valid DBX types:
text,blob,int,int64,uint,uint64bool,timestamp,float64utimestamp(microsecond timestamp)
Fix: Change the field type to a valid DBX type
Missing Primary Key
Error pattern: no primary key defined
Cause: Table definition missing a primary key
Fix: Add a primary key using ( key <field> ) in the model definition
Invalid Query Pattern
Error pattern: invalid query, unknown read pattern
Cause: Using an incorrect query pattern name
Valid patterns:
read one,read all,read first,read paged,read limitoffset,read scalarupdate,delete,create,count
Fix: Use a valid query pattern from the list above
Circular Dependency
Error pattern: circular dependency, import cycle
Cause: .dbx files referencing each other in a circular way
Fix: Restructure the models to remove circular references
Post-Regeneration Checklist
After successful regeneration, remind the user to:
- Review the diff: Check that generated changes match expectations
- Create migration: If schema changed, create database migration files
- Run linter: Ensure generated code passes linting
make llint LINT_TARGET=./satellite/satellitedb/dbx - Commit changes: Commit both .dbx changes and generated code together
Understanding the Generated Code
The satellitedb.dbx.go file contains:
- Model structs: Go representations of database tables
- Field types: Type-safe field constructors (e.g.,
User_Id_Field) - CRUD methods: Auto-generated database operations
- Backend implementations: Separate implementations for PostgreSQL and CockroachDB
- Transaction support:
WithTx()methods for transactions - Error handling: Wrapped errors with proper error codes
Example Workflow
User modified: satellite/satellitedb/dbx/user.dbx - added last_login timestamp field
Regeneration output:
DBX regenerated successfully!
Changes:
- Modified: User model (added field: last_login)
- New methods: Update_User_LastLogin_By_Id
- Lines changed: +156 -12
Generated methods:
- User.LastLogin field added
- User_LastLogin_Field type added
- Update methods now include last_login in optional fields
Compilation: ✓ Success
Next steps:
1. Review the diff to ensure changes are correct
2. Create a migration to add the last_login column
3. Run tests to ensure compatibility
Notes
- DBX generation can take 10-30 seconds depending on system performance
- The generated file is ~1.9 MB and ~50,000 lines of code
- Always regenerate after modifying ANY .dbx file
- The generator is located in
satellite/satellitedb/dbx/gen/main.go - DBX supports PostgreSQL and CockroachDB from the same schema
- Generated code includes monkit instrumentation for metrics
- All errors are wrapped with
errs.Class("satellitedb")
Tips
- Use
git diffto see exactly what changed before committing - If regeneration seems slow, check for syntax errors first
- Keep .dbx files focused - one file per logical domain (users, projects, etc.)
- Test generated code with all supported backends if possible
- DBX errors are usually specific - read them carefully for the fix
When not to use it
- →When modifying database schemas manually without updating.dbx files
- →When working in a non-Go project environment
- →For simple SQL queries that do not require an ORM layer
Prerequisites
Limitations
- →Depends on the stability and correctness of the DBX compiler
- →Requires a complete rebuild of the database layer on every change
- →Diffs for generated files can be large and difficult to review
How it compares
It eliminates manual creation of repetitive database access code by enforcing a schema-first generation approach.
Compared to similar skills
dbx-regenerate side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| dbx-regenerate (this skill) | 1 | 6mo | Review | Intermediate |
| run-tests | 1 | 5mo | Review | Intermediate |
| advanced-lokstra-validate-consistency | 0 | 6mo | Review | Advanced |
| database-development | 1 | 2mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by storj
View all by storj →You might also like
run-tests
pgschema
Run pgschema automated tests (go test) to validate diff logic, plan generation, and dump functionality using test fixtures
advanced-lokstra-validate-consistency
primadi
Validate application consistency - circular dependencies, schema validation, config checks, annotation validation, and service registration. Use after all code is implemented to identify issues before deployment.
database-development
vm0-ai
Database migrations and Drizzle ORM guidelines for the vm0 project
database-schema
alinaqi
Schema awareness - read before coding, type generation, prevent column errors
nop-orm-modeler
entropy-cloud
Generate, validate, and modify Nop ORM models from MySQL DDL/SQL or business requirements. Covers entity modeling, relationships, domains, dictionaries, displayName localization, and ORM file organization (Delta mode). Use for database-first or requirements-first ORM development.
litestream
benbjohnson
Expert knowledge for contributing to Litestream, a standalone disaster recovery tool for SQLite. Provides architectural understanding, code patterns, critical rules, and debugging procedures for WAL monitoring, LTX replication format, storage backend implementation, multi-level compaction, and SQLite page management. Use when working with Litestream source code, writing storage backends, debugging replication issues, implementing compaction logic, or handling SQLite WAL operations.