retrieve-sqllisted
Install: claude install-skill AVA-2568/MY_SKILL
# Retrieve-SQL (SQL 数据检索)
Query SQL databases safely.
## When to Use
- "How many orders were placed in Q3?"
- "Query the user table for active accounts"
- "Get revenue by month for 2025"
- "What's the average order value by region?"
## When Not to Use
- Schema migrations (`ALTER TABLE`, `CREATE TABLE`) → use database-design
- Cross-database migration → not supported; recommend dedicated migration tool
- Data visualization → route to dashboard-builder after retrieving data
- Writing data (`INSERT`, `UPDATE`, `DELETE`) without explicit user permission
## Procedure
0. **Schema check** — if the user didn't provide the schema, read from `INFORMATION_SCHEMA` or available config. If inaccessible, ask the user for table/column names.
1. **Query construction** — build the SQL query from the user's analytical question. Use parameterized placeholders (e.g., `%s` for psycopg2, `?` for sqlite3) for any user-supplied values.
2. **EXPLAIN verification** — prefix the query with `EXPLAIN` (or `EXPLAIN ANALYZE` for PostgreSQL). Verify the query plan uses indexes for large tables and avoids full-table scans on high-cardinality columns.
3. **Safe execution** — execute the parameterized query with a read-only connection (or transaction with rollback if read-only is unavailable).
4. **Return results** — present the results as a table or structured summary. Include row count and any warnings about data freshness.
## Pitfalls
- **Hardcoded connection strings**: Never write credentials or co