# postgres-nio

A skill that gives the agent a working reference for talking to PostgreSQL from Swift with postgres-nio: connections, pooling, prepared statements and COPY FROM.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 62
- Author: wendylabsinc
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/wendylabsinc/claude-skills/tree/HEAD/postgres-nio/SKILL.md
- Updated: 2026-10-22
- HTML: https://affpapa.org/en/nevibecode/skills/postgres-nio

## What it does

The skill loads the agent with guidance on the postgres-nio library and how it is used in Swift. It covers creating a `PostgresClient`, running queries with async/await and turning result rows into tuples or your own types. Prepared statements through `PostgresPreparedStatement` get their own section, as do transactions inside `withConnection` and bulk inserts with `copyFrom`.

Connection setup is spelled out too: TLS modes `.disable`, `.prefer` and `.require`, pool limits, idle timeouts and Unix socket connections. On injection safety the skill shows that interpolated values become `$1, $2, …` bindings, while table and column names go through `unescaped`. That escape hatch is meant for trusted identifiers only — never for anything a user typed. A type mapping table between Swift and PostgreSQL is included, along with `PSQLError` handling by code such as `.uniqueViolation`.

A companion file, `references/postgres-patterns.md`, holds the deeper material the agent reaches for: wire protocol details and backpressure-aware row streaming. Installing the skill does not add anything to your project. For the sample code to compile, `Package.swift` still needs the `postgres-nio` package at version 1.21.0 or later.

## Requirements
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill postgres-nio -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/postgres-nio/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/postgres-nio/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill postgres-nio -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/postgres-nio/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill postgres-nio -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/postgres-nio/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wendylabsinc/claude-skills postgres-nio
```

2. **Manually: put the files in place**
- File: `.github/skills/postgres-nio/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill postgres-nio -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wendylabsinc/claude-skills --path postgres-nio
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/postgres-nio/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill postgres-nio -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wendylabsinc/claude-skills/tree/HEAD/postgres-nio/SKILL.md

## When to use it
- turn a PostgreSQL query into parameter bindings instead of string concatenation
- set up a connection pool with idle timeouts
- define a prepared statement with a typed result row
- bulk-load a large set of rows with COPY FROM
- tell a unique violation apart from a foreign key error

## Example prompts
- Show me how to connect to PostgreSQL with `PostgresClient` and a connection pool
- Rewrite this query as a `PostgresPreparedStatement` in Swift
- How do I load an array of rows into the `users` table with `copyFrom`?

## Similar
- [postgres-patterns](https://affpapa.org/en/nevibecode/skills/postgres-patterns.md) — skill · 5200 installs
- [postgres-best-practices](https://affpapa.org/en/nevibecode/skills/neondatabase-postgres-best-practices.md) — skill · 1900 installs
- [postgres](https://affpapa.org/en/nevibecode/skills/sanjay3290-postgres.md) — skill · 620 installs
- [design-postgres-tables](https://affpapa.org/en/nevibecode/skills/design-postgres-tables.md) — skill · 613 installs
- [Postgres MCP](https://affpapa.org/en/nevibecode/mcp/edelciomolina-postgres-mcp.md) — MCP server · ★ 5
- [migrate-postgres-tables-to-hypertables](https://affpapa.org/en/nevibecode/skills/migrate-postgres-tables-to-hypertables.md) — skill · 355 installs

From the same set: [wendylabsinc/claude-skills](https://affpapa.org/en/nevibecode/by/wendylabsinc/claude-skills.md) — 7 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
