Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

dbx-regenerate

БесплатноБез исполняемых скриптовНе проверен

Regenerate DBX code after making changes to .dbx schema files. Runs code generation, shows diff summary, validates compilation, and reports any errors.

storjот storj★ 3 286 звёзд на GitHub

Об этом скилле

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:

  1. Runs the DBX code generator
  2. Shows a summary of what changed
  3. Validates the generated code compiles
  4. 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.go file

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 users table")
  • 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, uint64
  • bool, timestamp, float64
  • utimestamp (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 scalar
  • update, 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:

  1. Review the diff: Check that generated changes match expectations
  2. Create migration: If schema changed, create database migration files
  3. Run linter: Ensure generated code passes linting
    make llint LINT_TARGET=./satellite/satellitedb/dbx
    
  4. 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 implementa
Полный SKILL.md на GitHub

Установить dbx-regenerate в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл dbx-regenerate?

Regenerate DBX code after making changes to .dbx schema files. Runs code generation, shows diff summary, validates compilation, and reports any errors.

Как установить скилл dbx-regenerate?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл dbx-regenerate запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить dbx-regenerate с