Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Knex.js CLI

$ knex Official Med Risk
Knex.js · Database & Data · MIT · macos / linux / windows

Knex.js CLI (knex) manages JavaScript/TypeScript schema migrations and database seed scripts via knexfile.js or knexfile.ts. Provides straightforward migrate:status, migrate:list, migrate:latest, migrate:rollback, and seed:run commands for Node.js services.

FCRS-1.0 Score
74 /100
Usable w/ Caveats
Medium Confidence
Zero-Friction Install
npm install -D knex
CLI vs MCP Decision CLI Preferred vs MCP

knex executes project-local knexfile migrations and TypeScript/JS seed modules directly inside the repository.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 17 / 25

Runs headlessly without TTY prompts via npx knex, though it lacks --json output and --dry-run flags.

  • Non-interactive migrate:status and migrate:latest
  • No --json or --dry-run flag
Trust & Safety 19 / 25

--env scopes target databases and migrate:rollback steps back one batch by default, but lacks dry-run SQL preview.

  • Batch-scoped rollback by default; --all is destructive
Setup & Portability 12 / 15

Standard npm package (npx knex), but requires Node.js plus the project's database driver (pg, mysql2, sqlite3) installed in node_modules.

  • Requires Node.js and project-local DB driver packages
Utility & Efficiency 11 / 15

Simple imperative migration and seed runner for Node.js codebases without heavyweight ORM schemas.

  • Covers migration scaffolding, execution, rollback, and seeds
Maintenance & Lineage 8 / 10

Long-standing knex/knex official repository under MIT license.

  • Official knex/knex GitHub repository
Docs & Verifiability 7 / 10

Clear migrations CLI guide on knexjs.org, though TypeScript knexfile.ts flags and ESM nuances can require extra setup.

  • Migration CLI documentation at knexjs.org

Security, Auth & Guardrails

Auth Modes
Config File Env API Key
Credential Storage

Reads connection objects and env vars (such as DATABASE_URL) from knexfile.js / knexfile.ts keyed by --env.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

MIT open-source npm package; free to use.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Knex.js CLI Agent Rules
- Always pass `--env <target>` explicitly and run `npx knex migrate:status` first.
- Never run `npx knex migrate:rollback --all` on shared or production environments without explicit confirmation.

Agent-Ready Command Recipes

Safe Read-Only Queries

Check completed and pending migrations
npx knex migrate:status

Prints a list of completed and pending migration files against the configured database.

List migration execution history
npx knex migrate:list

Displays completed and pending migrations from the knex_migrations tracking table.

Controlled Writes & Previews

Run pending migrations to latest
npx knex migrate:latest --env development

Applies all pending migrations against the explicitly scoped --env target.

Strengths for Agents

  • + Zero-prompt CLI commands (migrate:status, migrate:latest, seed:run) work reliably in CI.
  • + Explicit --env flag separates local, test, and production knexfile configs.
  • + Supports both JavaScript and TypeScript migration files.

Caveats & Pitfalls

  • ! No --json output or built-in --dry-run SQL preview mode.
  • ! Requires project node_modules and matching DB driver packages (pg, mysql2, etc.) to run.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI