{"id":"a6638134-eac8-489c-b780-497cf54cf0bd","shortId":"Lksw6y","kind":"skill","title":"postgres","tagline":"Execute read-only SQL queries against multiple PostgreSQL databases. Use when: (1) querying PostgreSQL databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descr","description":"# PostgreSQL Read-Only Query Skill\n\nExecute safe, read-only queries against configured PostgreSQL databases.\n\n## Requirements\n\n- Python 3.8+\n- psycopg2-binary: `pip install -r requirements.txt`\n\n## Setup\n\nCreate `connections.json` in the skill directory or `~/.config/claude/postgres-connections.json`.\n\n**Security**: Set file permissions to `600` since it contains credentials:\n```bash\nchmod 600 connections.json\n```\n\n```json\n{\n  \"databases\": [\n    {\n      \"name\": \"production\",\n      \"description\": \"Main app database - users, orders, transactions\",\n      \"host\": \"db.example.com\",\n      \"port\": 5432,\n      \"database\": \"app_prod\",\n      \"user\": \"readonly_user\",\n      \"password\": \"your-password\",\n      \"sslmode\": \"require\"\n    }\n  ]\n}\n```\n\n### Config Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| name | Yes | Identifier for the database (case-insensitive) |\n| description | Yes | What data this database contains (used for auto-selection) |\n| host | Yes | Database hostname |\n| port | No | Port number (default: 5432) |\n| database | Yes | Database name |\n| user | Yes | Username |\n| password | Yes | Password |\n| sslmode | No | SSL mode: disable, allow, prefer (default), require, verify-ca, verify-full |\n\n## Usage\n\n### List configured databases\n```bash\npython3 scripts/query.py --list\n```\n\n### Query a database\n```bash\npython3 scripts/query.py --db production --query \"SELECT * FROM users LIMIT 10\"\n```\n\n### List tables\n```bash\npython3 scripts/query.py --db production --tables\n```\n\n### Show schema\n```bash\npython3 scripts/query.py --db production --schema\n```\n\n### Limit results\n```bash\npython3 scripts/query.py --db production --query \"SELECT * FROM orders\" --limit 100\n```\n\n## Database Selection\n\nMatch user intent to database `description`:\n\n| User asks about | Look for description containing |\n|-----------------|--------------------------------|\n| users, accounts | users, accounts, customers |\n| orders, sales | orders, transactions, sales |\n| analytics, metrics | analytics, metrics, reports |\n| logs, events | logs, events, audit |\n\nIf unclear, run `--list` and ask user which database.\n\n## Safety Features\n\n- **Read-only session**: Connection uses PostgreSQL `readonly=True` mode (primary protection)\n- **Query validation**: Only SELECT, SHOW, EXPLAIN, WITH queries allowed\n- **Single statement**: Multiple statements per query rejected\n- **SSL support**: Configurable SSL mode for encrypted connections\n- **Query timeout**: 30-second statement timeout enforced\n- **Memory protection**: Max 10,000 rows per query to prevent OOM\n- **Column width cap**: 100 char max per column for readable output\n- **Credential sanitization**: Error messages don't leak passwords\n\n## Troubleshooting\n\n| Error | Solution |\n|-------|----------|\n| Config not found | Create `connections.json` in skill directory |\n| Authentication failed | Check username/password in config |\n| Connection timeout | Verify host/port, check firewall/VPN |\n| SSL error | Try `\"sslmode\": \"disable\"` for local databases |\n| Permission warning | Run `chmod 600 connections.json` |\n\n## Exit Codes\n\n- **0**: Success\n- **1**: Error (config missing, auth failed, invalid query, database error)\n\n## Workflow\n\n1. Run `--list` to show available databases\n2. Match user intent to database description\n3. Run `--tables` or `--schema` to explore structure\n4. Execute query with appropriate LIMIT","tags":["postgres","skills","sanjay3290","agent-skills","ai-skills","atlassian","azure-devops","claude-code","claude-skills","confluence","deep-research","elevenlabs"],"capabilities":["skill","source-sanjay3290","skill-postgres","topic-agent-skills","topic-ai-skills","topic-atlassian","topic-azure-devops","topic-claude-code","topic-claude-skills","topic-confluence","topic-deep-research","topic-elevenlabs","topic-gmail","topic-google-calendar","topic-google-drive"],"categories":["ai-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sanjay3290/ai-skills/postgres","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sanjay3290/ai-skills","source_repo":"https://github.com/sanjay3290/ai-skills","install_from":"skills.sh"}},"qualityScore":"0.574","qualityRationale":"deterministic score 0.57 from registry signals: · indexed on github topic:agent-skills · 248 github stars · SKILL.md body (3,395 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-02T18:54:11.774Z","embedding":null,"createdAt":"2026-04-18T22:05:24.033Z","updatedAt":"2026-05-02T18:54:11.774Z","lastSeenAt":"2026-05-02T18:54:11.774Z","tsv":"'/.config/claude/postgres-connections.json':73 '0':385 '000':320 '1':14,387,398 '10':197,319 '100':226,330 '2':18,405 '3':22,412 '3.8':57 '30':311 '4':29,420 '5432':102,150 '600':79,86,381 'account':243,245 'allow':166,293 'analysi':28 'analyt':252,254 'app':94,104 'appropri':424 'ask':236,267 'audit':261 'auth':391 'authent':357 'auto':139 'auto-select':138 'avail':403 'bash':84,180,187,200,208,216 'binari':60 'ca':172 'cap':329 'case':127 'case-insensit':126 'char':331 'check':30,359,367 'chmod':85,380 'code':384 'column':327,334 'config':115,349,362,389 'configur':52,178,303 'connect':36,277,308,363 'connections.json':67,87,353,382 'contain':82,135,241 'content':32 'creat':66,352 'credenti':83,338 'custom':246 'data':27,132 'databas':11,17,20,31,35,54,89,95,103,125,134,143,151,153,179,186,227,233,270,376,395,404,410 'db':190,203,211,219 'db.example.com':100 'default':149,168 'descr':38 'descript':92,119,129,234,240,411 'directori':71,356 'disabl':165,373 'encrypt':307 'enforc':315 'error':340,347,370,388,396 'event':258,260 'execut':2,45,421 'exit':383 'explain':290 'explor':19,418 'fail':358,392 'featur':272 'field':116,117 'file':76 'firewall/vpn':368 'found':351 'full':175 'host':99,141 'host/port':366 'hostnam':144 'identifi':122 'insensit':128 'instal':62 'intent':231,408 'invalid':393 'json':88 'leak':344 'limit':196,214,225,425 'list':177,183,198,265,400 'local':375 'log':257,259 'look':238 'main':93 'match':229,406 'max':318,332 'memori':316 'messag':341 'metric':253,255 'miss':390 'mode':164,282,305 'multipl':9,34,296 'name':90,120,154 'number':148 'oom':326 'order':97,224,247,249 'output':337 'password':109,112,158,160,345 'per':298,322,333 'permiss':77,377 'pip':61 'port':101,145,147 'postgr':1 'postgresql':10,16,39,53,279 'prefer':167 'prevent':325 'primari':283 'prod':105 'product':91,191,204,212,220 'protect':284,317 'psycopg2':59 'psycopg2-binary':58 'python':56 'python3':181,188,201,209,217 'queri':7,15,25,43,50,184,192,221,285,292,299,309,323,394,422 'r':63 'read':4,41,48,274 'read-on':3,40,47,273 'readabl':336 'readon':107,280 'reject':300 'report':256 'requir':55,114,118,169 'requirements.txt':64 'result':215 'row':321 'run':23,264,379,399,413 'safe':46 'safeti':271 'sale':248,251 'sanit':339 'schema':207,213,416 'schemas/tables':21 'scripts/query.py':182,189,202,210,218 'second':312 'secur':74 'select':24,140,193,222,228,288 'session':276 'set':75 'setup':65 'show':206,289,402 'sinc':80 'singl':294 'skill':44,70,355 'skill-postgres' 'solut':348 'source-sanjay3290' 'sql':6 'ssl':163,301,304,369 'sslmode':113,161,372 'statement':295,297,313 'structur':419 'success':386 'support':33,302 'tabl':199,205,414 'timeout':310,314,364 'topic-agent-skills' 'topic-ai-skills' 'topic-atlassian' 'topic-azure-devops' 'topic-claude-code' 'topic-claude-skills' 'topic-confluence' 'topic-deep-research' 'topic-elevenlabs' 'topic-gmail' 'topic-google-calendar' 'topic-google-drive' 'transact':98,250 'tri':371 'troubleshoot':346 'true':281 'unclear':263 'usag':176 'use':12,136,278 'user':96,106,108,155,195,230,235,242,244,268,407 'usernam':157 'username/password':360 'valid':286 'verifi':171,174,365 'verify-ca':170 'verify-ful':173 'warn':378 'width':328 'workflow':397 'yes':121,130,142,152,156,159 'your-password':110","prices":[{"id":"c380cea5-cc55-45ad-9fcd-860d13a8f6d9","listingId":"a6638134-eac8-489c-b780-497cf54cf0bd","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sanjay3290","category":"ai-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:05:24.033Z"}],"sources":[{"listingId":"a6638134-eac8-489c-b780-497cf54cf0bd","source":"github","sourceId":"sanjay3290/ai-skills/postgres","sourceUrl":"https://github.com/sanjay3290/ai-skills/tree/main/skills/postgres","isPrimary":false,"firstSeenAt":"2026-04-18T22:05:24.033Z","lastSeenAt":"2026-05-02T18:54:11.774Z"}],"details":{"listingId":"a6638134-eac8-489c-b780-497cf54cf0bd","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sanjay3290","slug":"postgres","github":{"repo":"sanjay3290/ai-skills","stars":248,"topics":["agent-skills","ai-skills","atlassian","azure-devops","claude-code","claude-skills","confluence","deep-research","elevenlabs","gmail","google-calendar","google-drive","google-workspace","imagen","jira","mcp","mysql","notebooklm","postgresql","text-to-speech"],"license":"apache-2.0","html_url":"https://github.com/sanjay3290/ai-skills","pushed_at":"2026-04-13T14:16:19Z","description":"Collection of agent skills for AI coding assistants","skill_md_sha":"26570e14ce96ed5c1efb71e0f872f13256fe5b79","skill_md_path":"skills/postgres/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sanjay3290/ai-skills/tree/main/skills/postgres"},"layout":"multi","source":"github","category":"ai-skills","frontmatter":{"name":"postgres","license":"Apache-2.0","description":"Execute read-only SQL queries against multiple PostgreSQL databases. Use when: (1) querying PostgreSQL databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks all write operations (INSERT, UPDATE, DELETE, DROP, etc.) for safety."},"skills_sh_url":"https://skills.sh/sanjay3290/ai-skills/postgres"},"updatedAt":"2026-05-02T18:54:11.774Z"}}