Rebase

From openmeterio/openmeter · View interactive version

Rebase is an AI agent skill from the GitHub repository openmeterio/openmeter. Rebase an OpenMeter branch onto another branch and handle repo-specific gotchas like sequential migrations, atlas.sum conflicts, Ent regeneration, and targeted verification.

How to use this skill

Skill file

Rebase Gotchas

Use this skill when rebasing an OpenMeter branch, especially onto origin/main, and there may be migration, Ent, or generated-code conflicts.

Before rebasing

Standard flow

  1. git fetch origin main
  2. git rebase origin/main
  3. Resolve conflicts one commit at a time.
  4. Prefer GIT_EDITOR=true git rebase --continue in non-interactive shells.

First rule for conflicts

When a rebase conflict appears, the first move should usually be regenerating generated artifacts:

make generate

Treat this as the default first step before manually resolving conflicted generated files.

Why:

In practice, regenerating first resolves or clarifies most conflicts much faster than hand-merging generated files.

Migration conflicts

OpenMeter migrations must stay sequential by timestamp.

If a rebased commit introduces a migration that is now older than migrations already on the target branch:

Typical flow:

  1. Remove the outdated .up.sql and .down.sql files.
  2. Regenerate code:
make generate
  1. Generate a fresh migration at the current head:
atlas migrate --env local diff <migration-name>
  1. Stage the newly generated migration pair and tools/migrate/migrations/atlas.sum.

atlas.sum conflicts

If tools/migrate/migrations/atlas.sum conflicts or gets out of sync:

atlas migrate --env local hash

Then stage atlas.sum. Do not hand-edit checksum entries unless there is no other option.

Ent and generated code

Shell/runtime notes

nix develop --impure .#ci -c <command>
direnv exec . atlas migrate --env local diff <migration-name>

Verification

Before continuing or finishing the rebase, run the smallest relevant test slice for the touched area.

For ledger work, the usual check is:

POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/ledger/...

If there is a known pre-existing failure, call it out explicitly and separate it from any new regression introduced by the rebase.

Important reminders

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.