agentleFS
dbtinoy-dbtinoy-/lexigram-framework-skills/cli-database-operations/SKILL.md

cli-database-operations

Skill1 starsChanged 3 months agoMITView on GitHub

Use when running database migrations, seeding data, backing up, or inspecting the database schema in a Lexigram project

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is 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.

  • 1

    Very specific

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

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

    Default URL is sqlite:///data.db.

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

CLI Database Operations

Overview

lexigram db manages the full database lifecycle — migrations, seeding, schema inspection, and backup/restore — backed by lexigram-sql's migration manager. All commands accept --env/-e to select the environment.

Migration Lifecycle

lexigram db init                    # Create migrations/ directory (arg: dir name)
lexigram db migrate add_users_table # Generate a new migration file
lexigram db create add_users_table  # New empty migration (-m for description)
lexigram db upgrade                 # Apply pending migrations
lexigram db downgrade               # Roll back the most recent
lexigram db downgrade 0003_seed     # Roll back to a specific version (positional arg)
lexigram db status                  # Current version + pending
lexigram db history --limit 20      # Last N applied migrations (-n)
lexigram db validate                # Check applied migrations have files

Seeding & Reset

lexigram db seed                    # Run seeds/*.py scripts (arg: single file)
lexigram db reset --seed            # Drop + recreate + seed
lexigram db reset --force           # Skip confirmation prompt

Seed scripts live in seeds/*.py.

Inspection & Administration

lexigram db inspect                 # List tables
lexigram db inspect --table users   # One table's columns + types (-t)
lexigram db shell                   # Open a DB client REPL
lexigram db setup                   # Per-package schema setup

Backup & Restore

lexigram db backup --output dump.sql
lexigram db restore dump.sql --force

Config

The SQL config section is sql: (env prefix LEX_SQL__):

sql:
  backend:
    url: postgresql+asyncpg://user:pass@localhost:5432/mydb
  pool:
    min_size: 2
    max_size: 10

Default URL is sqlite:///data.db. Valid URL schemes: sqlite, postgresql/postgres, mysql, mariadb, oracle, mssql. Insecure default credentials are blocked in production.

Common Mistakes

  • Running upgrade before db init — the migrations directory must exist
  • Running downgrade without a version argument — reverts only the most recent
  • Editing applied migration files — write a new migration instead
  • reset --force without backup — irreversible data loss
  • Using sync driver (psycopg2) in async context — use +asyncpg in the URL

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.