postgres-readonly-queries
하는 일
이 에이전트는 PostgreSQL 데이터베이스에 안전하게 질문하고 데이터만 읽도록 합니다. 설정한 여러 데이터베이스에 연결하며, 실수로 아무것도 바꾸지 않도록 합니다.
사용하는 경우
- ✓변경될 위험 없이 PostgreSQL 데이터베이스의 데이터를 보아야 할 때.
- ✓데이터베이스의 테이블과 열을 살펴볼 때.
- ✓고객이나 주문 목록처럼 데이터베이스의 특정 정보를 확인하는 경우.
스킬 링크
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/postgres-readonly-queries/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“운영 데이터베이스에서 사용자 처음 10명을 나열해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
파일에 PostgreSQL 데이터베이스의 연결 정보를 설정합니다. 그다음 에이전트에게 SQL 쿼리(데이터를 가져오는 명령)를 실행하도록 요청할 수 있으며, 이 쿼리는 항상 읽기 전용이라 안전합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PostgreSQL Read-Only Query Skill
When to Use
- Use when querying PostgreSQL databases and access must stay strictly read-only
- Use when exploring schemas, tables, and data across multiple configured connections
- Use when you want defense-in-depth protection against accidental INSERT/UPDATE/DELETE or DDL
Execute safe, read-only queries against configured PostgreSQL databases.
Requirements
- Python 3.8+
- psycopg2-binary:
pip install -r requirements.txt
Setup
Create connections.json in the skill directory or ~/.config/claude/postgres-connections.json.
Security: Set file permissions to 600 since it contains credentials:
chmod 600 connections.json
{
"databases": [
{
"name": "production",
"description": "Main app database - users, orders, transactions",
"host": "db.example.com",
"port": 5432,
"database": "app_prod",
"user": "readonly_user",
"password": "your-password",
"sslmode": "require"
}
]
}
Config Fields
| Field | Required | Description |
|---|---|---|
| name | Yes | Identifier for the database (case-insensitive) |
| description | Yes | What data this database contains (used for auto-selection) |
| host | Yes | Database hostname |
| port | No | Port number (default: 5432) |
| database | Yes | Database name |
| user | Yes | Username |
| password | Yes | Password |
| sslmode | No | SSL mode: disable, allow, prefer (default), require, verify-ca, verify-full |
Usage
List configured databases
python3 scripts/query.py --list
Query a database
python3 scripts/query.py --db production --query "SELECT * FROM users LIMIT 10"
List tables
python3 scripts/query.py --db production --tables
Show schema
python3 scripts/query.py --db production --schema
Limit results
python3 scripts/query.py --db production --query "SELECT * FROM orders" --limit 100
Database Selection
Match user intent to database description:
| User asks about | Look for description containing |
|---|---|
| users, accounts | users, accounts, customers |
| orders, sales | orders, transactions, sales |
| analytics, metrics | analytics, metrics, reports |
| logs, events | logs, events, audit |
If unclear, run --list and ask user which database.
Safety Features
- Read-only session: Connection uses PostgreSQL
readonly=Truemode (primary protection) - Query validation: Only SELECT, SHOW, EXPLAIN, WITH queries allowed
- Single statement: Multiple statements per query rejected
- SSL support: Configurable SSL mode for encrypted connections
- Query timeout: 30-second statement timeout enforced
- Memory protection: Max 10,000 rows per query to prevent OOM
- Column width cap: 100 char max per column for readable output
- Credential sanitization: Error messages don't leak passwords
Troubleshooting
| Error | Solution |
|---|---|
| Config not found | Create connections.json in skill directory |
| Authentication failed | Check username/password in config |
| Connection timeout | Verify host/port, check firewall/VPN |
| SSL error | Try "sslmode": "disable" for local databases |
| Permission warning | Run chmod 600 connections.json |
Exit Codes
- 0: Success
- 1: Error (config missing, auth failed, invalid query, database error)
Workflow
- Run
--listto show available databases - Match user intent to database description
- Run
--tablesor--schemato explore structure - Execute query with appropriate LIMIT
Limitations
- Read-only protections reduce accidental writes but cannot override database-server policy, triggers, extensions, or an over-privileged account. Use a database role with read-only permissions as the primary control.
- Query results can contain personal, confidential, or regulated data. Confirm the intended database and avoid exporting or sharing results without explicit authorization.
- The script is not a replacement for backups, auditing, access reviews, or production change controls.
자주 묻는 질문
데이터를 바꾸려고 하면 어떻게 되나요?
에이전트는 변경을 막도록 설계되어 있습니다. SELECT 같은 읽기 명령만 허용하며, 실수로 데이터를 수정하거나 삭제하지 못하도록 추가 보호 장치가 있습니다.
에이전트는 어떤 데이터베이스에 연결할지 어떻게 아나요?
설정된 데이터베이스 목록을 보고 이름이나 설명으로 하나를 고를 수 있습니다. 에이전트는 질문을 바탕으로 어떤 데이터베이스를 원하는지 추측하기도 합니다.
제 비밀번호를 넣어도 안전한가요?
예, 보안 지침을 따른다면 안전합니다. 비밀번호는 사용자만 읽고 쓸 수 있도록 제한된 권한을 가진 특별한 설정 파일에 들어 있으며, 에이전트는 오류 메시지에 비밀번호를 표시하지 않습니다.
상세 정보
작성자의 원본 설명
Execute safe read-only SQL queries against PostgreSQL databases with multi-connection support and defense-in-depth write protection.
인기도
- GitHub 스타
- 48k
- 순위
- #6291
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
00-andruia-consultant
48k에이전트가 AI 프로젝트를 시작하거나 개선할 수 있도록 코드를 분석하고 스페인어로 실행 계획을 세워 줍니다.
007
48k에이전트가 보안 감사와 위협 모델링을 수행해 공격과 취약점으로부터 프로젝트를 보호하도록 돕습니다.
10-andruia-skill-smith
48k에이전트가 AI 도구의 작동 방식을 정의하고 문서를 쓰며 구조를 검증하도록 돕습니다.
20-andruia-niche-intelligence
48k에이전트가 신뢰할 수 있는 자료를 바탕으로 특정 산업의 맥락, 규칙, 사용 패턴, 위험을 정리한 요약을 만들도록 돕습니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.