agentleFS
jenrehjenreh/appkit/.claude/skills/runic-migrate/SKILL.md

runic-migrate

Skill4 starsChanged 5 months agoMITView on GitHub

Expert guide for runic — an Alembic-style graph schema migration tool that supports FalkorDB, Memgraph, Neo4j, ArcadeDB, and Apache AGE. Use whenever the user works with runic: CLI commands, migration file anatomy, op.* API, env.py config, autogenerate, branching/merge, or testing. Invoke for any versions/*.py file, `runic` CLI question, or graph schema change task.

  • Installs packages

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All other backends: (:_RunicMigrateVersion)

    line 19
  2. Very specific:

    Default config: runic/env.py — override with --config path/to/env.py.

    line 54
  3. Very specific:

    When you init to a non-default location, runic writes a .runic file in the working directory containing the path to env.py.

    line 56
  4. Very specific:

    Create the range index before a unique constraint on the same property in upgrade.

    line 155
  5. Very specific:

    Use irreversible = True for one-way data migrations (e.g.

    line 156
  6. Very specific:

    Use snapshot = True for risky data migrations.

    line 157
  7. Very specific:

    Keep every data step idempotent — use MERGE / guarded WHERE … IS NULL writes.

    line 158

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Runic — Graph Schema Migration Tool

Runic is an Alembic-style migration framework for graph databases (FalkorDB, Memgraph, Neo4j, ArcadeDB, Apache AGE). It tracks schema versions in a version node inside each graph and drives upgrades/downgrades via Python scripts stored in versions/.

  • FalkorDB version node label: (:_FalkorMigrateVersion)
  • All other backends: (:_RunicMigrateVersion)

For real migration file examples see examples/. For the full op.* API and SchemaManifest see references/op-api.md. For autogenerate, programmatic SDK, testing, and branching see references/advanced.md. For the initial migration workflow (dev bootstrap → baseline → production) see references/initial-migration.md. For annotated migration patterns (rename, relabel, seed, constraint guard) see references/migration-patterns.md.


Quick-start

pip install runic          # or: uv add runic

runic init                 # scaffold runic/ directory
# edit runic/env.py to point at your graph database instance
runic revision -m "create user index"
# edit the generated versions/*.py (see examples/ for patterns)
runic upgrade head

Directory layout (after runic init)

runic/
├── env.py            # executed on every CLI call; configures adapter + context
├── script.py.mako    # Mako template for new revision files
└── versions/
    ├── .gitkeep
    └── <rev_id>_<slug>.py

Default config: runic/env.py — override with --config path/to/env.py.

When you init to a non-default location, runic writes a .runic file in the working directory containing the path to env.py. Subsequent commands use this as a fallback when the default runic/env.py does not exist. Commit .runic.


env.py

import os
from runic.migrate import context
from runic.migrate.adapters import create_adapter

adapter = create_adapter(
    "falkordb",
    url=os.getenv("FALKORDB_URL", "falkor://localhost:6379"),
    graph_name=os.getenv("FALKORDB_GRAPH", "my_graph"),
)
context.configure(adapter)

For autogenerate/check, add target_manifest — see references/advanced.md.


CLI reference

CommandDescription
runic init [DIR]Scaffold migration environment (default: runic/); --force to overwrite
runic revision -m "msg"Create new empty revision at current head
runic revision -m "msg" --autogenerateDiff manifest vs live; emit candidate ops
runic revision -m "msg" --branch-label LABELCreate revision on a named branch
runic revision -m "msg" --formatAuto-format the generated file with ruff
runic upgrade [TARGET]Apply upgrades to TARGET (default: head)
runic upgrade TARGET --previewPrint ops without executing
runic upgrade TARGET --validate-on-migrateAbort if any applied script has a checksum mismatch
runic upgrade TARGET --installed-by NAMERecord attribution with each applied revision
runic downgrade TARGETRevert to TARGET (base, -1, rev id)
runic downgrade TARGET --forceRevert through irreversible revisions
runic currentShow applied revision
runic historyList all revisions newest-first
runic history --verboseInclude create_date and down_revision; mark branch points
runic history --range start:endSlice of history
runic headsList all head revisions (multiple = branched)
runic branchesList branch-point revisions
runic stamp TARGETSet version pointer without running migrations
runic stamp base --purgeClear version pointer
runic show REVPrint full metadata for a revision
runic test REVRound-trip test: upgrade → downgrade → upgrade
runic test REV --url URL --graph NAMESame against an explicit DB
runic merge R1 R2 -m "msg"Create merge revision for two heads
runic checkCI gate: non-zero exit if manifest has pending changes
runic validateVerify applied scripts match their stored checksums
runic run FILE.py [FILE.py ...]Execute .py migration script(s) (must have upgrade(op)) against the DB without recording in the chain
runic infoShow migration status: current, applied, pending counts (COMPARE mode)
runic info --mode LOCALOffline-only: local revision count and heads
runic info --mode REMOTEDB-only: which revision is applied
runic baseline [-m "msg"]Introspect live schema, write a root revision, and stamp it
runic baseline --stamp-onlyStamp the version node only, without writing a file

Relative targets: +1 / +2 (upgrade N steps), -1 / -2 (downgrade N steps).


Migration file anatomy

"""create user email index

Revision ID: 1975ea83b712
Revises: None
Create Date: 2026-05-30T14:00:00+00:00
"""
from datetime import UTC, datetime

message = "create user email index"
create_date = datetime.fromisoformat("2026-05-30T14:00:00+00:00")

revision = "1975ea83b712"
down_revision = None       # None = base; str = parent id; tuple = merge revision
branch_labels = []
depends_on = []
irreversible = False       # True → refuse downgrade unless --force
snapshot = False           # True → GRAPH.COPY before upgrade; restore on failure


def upgrade(op) -> None:
    op.create_range_index("User", "email")
    op.create_constraint("UNIQUE", "NODE", "User", ["email"])


def downgrade(op) -> None:
    op.drop_constraint("UNIQUE", "NODE", "User", ["email"])  # constraint BEFORE index
    op.drop_range_index("User", "email")

Key rules:

  • Drop constraints before dropping their backing range index in downgrade.
  • Create the range index before a unique constraint on the same property in upgrade.
  • Use irreversible = True for one-way data migrations (e.g. rename + drop old property).
  • Use snapshot = True for risky data migrations; runic GRAPH.COPYs before upgrade and restores on failure/downgrade.
  • Keep every data step idempotent — use MERGE / guarded WHERE … IS NULL writes; graph databases have no multi-statement transactions.

For the full op.* API signatures, see references/op-api.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.