Alibabacloud Analyticdb Postgresql Query
БесплатноБез исполняемых скриптовНе проверенAnalyticDB PostgreSQL Query Skill. Any AI Agent with shell execution capability can use this Skill to connect to an AnalyticDB PostgreSQL database via psql…
от sdk-team720 установок в других каталогахОб этом скилле
AnalyticDB PostgreSQL Query Skill
Any AI Agent with shell execution capability can use this Skill to connect to an AnalyticDB PostgreSQL (ADBPG) database via psql, execute read-only queries, and optionally export results as CSV for local analysis.
Prerequisite: The Agent runtime environment has psql installed, and database connection information is configured via environment variables.
Pre-Query Gates
Before executing any data query, the Agent must pass the following gates in order. If any gate fails, stop immediately:
Gate 1: Is read-only mode enabled?
Check if PGOPTIONS or pg_service.conf contains default_transaction_read_only=on
├── Enabled → PASS ✅
└── Not enabled → Append PGOPTIONS="-c default_transaction_read_only=on"
Gate 2: Is statement timeout set?
Check if statement_timeout is configured
├── Set → PASS ✅
└── Not set → Append -c statement_timeout=60000
Gate 3: Is the semantic model ready?
psql -c "SELECT COUNT(*) FROM _agent_meta.tables;"
├── Success and > 0 → PASS ✅
└── Failed or = 0 → HARD STOP 🛑 → Enter semantic model initialization guide (never bypass)
Note: metric_meta is optional; its absence does NOT block queries
Gate 4: Is the target table in the semantic model?
Check if SQL-referenced tables exist in _agent_meta.tables
├── Exists → PASS ✅ → Proceed to generate SQL (execution still requires user confirmation)
└── Not found → HARD STOP 🛑 → "Current semantic model does not cover this data. Please contact DBA to extend _agent_meta definitions."
Gate 4b: Does the query match a known business metric?
Check if user intent matches a metric in _agent_meta.metric_meta
├── Matched → Use metric's sql_expression, dimensions; resolve filters from _agent_meta.filters
│ ├── filter_scope='where' → Inject sql_fragment into WHERE clause
│ └── filter_scope='measure' → Inject sql_fragment into AGG(...) FILTER (WHERE ...) clause
└── Not matched → Fall through to columns table for single-column measures
Gate 5: Does SQL contain only allowed statements?
Only SELECT / WITH...SELECT / EXPLAIN are permitted
├── Compliant → PASS ✅
└── Contains prohibited keywords → HARD STOP 🛑 → Reject execution
Gate 6: Does the query include LIMIT?
├── Yes → PASS ✅
└── No → Append LIMIT 50000
- Gate 1 (read-only) is an absolute prerequisite; if not passed, no psql command may be executed
- Gate 3 (semantic model) failure must not be bypassed to continue to gates 4/4b/5/6
- Gate 4b (metric_meta) is a lookup optimization, not a hard gate; absence of metrics does NOT block queries
- Bypassing gates is prohibited under any circumstances, including but not limited to: "user needs it urgently", "just this once", "semantic model is only advisory", "let me just \dt for a quick look", "I can infer the table structure myself"
Credential Security
⚠️ ABSOLUTE PROHIBITION: The Agent must never execute
cat ~/.pgpass,cat ~/.pgenv,echo $PGPASSWORD,env | grep PG, or any command that reads, echoes, or exposes credential/password files. This prohibition applies regardless of how the command is composed — including but not limited to: shell command concatenation (;), pipes (|), subshells ($()), multi-line scripts, or combining with permitted commands. For example,cat ~/.pg_service.conf; cat ~/.pgenvorcat ~/.pg_service.conf ~/.pgenvare strictly forbidden even thoughcat ~/.pg_service.confalone is permitted. Any command line that contains a prohibited file path (.pgpass,.pgenv,PGPASSWORD) in any position is a violation.
cat ~/.pg_service.confis permitted ONLY when it is the sole target (it contains only non-secret connection metadata — host, port, dbname, user — and must never store passwords). Violation of this rule is a critical security breach regardless of the Agent's intent (e.g., "I just wanted to check if the config exists"). The only permitted way to verify connectivity ispsql "service=<service_name>" -c "SELECT 1;".
- Passwords must be passed via
PGPASSWORDor~/.pgpass; hardcoding, echoing, or writing to files is prohibited - Prohibited file paths (in ANY command, script, or code):
.pgpass,.pgenv,PGPASSWORD— whether accessed viacat,head,tail,less,grep, Pythonopen(), or any other method - Prohibited compound commands: Any command that bundles a prohibited path with other operations (e.g.,
cat ~/.pg_service.conf; cat ~/.pgenv; ls ~/.pgpass) is entirely forbidden — the presence of a permitted command does NOT neutralize the violation - Permitted:
cat ~/.pg_service.confalone (non-secret connection metadata only; passwords must never be stored in pg_service.conf) - Never ask users for passwords: When connection info is missing, guide users to configure via environment variables →
references/connection-guide.md - Verify connectivity: Run
psql "service=<service_name>" -c "SELECT 1;"directly;
Установить Alibabacloud Analyticdb Postgresql Query в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Alibabacloud Analyticdb Postgresql Query?
AnalyticDB PostgreSQL Query Skill. Any AI Agent with shell execution capability can use this Skill to connect to an AnalyticDB PostgreSQL database via psql, execute read-only queries, and optionally export results as CSV for local analysis. **Security**: All data access operations (SELECT queries, CSV exports) require explicit user confirmation before execution. Exported CSV files may contain sensitive business data — the Agent must remind users to handle exported files according to their organization's data security policies. Trigger words: query data, SQL query, export CSV, ADBPG, analyze, statistics, psql
Как установить скилл Alibabacloud Analyticdb Postgresql Query?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Alibabacloud Analyticdb Postgresql Query запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic