Convert natural language questions to SQL queries for CSV data analysis. Operations teams use this to automate data extraction without SQL expertise. Integrates with Python workflows and Claude agents.
git clone https://github.com/distil-labs/distil-example-text2sql-with-claude.gitThe distil-example-text2sql-with-claude skill is an innovative automation tool designed to simplify the process of generating SQL queries from natural language inputs. By utilizing the capabilities of the Claude Code framework, this skill showcases model training and deployment using the distil Claude CLI. It serves as a practical example for developers looking to enhance their workflow automation processes, particularly in data management tasks. With an implementation time of just 30 minutes, this skill allows users to quickly integrate it into their existing systems. One of the key benefits of this skill is its ability to save time by automating the SQL query generation process. Instead of manually writing complex SQL statements, users can input natural language descriptions, and the skill translates these into accurate SQL queries. This not only streamlines the workflow but also reduces the likelihood of errors associated with manual coding. While the exact time savings are currently unknown, the efficiency gained from automation is evident, especially for teams handling large volumes of data. The distil-example-text2sql-with-claude skill is particularly beneficial for developers, product managers, and AI practitioners who are involved in data-centric projects. It is an excellent fit for teams looking to implement AI automation in their workflows, as it directly addresses the common challenge of translating business requirements into technical specifications. For instance, a product manager could use this skill to quickly generate SQL queries needed for reporting without requiring deep technical expertise. With an intermediate level of complexity, users should have a foundational understanding of SQL and familiarity with the Claude Code environment to effectively implement this skill. It is a valuable addition to any AI-first workflow, enabling teams to leverage automation for improved productivity and accuracy in data handling tasks. By integrating this skill into their processes, organizations can enhance their operational efficiency and focus on higher-level strategic initiatives.
1. **Prepare your dataset**: Ensure your CSV file is loaded into a data analysis environment (e.g., Python with pandas, SQLite, or a spreadsheet tool). Name the dataset clearly (e.g., `sales_data.csv`). 2. **Craft your question**: Frame your data analysis request as a natural language question. For example: *"What are the monthly sales trends for 2023?"* or *"List all customers who placed orders over $1,000 in the last 6 months."* 3. **Use the prompt template**: Copy the prompt template and replace `[DATASET_NAME]` with your dataset's filename (e.g., `sales_data.csv`) and `[USER_QUESTION]` with your specific question. Paste the completed prompt into your AI tool (e.g., Claude, ChatGPT). 4. **Validate the output**: Review the generated SQL query for accuracy. Check that table and column names match your dataset. Adjust the query if needed (e.g., fix typos in column names or add missing filters). 5. **Execute the query**: Run the SQL query in your preferred environment (e.g., Python with pandas, SQLite CLI, or a database tool like DBeaver). Verify the results align with your expectations. For complex queries, consider breaking them into smaller parts for easier debugging.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/distil-labs/distil-example-text2sql-with-claudeCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Convert this natural language question into a SQL query for a CSV file containing [DATASET_NAME] data: '[USER_QUESTION]'. Ensure the query uses the correct table and column names from the dataset. If the query requires filtering, sorting, or aggregation, include those clauses. Return only the SQL query without any additional text or explanations.
```sql
-- Natural Language Question: "Show me the top 5 customers by total order value in 2023"
-- Dataset: sales_data.csv (columns: customer_id, customer_name, order_id, order_date, order_value)
SELECT
customer_name,
SUM(order_value) AS total_order_value
FROM
sales_data
WHERE
YEAR(order_date) = 2023
GROUP BY
customer_id, customer_name
ORDER BY
total_order_value DESC
LIMIT 5;
```
**Results:**
| customer_name | total_order_value |
|---------------------|-------------------|
| Acme Corporation | $125,000 |
| Globex Industries | $98,500 |
| Initech | $87,200 |
| Wayne Enterprises | $76,800 |
| Stark Industries | $65,400 |
This query filters orders from 2023, groups them by customer, sums the order values, and returns the top 5 customers by total spending. The results are sorted in descending order to highlight the highest spenders first.AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Automate security compliance and monitor real-time security posture seamlessly.
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan