بنقرة واحدة
text-to-sql
Convert natural language queries to SQL. Use for database queries, data analysis, and reporting.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Convert natural language queries to SQL. Use for database queries, data analysis, and reporting.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Agent frontmatter enhancements — disallowedTools, mcpServers scoping, fork_eligible field
Context management — pre-compact persistence, threshold alignment, microcompact/circuit breaker detection
Hook enhancements — updatedInput for bash safety prefixes, suppressOutput for verbose blocks, denial-based routing feedback
Hook system optimization — async conversion, consolidation, deduplication, new hook events
Memory index discipline — cap enforcement, pruning, archival, health reporting
Prompt assembler optimization — sorting, memoization, cache-break detection, integration tests
| name | text-to-sql |
| description | Convert natural language queries to SQL. Use for database queries, data analysis, and reporting. |
| version | 1.0.0 |
| model | sonnet |
| invoked_by | both |
| user_invocable | true |
| tools | ["Read","Write","Grep","Glob"] |
| best_practices | ["Provide database schema context","Validate SQL before execution","Use parameterized queries","Test queries on sample data"] |
| error_handling | graceful |
| streaming | supported |
| verified | true |
| lastVerifiedAt | "2026-02-22T00:00:00.000Z" |
| source | builtin |
| trust_score | 100 |
| provenance_sha | cd76bf9a59942cc5 |
Mode: Cognitive/Prompt-Driven — No standalone utility script; use via agent context.
Text-to-SQL - Converts natural language queries to SQL using database schema context and query patterns.
When to Use:
How to Invoke:
"Generate SQL to find all users who signed up in the last month"
"Create a query to calculate total revenue by product"
"Write SQL to find duplicate records"
What It Does:
Schema Integration:
Query Optimization:
Safety:
Text-to-SQL uses schema from database-architect:
Text-to-SQL generates queries for developers:
User: "Find all users who signed up in the last month"
Text-to-SQL:
1. Analyzes query
2. References users table schema
3. Generates SQL:
SELECT * FROM users
WHERE created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
4. Returns parameterized query
User: "Calculate total revenue by product for Q4"
Text-to-SQL:
1. Analyzes query
2. References orders and products tables
3. Generates SQL:
SELECT p.name, SUM(o.total) as revenue
FROM orders o
JOIN products p ON o.product_id = p.id
WHERE o.created_at >= '2024-10-01'
AND o.created_at < '2025-01-01'
GROUP BY p.id, p.name
4. Returns optimized query
Based on Claude Cookbooks patterns, text-to-SQL evaluation includes:
Syntax Validation:
Functional Testing:
Promptfoo Integration:
Evaluation Configuration:
Create a promptfoo config file for your evaluation setup (e.g., text_to_sql_config.yaml).
# Run text-to-SQL evaluation (create config first)
npx promptfoo@latest eval -c text_to_sql_config.yaml
Always include complete database schema:
Provide examples of similar queries:
For complex queries, use chain-of-thought reasoning:
Use RAG to retrieve relevant schema information:
LIMIT clause (default 100) to SELECT queries unless the user explicitly overrides it| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| String interpolation for values | SQL injection vulnerability | Use parameterized queries with ? or $N placeholders |
| No LIMIT clause on SELECT | Returns all rows, risk of OOM and timeout | Default LIMIT 100, require explicit user override |
| Destructive SQL without confirmation | Irreversible data loss | Gate DROP/DELETE/TRUNCATE behind user confirmation |
| No schema validation | References non-existent tables or columns | Validate all identifiers against the provided schema |
| SELECT * without column list | Unpredictable results and performance waste | Always specify an explicit column list |
Before starting:
Read .claude/context/memory/learnings.md
After completing:
.claude/context/memory/learnings.md.claude/context/memory/issues.md.claude/context/memory/decisions.md