postgres
0
总安装量
5
周安装量
安装命令
npx skills add https://github.com/alemar11/skills --skill postgres
Agent 安装分布
cursor
5
codex
4
opencode
3
gemini-cli
3
kimi-cli
3
Skill 文档
Postgres
Goal
Use this skill to connect to Postgres and run user-requested queries or checks.
Workflow
- Confirm connection source:
- If
DB_URLis provided, use it for a one-off connection unless the user asks to persist it. - Use
postgres.tomlwhen present; otherwise ask the user for the data required to create a profile. - If a
postgres.tomlis already present under the current repo/root at.skills/postgres/postgres.toml, treat that repo/root as the project root and proceed without prompting forDB_PROJECT_ROOT. - If not in a git repo, or if running outside the target project, set
DB_PROJECT_ROOT/PROJECT_ROOTexplicitly. - When creating or loading
postgres.tomland the target project is a git repo, verify.skills/postgres/postgres.tomlis gitignored to avoid committing credentials. - If
postgres.tomlexists, first ensure it is at the latest schema version. Run./scripts/migrate_toml_schema.shonly when an older schema is found, and run it from the skill dir only ifDB_PROJECT_ROOT/PROJECT_ROOTis set.
- If
- Choose action:
- Connect/run a query, inspect schema, or run a helper script.
- Execute and report:
- Run the requested action and summarize results or errors.
- If a connection test fails, run
./scripts/check_deps.shand/or./scripts/connection_info.shto diagnose.
- Persist only if asked:
- Update TOML only with explicit user approval, except
[configuration].pg_bin_pathwhich may be auto-written when missing.schema_versionis written by the migration helper. Prompt before changing an existing value.
- Update TOML only with explicit user approval, except
Config and schema (brief)
- Config file:
<project-root>/.skills/postgres/postgres.toml - Template (canonical schema):
assets/postgres.toml.example - Schema history/migrations:
references/postgres_skill_schema.md - Best practices index:
references/postgres_best_practices/README.md - Scripts are intended to be run from the skill directory; set
DB_PROJECT_ROOT/PROJECT_ROOTto the target project root.
Trigger rules (summary)
- If
<project-root>/.skills/postgres/postgres.tomlexists, do not scan by default; only scan when asked or missing. - If that TOML is under the current repo/root, use that root for scripts without asking for
DB_PROJECT_ROOT. - If
DB_PROFILEis unset and any profiles defineproject, auto-select the profile matching the current subproject (based on cwd); otherwise ask forDB_PROFILE. - If
postgres.tomlis missing, ask for host/port/database/user/password to create a profile (ask forsslmodeonly if needed). - If the requested profile is missing, ask for the profile details to add it.
- If the user provides a connection URL, infer missing fields from it.
- Ask whether to save the profile into
postgres.tomlor use a one-off (temporary) connection. - For migrations path resolution and schema-change workflow, follow the guardrails reference.
Guardrails (summary)
- Always ask for approval before making any database structure change (DDL like CREATE/ALTER/DROP).
- Keep pending changes in prerelease migration files and maintain a changelog.
- Never touch any file or folder whose name ends with
released(case-insensitive) inside the migrations folder. - After any schema change, run the least expensive query that confirms the change.
- For full rules and migration workflow, read
references/postgres_guardrails.mdwhen doing schema changes.
Common requests
- Check connection:
DB_PROFILE=local ./scripts/test_connection.sh - Postgres version:
DB_PROFILE=local ./scripts/pg_version.sh - Connection details:
DB_PROFILE=local ./scripts/connection_info.sh - Find objects by name:
DB_PROFILE=local ./scripts/find_objects.sh users
Usage references
- Setup, env defaults, and script catalog:
references/postgres_usage.md