Harness Component — Command
Psql Query
Run ad-hoc PostgreSQL analytics queries against dev/test database
Runtimeclaude-code
Stackpostgres
Intenttest
Definition
PostgreSQL Analytics
Run analytics queries against the local database using psql or mix run.
Rules
- NEVER run against production
- Use READ-ONLY queries (SELECT only)
- For complex analysis, use
Repo.query/2in a Mix task - Format results as ASCII tables or pipe to
column -t
Tidewave Integration
If Tidewave MCP is available, prefer it over psql/mix run:
mcp__tidewave__execute_sql_queryfor direct SQL queriesmcp__tidewave__project_evalfor Ecto-based queries viaRepo.query!/2orRepo.all/1
Fall back to psql/mix run only if Tidewave is not detected.
Workflow
- Check if Tidewave MCP is available — if yes, use
mcp__tidewave__execute_sql_query - Otherwise, detect database URL from
config/dev.exsorDATABASE_URL - Run query via:
psql $DATABASE_URL -c "YOUR QUERY" --expanded - For Ecto:
mix run -e 'MyApp.Repo.query!("SELECT ...") |> IO.inspect()' - Summarize results
Example prompts
- "How many users signed up this week?"
- "Show me the slowest queries from pg_stat_statements"
- "What's the table size distribution?"
- "Show index usage stats"