
Query Writing
langchain-ai/deepagentsOfficial
Structured SQL query writing skill that builds SELECTs from simple lookups to multi-table JOINs and aggregations.
- CCM score
- 68 of 100
- skills.sh installs
- 1.3K
- GitHub stars
- 31.5K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers a single-table workflow (identify, check schema, query, format) and a multi-table workflow for JOINs and aggregations
- Uses
sql_db_schemafor each table,sql_db_queryto execute, andwrite_todosto plan complex tasks - Enforces a default LIMIT of 5, selected columns instead of
SELECT *, and read-only queries with no INSERT, UPDATE, DELETE, or DROP - Includes error recovery steps for empty results, syntax errors, and timeouts, with a revenue-by-country example
Install
$ npx -y skills add langchain-ai/deepagents --skill query-writing -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Query Writing Skill
Workflow for Simple Queries
For straightforward questions about a single table:
- Identify the table - Which table has the data?
- Get the schema - Use
sql_db_schemato see columns - Write the query - SELECT relevant columns with WHERE/LIMIT/ORDER BY
- Execute - Run with
sql_db_query - Format answer - Present results clearly
Workflow for Complex Queries
For questions requiring multiple tables:
1. Plan Your Approach
Use write_todos to break down the task:
- Identify all tables needed
- Map relationships (foreign keys)
- Plan JOIN structure
- Determine aggregations
2. Examine Schemas
Use sql_db_schema for EACH table to find join columns and needed fields.
3. Construct Query
- SELECT - Columns and aggregates
- FROM/JOIN - Connect tables on FK = PK
- WHERE - Filters before aggregation
- GROUP BY - All non-aggregate columns
- ORDER BY - Sort meaningfully
- LIMIT - Default 5 rows
4. Validate and Execute
Check all JOINs have conditions, GROUP BY is correct, then run query.
Details
- Repository
- github.com/langchain-ai/deepagents
- Category
- Databases
- First seen
- May 16, 2026
More from langchain-ai/deepagents
All 12Similar to Query Writing
More Databases
write-queryanthropics/knowledge-work-plugins3.2K installsPractical SQL writing guide that structures multi-CTE queries, dialect-specific syntax, and partition-aware performance tuning.
sql-queriesphuryn/pm-skills3K installsNatural-language to SQL generator that reads schema files and targets BigQuery, PostgreSQL, MySQL, and other dialects.
platform-soql-queryforcedotcom/sf-skills7.3K installsSalesforce SOQL and SOSL authoring and optimization skill that generates queries and analyzes query plans for performance.
sql-best-practicesmindrally/skills847 installsOpinionated SQL style guide covering formatting, joins, indexing, transactions, and injection safety for query writing.
sql-optimizationgithub/awesome-copilot16.4K installsUniversal SQL tuning guide covering query rewrites, indexing, pagination, and execution plan analysis across major engines.