postgres
Skill59 starsChanged 2 months agoMITView on GitHub
Postgres behaviour worth checking before relying on it — type choices, index kinds and their costs, reading EXPLAIN output, isolation levels and lock behaviour during DDL, and row-level security. Use when the project runs on Postgres (including Postgres-backed services) and a decision depends on what the engine actually does: picking a column type, adding an index, changing isolation, or writing and debugging an RLS policy. Not for engine-neutral modelling decisions, and not for the measure-fix-measure loop on one slow query.
15 other projects use a version of this.
Adopted by
Most recently taken up by
- fworks-tech/agenthoodtheir own version, first seen Sep 28, 2026
- timescale/pg-aiguidetheir own version, first seen Sep 2, 2026
- chenwei791129/agent-skillstheir own version, first seen Aug 29, 2026
- LDKTC/Agent-P-FullStacktheir own version, first seen Jul 31, 2026
- magnus919/agent-skillstheir own version, first seen Jul 21, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Jul 14, 2026
Used with
Projects with it also use mysql, sentry and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
planetscaleSkillmysql
Plan and review MySQL/InnoDB schema, indexing, query tuning, transactions, and operations. Use when creating or modifying MySQL tables, indexes, or queries; diagnosing slow/locking behavior; planning migrations; or troubleshooting replication and connection issues. Load when using a MySQL database.
Also in 4 projects that use this
OpenAISkillsentry
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry CLI; perform read-only queries using the `sentry` command.
Also in 3 projects that use this
OpenAISkilllinear
Manage issues, projects & team workflows in Linear. Use when the user wants to read, create or updates tickets in Linear.
Also in 3 projects that use this
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- timescale/pg-aiguide★ 1.9ksame name
- planetscale/database-skills★ 692same name
- sanjay3290/ai-skills★ 429same name
- magnus919/agent-skills★ 109same name
- damusix/skills★ 62same name
- digitalocean-labs/do-app-platform-skills★ 36same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- mamamou/ai-coding-skills★ 16same name
- qhkm/zeptoclaw-skills★ 4same name
- fworks-tech/agenthood★ 3same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository79 other files it gives its agents.
- agent-dispatcherSkill
- agent-designSkill
- agent-evalsSkill
- context-engineeringSkill
- llm-observabilitySkill
- mcp-designSkill
- memory-designSkill
- model-routingSkill
- prompt-engineeringSkill
- prompt-injection-defenseSkill
- retrieval-ragSkill
- structured-outputSkill
- tool-designSkill
- api-contract-verificationSkill
- api-designSkill
- authenticationSkill
- authorizationSkill
- background-jobsSkill
- cachingSkill
- idempotency-and-retriesSkill
- webhooksSkill
- database-migration-verificationSkill
- data-integritySkill
- data-pipelinesSkill
- data-qualitySkill
- migrationsSkill
- query-optimizationSkill
- schema-designSkill
- accessibilitySkill
- accessibility-verificationSkill
- design-systemsSkill
- design-to-codeSkill
- frontend-designSkill
- motion-designSkill
- responsive-designSkill
- ui-auditSkill
- ux-writingSkill
- ci-cdSkill
- deploymentSkill
- dockerSkill
- github-actionsSkill
- incident-responseSkill
- observabilitySkill
- release-verificationSkill
- rollbackSkill
- component-architectureSkill
- frontend-performanceSkill
- shadcn-uiSkill
- stack-detectionSkill
- tailwindSkill
- visual-verificationSkill
- competitive-analysisSkill
- copywritingSkill
- data-analysisSkill
- deep-researchSkill
- documentation-verificationSkill
- positioningSkill
- seoSkill
- source-evaluationSkill
- technical-writingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
Remember what indexes cost and what they do not do: Every index is maintained on every write.
- Distinctive: line 67
Keep statistics honest: Run ANALYZE after a bulk load or a large backfill, because a plan built on empty-table statistics is not the plan …
- Distinctive: line 90
A feature is missing or the syntax is rejected: Check version and extensions before rewriting the query.
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Postgres
Most Postgres surprises come from defaults: the default isolation level, the default lock an
ALTER TABLE takes, what happens to a table with RLS enabled and no policy. Check the default
before designing around what you assume it is.
When this fires
The project is on Postgres and the answer depends on engine behaviour rather than on modelling. It does not fire as a tour — read the section the decision needs. It does not fire for another engine, and Postgres-compatible services differ in what they permit, so confirm rather than assume.
Procedure
- Establish what you are actually talking to.
select version();and list the installed extensions before writing DDL that depends on one. Major versions differ in defaults and in available syntax, and an extension you assume is present (citext,pg_stat_statements,pgcrypto,postgis) is either installed or it is not. If the version is unknown, prefer the long-standing form of a feature over the newest one. - Choose types on meaning.
textfor strings unless a length is a real constraint worth enforcing; timezone-aware timestamps for instants and plaindatefor dates;numericfor money and never a float;uuidas a type rather than a string;jsonbwhen the shape is genuinely open, with the understanding that it defers validation to every reader. Enum types are cheap to extend and awkward to shrink — a lookup table with a foreign key is the reversible version. - Know what each index kind is for. B-tree is the default and serves equality, ranges and ordering. GIN suits containment queries over documents, arrays and full-text. GiST suits ranges and geometry, and backs exclusion constraints. BRIN is for very large tables whose physical order tracks the indexed value. Partial indexes carry a WHERE clause and are the tool for "at most one active row"; expression indexes match predicates that wrap the column in a function.
- Remember what indexes cost and what they do not do. Every index is maintained on every write. In a multicolumn index, column order decides which queries it can serve. Declaring a foreign key does not create an index on the referencing column — a missing one shows up as slow cascading deletes and slow parent updates. A unique index treats NULLs as distinct by default, so it does not prevent repeated NULL rows.
- Get a plan before believing any performance claim.
EXPLAINgives estimates;EXPLAIN (ANALYZE, BUFFERS)runs the statement and reports what really happened. Because ANALYZE executes, run a data-modifying statement inside a transaction you roll back — and on a shared database, ask before running it at all. Read the actual-versus-estimated row counts first: a large gap means the planner is working from statistics that do not describe this data. The per-node loop count multiplies the reported time. The tuning loop itself belongs to the query-optimization skill. - Pick an isolation level for what the code needs. The default, READ COMMITTED, gives each
statement a fresh snapshot, so two statements in one transaction can legitimately disagree.
REPEATABLE READ holds one snapshot for the whole transaction. SERIALIZABLE enforces invariants
no constraint can express, at the price of serialization failures the application must catch
and retry — choosing it without a retry path converts a rare anomaly into a user-visible error.
Explicit row locks (
FOR UPDATE) are the narrower tool when the conflict is one row. - Treat locking as part of any DDL. Schema changes take table-level locks, and a statement waiting for one blocks every query queued behind it, so a fast migration can still stop the application. Set a lock timeout, keep each statement short, and build indexes concurrently when the table is live — noting that a concurrent build runs outside a transaction block and can leave an invalid index behind that has to be dropped and retried. Running any of this against a shared or production database is an authorized action: produce the statements, say what they will lock, and stop.
- Write RLS policies against the role that will run the query. Enabling row-level security on
a table with no policy denies everything.
USINGdecides which rows are visible or reachable;WITH CHECKdecides which rows may be written — a policy with onlyUSINGcan still let a row be written into a state the writer cannot see afterwards. Permissive policies combine with OR, restrictive ones with AND. The table owner is not subject to RLS unless the table forces it, so testing a policy while connected as the owner proves nothing: test as the application role. - Keep statistics honest. Run ANALYZE after a bulk load or a large backfill, because a plan built on empty-table statistics is not the plan production will get. Correlated columns routinely produce bad estimates that no index fixes; extended statistics are the tool for that case. Long-lived transactions hold back cleanup and cause bloat — check for them before blaming the query.
- Check the connection layer before debugging session state. Under transaction-level pooling,
session-scoped things —
SET, advisory locks, temporary tables — do not reliably belong to the next statement your code runs. If an RLS context or a timeout is set per session, confirm the pooling mode supports it.
Checklist
- Server version and installed extensions confirmed, not assumed
- Types chosen for meaning; no float money, no string-typed timestamps
- Index kind and column order justified by the predicate and ordering it must serve
- Any performance claim backed by a plan, not by reasoning about the query text
- Isolation level named, with the retry path if serialization failures are possible
- DDL's lock behaviour stated; nothing run against a shared database without authorization
- RLS policies cover read and write, and were exercised as the application role
- Statistics refreshed after any bulk data change that precedes a measurement
Failure handling
- A feature is missing or the syntax is rejected. Check version and extensions before rewriting the query; a managed Postgres service may also withhold superuser-level operations entirely. Report the restriction instead of routing around it with something weaker.
- The plan on your machine does not match production. Different data volume, different statistics, different configuration. State which environment produced the plan; a plan from a small dataset supports no conclusion about production.
- RLS "works" in testing. Confirm the role. Owner and bypass-privileged roles skip policies, and a policy that was never actually applied looks exactly like one that permits everything.
- A migration hangs. It is waiting on a lock, and it is now also blocking everything behind it. Find the blocking transaction rather than retrying. Cancel and reschedule instead of waiting it out during traffic.
- An index was added and nothing got faster. The planner may be right to ignore it. Re-read the plan before adding another; two unused indexes cost more than one.
Evidence to report
The version and extensions you confirmed; the exact DDL or SQL; plans quoted as output rather than described; which role and which database the check ran as; lock and rollout implications for anything not yet applied. Say which environment each result came from, and never describe DDL you have only written as DDL that has been executed, tested or deployed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

