跳到正文
cccskills
免费在 GitHub 公开

postgresql

PostgreSQL database agent: deploy locally (Docker/K8s), manage schemas, run queries, analyze performance, configure permissions, and seed data.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(13)

  • SKILL.md4.1 KB
  • references/common-errors.md12.6 KB
  • references/deployment.md12.0 KB
  • references/introspection-queries.md13.1 KB
  • references/performance-tuning.md13.2 KB
  • references/permissions-setup.md15.6 KB
  • references/schema-management.md12.4 KB
  • references/seed-data.md11.3 KB
  • references/system-views.md14.2 KB
  • resources/administration.md2.1 KB
  • resources/deployment.md911 B
  • resources/monitoring.md1.9 KB
  • resources/schema-management.md2.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

PostgreSQL Skill

SQL-native PostgreSQL operations via psql. No Python dependencies required.


Version Compatibility

FeatureMinimum Version
Core functionalityPostgreSQL 12+
pg_blocking_pids()9.6+
REINDEX CONCURRENTLY12+
pg_stat_progress_* views12+
VACUUM PARALLEL13+
pg_stat_wal14+
pg_stat_checkpointer17+

Recommended: PostgreSQL 14+


Connection

Environment Variables

export PGHOST=localhost
export PGPORT=5432
export PGUSER=app
export PGPASSWORD=secret
export PGDATABASE=myapp

Connect via psql

# Using environment variables
psql

# Using connection string
psql "postgresql://app:secret@localhost:5432/myapp"

# Docker
docker exec -it postgres psql -U app -d myapp

# Kubernetes
kubectl exec -it postgres -- psql -U postgres

Seed Data

Basic Insert

INSERT INTO app.users (email, name) VALUES
    ('alice@example.com', 'Alice'),
    ('bob@example.com', 'Bob')
RETURNING id, email;

Upsert

INSERT INTO app.users (email, name)
VALUES ('alice@example.com', 'Alice Updated')
ON CONFLICT (email) DO UPDATE SET
    name = EXCLUDED.name,
    updated_at = NOW();

Generate Test Data

INSERT INTO app.users (email, name)
SELECT
    'user' || n || '@example.com',
    'User ' || n
FROM generate_series(1, 1000) AS n;

COPY from CSV

\copy app.users (email, name) FROM 'users.csv' WITH (FORMAT csv, HEADER true);

Query Execution

Parameterized Queries

CRITICAL: Always use parameterized queries to prevent SQL injection.

-- In psql with variables
\set user_id 123
SELECT * FROM app.users WHERE id = :user_id;

-- Prepared statements
PREPARE get_user(bigint) AS
    SELECT * FROM app.users WHERE id = $1;
EXECUTE get_user(123);

Transactions

BEGIN;
    UPDATE app.accounts SET balance = balance - 100 WHERE id = 1;
    UPDATE app.accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

-- With savepoint
BEGIN;
    INSERT INTO app.orders (user_id, total) VALUES (1, 99.99);
    SAVEPOINT before_items;
    INSERT INTO app.order_items (order_id, product_id) VALUES (1, 999);
    -- Oops, rollback just the items
    ROLLBACK TO before_items;
COMMIT;

Safety Guidelines

CRITICAL: Follow these rules to prevent data loss and security issues.

  1. Always use parameterized queries - Never concatenate user input into SQL strings
  2. Wrap modifications in transactions - Use BEGIN/COMMIT for multi-statement changes
  3. Always include WHERE clause - Never run UPDATE/DELETE without WHERE
  4. Test on non-production first - Validate queries on dev/staging before production
  5. Use CONCURRENTLY for indexes - Avoid locking tables during index operations
  6. Backup before migrations - Always have a restore point before schema changes
  7. Limit query results - Use LIMIT during exploration to avoid memory issues

psql Quick Reference

CommandDescription
\lList databases
\c dbnameConnect to database
\dtList tables
\dt schema.*List tables in schema
\d tablenameDescribe table
\diList indexes
\dfList functions
\duList roles/users
\dnList schemas
\xToggle expanded display
\timingToggle query timing
\i file.sqlExecute SQL file
\copyImport/export CSV
\qQuit

Resource Files

For detailed guidance, read these on-demand:


Input / Output

This skill defines no input parameters or structured output.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Standards for authoring SDD plugin agents — frontmatter, self-containment, skill references, and no-user-interaction rules.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Scaffolds Node.js/TypeScript backend components with CMDO architecture, driven by component settings.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

CMDO architecture standards for Node.js/TypeScript backends with strict layer separation.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Intent-to-command mappings for fullstack-typescript tech pack features.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Create change specification and implementation plan with dynamic phase generation. Supports feature, bugfix, refactor, and epic types.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

Orchestrates the full change lifecycle — routes actions to phase-specific sub-files.

中文简介正在准备中。当前显示原文说明。

LiorCohen/sdd432026年2月24日 更新

查看 LiorCohen 的全部技能

报告此技能的问题