| name | database-query-helper |
| description | Helps query and analyze PostgreSQL databases. Use when the user asks about database queries, schema inspection, table relationships, or data analysis tasks. Can connect to local or remote PostgreSQL instances and execute safe, parameterized queries. Supports schema exploration, query optimization suggestions, and data export. |
| allowed-tools | Read, Write, Bash, Grep, Glob |
Database Query Helper - Claude Code Skill
This skill provides intelligent PostgreSQL database interaction capabilities through a secure MCP server.
Core Capabilities
Schema Inspection
Explore database structures, table definitions, column types, and relationships:
Example requests:
- "Show me the schema for the users table"
- "What columns exist in the orders table?"
- "List all tables in the database"
- "Show me the relationships between users and orders tables"
Safe Query Execution
Execute parameterized queries with automatic SQL injection protection:
Example requests:
- "Find all users created in the last 30 days"
- "Count orders by status"
- "Show me the top 10 customers by order value"
- "Get all products with price greater than $50"
Query Optimization
Analyze and suggest improvements for slow queries:
Example requests:
- "Optimize this query: SELECT * FROM large_table WHERE date > '2023-01-01'"
- "Why is this query slow?"
- "Suggest indexes for better performance"
Data Analysis
Aggregate, group, and analyze data patterns:
Example requests:
- "Show monthly revenue trends"
- "Which products have the highest return rate?"
- "Calculate customer lifetime value"
Safety Features
All queries executed through this skill include:
- Parameterized queries: Automatic SQL injection prevention
- Query timeout protection: 30-second default timeout
- Transaction rollback: Automatic rollback on errors
- Read-only mode available: Can be configured for safe exploration
- Connection pooling: Efficient resource management
Configuration
The skill uses environment variables for database connection:
DB_HOST: PostgreSQL server hostname (default: localhost)DB_PORT: PostgreSQL port (default: 5432)DB_NAME: Database nameDB_USER: Database usernameDB_PASSWORD: Database passwordDB_CONNECTION_TIMEOUT: Connection timeout in milliseconds (default: 30000)
Claude Code Specific Notes
This skill integrates with the database-mcp-server MCP server, which is automatically configured in the marketplace.json manifest. The MCP server provides the following tools:
execute_query: Execute safe SQL queries with parametersget_schema: Retrieve table structure informationlist_tables: Get all tables in the databaseanalyze_query: Get query execution plans and optimization suggestions
Usage Tips
- Start with schema inspection before writing queries
- Use natural language - I'll translate to SQL
- Ask for explanations of results or query plans
- Request optimizations if queries seem slow
- Export results to CSV or JSON if needed
Examples
Basic Query
User: "Show me all users who registered this week"
Claude: I'll query the users table with a date filter...
Schema Exploration
User: "What's the structure of the products table?"
Claude: Let me get the schema information...
Data Analysis
User: "Calculate average order value by customer segment"
Claude: I'll write a query with GROUP BY and AVG...
For detailed API documentation and advanced usage, see shared/reference.md