text-to-sql
Skill6 starsChanged 6 months agoApache-2.0View on GitHub
Setup and use text-to-SQL capabilities for SQL databases (SQLite, PostgreSQL, MySQL, MariaDB, etc.). Use when: (1) User wants to query databases using natural language, (2) User asks to setup text-to-sql project, (3) User mentions extracting data from database, (4) User has .sqlite/.db file or database credentials and wants to work with data. This skill sets up project structure, extracts database schema, and enables natural language to SQL conversion.
- Reads credentials
- Installs packages
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Ask user which database type they want to use:
- Distinctive: line 32
Run the init script OR manually create structure:
- Very specific: line 91
After extraction, these files should exist in output/:
- Distinctive: line 101
When user asks a data question:
- Very specific: line 105
Read output/text_to_sql_context.md to understand:
- Distinctive: line 112
Create SQL file based on user question.
- Distinctive: line 190
Ask user for SQLite file path
- Very specific: line 198
Read schema from output/text_to_sql_context.md
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.
Files
Text-to-SQL Skill
Convert natural language questions into SQL queries and execute them against SQL databases.
Phase 1: Project Setup
Step 1: Ask about database connection
Ask user which database type they want to use:
Option A: SQLite (file-based, no credentials needed)
- User provides path to
.sqliteor.dbfile - Or places file in
database/folder
Option B: Server database (PostgreSQL, MySQL, MariaDB, etc.)
- User creates
.envfile with connection details - Supported: PostgreSQL, MySQL, MariaDB, and other SQL databases
Step 2: Initialize project structure
Run the init script OR manually create structure:
Option A: Use init script
python scripts/init_project.py --target /path/to/projectOption B: Manual setup
mkdir -p database output/queries output/reportsCopy from skill folders to project root:
scripts/*.py→ project root (db_extractor.py, query_runner.py, list_databases.py, sql_helper.py)assets/example.env→ project rootassets/requirements.txt→ project rootassets/.gitignore→ project root
Install dependencies:
pip install -r requirements.txtStep 3: Configure connection
For SQLite:
# Place database file
cp /path/to/database.sqlite database/
# Extract schema
python db_extractor.py --sqlite database/YOUR_DB.sqliteFor server databases (PostgreSQL, MySQL, etc.):
Copy and edit the template:
cp example.env .env
# Edit .env with actual credentialsThe example.env template contains:
DB_TYPE=postgresql # postgresql, mysql, mariadb
DB_HOST=localhost
DB_PORT=5432 # 5432 for PostgreSQL, 3306 for MySQL
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database_nameThen extract schema:
python db_extractor.py --database your_database_nameStep 4: Verify setup
After extraction, these files should exist in output/:
connection.json- current connection configtext_to_sql_context.md- schema for LLM queriesschema_info.json- full schema datadatabase_documentation.md- human-readable docs
Phase 2: Query Workflow
When user asks a data question:
Step 1: Read schema context
Read output/text_to_sql_context.md to understand:
- Available tables and columns
- Data types and relationships
- Enum values for filtering
Step 2: Generate and save SQL
Create SQL file based on user question. See sql_patterns.md for common query patterns.
# Save to output/queries/descriptive_name.sqlStep 3: Execute query
Get run command from output/connection.json, then:
# SQLite example
python query_runner.py --sqlite database/DB.sqlite -f output/queries/query.sql -o result.csv
# MySQL example
python query_runner.py -f output/queries/query.sql -o result.csvStep 4: Report results
Tell user: "Results saved to output/reports/result.csv"
Quick Reference
Commands
# List databases
python list_databases.py
# Extract schema (SQLite)
python db_extractor.py --sqlite database/file.sqlite
# Extract schema (MySQL)
python db_extractor.py --database db_name
# Run query (SQLite)
python query_runner.py --sqlite database/file.sqlite "SELECT * FROM table LIMIT 10"
python query_runner.py --sqlite database/file.sqlite -f query.sql -o result.csv
# Run query (MySQL)
python query_runner.py "SELECT * FROM table LIMIT 10"
python query_runner.py -f query.sql -o result.csv
# Output formats
--format csv # default
--format xlsx # Excel
--format json # JSON
--format md # MarkdownProject Structure
project/
├── .env # MySQL credentials (if using MySQL)
├── database/ # SQLite files go here
│ └── your_db.sqlite
├── output/
│ ├── connection.json # Current DB connection
│ ├── text_to_sql_context.md # Schema for LLM
│ ├── queries/ # Saved SQL queries
│ └── reports/ # Query results (CSV, XLSX, JSON)
├── db_extractor.py
├── query_runner.py
├── list_databases.py
└── sql_helper.pyExample Workflow
User: "I have a SQLite database with e-commerce data. Help me analyze it."
Setup:
- Ask user for SQLite file path
- Copy file to
database/ - Run
python db_extractor.py --sqlite database/file.sqlite - Read generated
output/text_to_sql_context.md
User: "Show me top 10 sellers by revenue"
Query:
- Read schema from
output/text_to_sql_context.md - Generate SQL:
SELECT seller_id, SUM(price) as revenue FROM order_items GROUP BY seller_id ORDER BY revenue DESC LIMIT 10; - Save to
output/queries/top_sellers.sql - Execute:
python query_runner.py --sqlite database/file.sqlite -f output/queries/top_sellers.sql -o top_sellers.csv - Report: "Results saved to
output/reports/top_sellers.csv"
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/extension-dev-skill/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-browserSkill
- architecture-designerSkill
- architecture-patternsSkill
- browser-useSkill
- deep-researchSkill
- docxSkill
- enhance-promptSkill
- extension-dev-skillSkill
- find-skillsSkill
- frontend-designSkill
- gh-cliSkill
- humanizer-zhSkill
- langchain-architectureSkill
- mcp-builderSkill
- mermaid-visualizerSkill
- microservices-architectSkill
- obsidian-basesSkill
- obsidian-cliSkill
- obsidian-markdownSkill
- pdfSkill
- planning-with-filesSkill
- playwright-cliSkill
- plugin-creatorSkill
- pptxSkill
- remotion-best-practicesSkill
- skill-creatorSkill
- tailored-resume-generatorSkill
- ui-ux-pro-maxSkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
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
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.

