Skip to content

theahura/sqlite3-ai-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLite3 AI CLI

A thin wrapper over the SQLite3 CLI with AI integration and tab completion.

Features

  • Full SQLite3 compatibility: All standard SQLite3 commands work as usual (.table, .headers on, SQL queries, etc.)
  • Tab completion: Intelligent completion for SQL keywords and table names
  • AI integration: Generate SQL queries using natural language with the .ai command
  • Model configuration: Configure which AI model to use with .model
  • API key management: Securely store your Anthropic API key with .anthropic-key

Installation

From npm (Recommended)

npm install -g sqlite3-ai-cli

From source

git clone <repository-url>
cd sqlite3-ai-cli
npm install
npm run build
npm install -g .

Usage

After installation, you can use the sqlite3-ai command:

# Connect to a database file
sqlite3-ai [database.db]

# Create/connect to a new database
sqlite3-ai mydatabase.db

Development Usage

# Run in development mode
npm run dev [database.db]

# Build and run locally
npm run build
npm start [database.db]

Commands

Standard SQLite3 Commands

All standard SQLite3 commands work as usual:

  • .tables - List all tables
  • .schema - Show table schemas
  • .headers on/off - Toggle column headers
  • Any SQL query (SELECT, INSERT, UPDATE, DELETE, etc.)

AI-Enhanced Commands

.model [model-name]

Set or view the current AI model.

.model                           -- View current model
.model claude-sonnet-4-20250514  -- Set model

.anthropic-key [api-key]

Set or view the current Anthropic API key.

.anthropic-key              -- View current key (masked)
.anthropic-key sk-ant-...   -- Set API key

.ai <prompt>

Generate SQL using natural language. The AI has access to your database schema.

.ai show all users
.ai find the top 10 customers by total orders
.ai create a table for storing product reviews

Tab Completion

Press Tab to see completions:

  • After typing sel + Tab → SELECT
  • After typing SELECT * FROM + Tab → shows available tables
  • After typing . + Tab → shows dot commands

Examples

-- Set up AI
.model claude-sonnet-4-20250514
.anthropic-key sk-ant-your-key-here

-- Use AI to generate queries
.ai show me all customers from California
-- This might generate: SELECT * FROM customers WHERE state = 'California';

-- Standard SQLite3 usage still works
.tables
.schema customers
SELECT COUNT(*) FROM customers;

Configuration

Configuration is stored in ~/.sqlite3-ai-cli/config.json and includes:

  • AI model selection
  • Anthropic API key (encrypted storage recommended for production use)

About

An AI-enabled cli for sqlite3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published