db-run-sql

Execute SQL files or inline SQL statements with transaction safety and timing.

3|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-run-sql-gabrielnsmnto
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-run-sql
Source: https://github.com/gabrielnsmnto/kord-aios/tree/main/src/features/builtin-skills/kord-aios/database/db-run-sql
Command: npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-run-sql-gabrielnsmnto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Running ad-hoc SQL against a PostgreSQL database is risky when destructive statements, missing transaction control, or silent failures can corrupt data. This Skill wraps SQL execution in safety checks, transaction modes, and clear execution summaries. ## Core Features & Use Cases - Flexible Input: Accepts either a SQL file path or an inline SQL statement and detects the mode automatically. - Destructive Operation Detection: Warns and requires explicit confirmation before running DROP TABLE, TRUNCATE, or unbounded UPDATE/DELETE statements. - Transaction Modes: Supports auto (BEGIN/COMMIT wrapper with rollback on error), manual (script-controlled), and read-only transactions. - Use Case: Run a migration file like supabase/migrations/20240101_add_users.sql with automatic transaction wrapping, then review rows affected and execution time in the summary output. ## Quick Start Ask the agent to run your SQL file or inline query against the database, for example: run the migration file supabase/migrations/20240101_add_users.sql with automatic transaction mode.

Frequently Asked Questions about db-run-sql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a SQL file against a PostgreSQL database safely?▼

Pass the SQL file path as input and select auto transaction mode, which wraps the script in BEGIN/COMMIT with ON_ERROR_STOP enabled. Errors trigger an automatic rollback, and the output shows rows affected and execution time.

How to execute inline SQL queries with psql from a script?▼

Provide the SQL statement as an inline string input instead of a file path. The skill detects it is not a file and runs it through psql with the selected transaction mode, saving full output to /tmp/dbsage_sql_output.txt.

Does this prevent accidental DROP TABLE or DELETE statements?▼

Yes, it scans the SQL for destructive patterns like DROP TABLE, TRUNCATE, and unbounded UPDATE or DELETE statements. When detected, execution pauses and requires typing a confirmation phrase before proceeding.

What transaction modes are available when running SQL scripts?▼

Three modes exist: auto wraps statements in BEGIN/COMMIT with rollback on error, manual executes the script as-is for files with their own transaction control, and read uses a read-only transaction safe for queries.

Why does my SQL execution fail with a transaction rollback?▼

Rollbacks occur when a statement violates constraints, has syntax errors, or times out while ON_ERROR_STOP is enabled. Review the error output saved to /tmp/dbsage_sql_output.txt, fix the query, and retry.