Back to Skills

postgresql-json

verified

Work with JSONB data - queries, indexing, transformations

View on GitHub

Marketplace

pluginagentmarketplace-postgresql

pluginagentmarketplace/custom-plugin-postgresql

Plugin

ultrathink

Repository

pluginagentmarketplace/custom-plugin-postgresql
1stars

skills/postgresql-json/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-postgresql/blob/main/skills/postgresql-json/SKILL.md -a claude-code --skill postgresql-json

Installation paths:

Claude
.claude/skills/postgresql-json/
Powered by add-skill CLI

Instructions

# PostgreSQL JSON Skill

> Atomic skill for JSONB operations

## Overview

Production-ready patterns for JSONB queries, indexing, and transformations.

## Prerequisites

- PostgreSQL 16+
- Understanding of JSON structure

## Parameters

```yaml
parameters:
  operation:
    type: string
    required: true
    enum: [query, index, transform, aggregate]
  json_path:
    type: string
```

## Quick Reference

### JSONB Operators
| Operator | Description | Example |
|----------|-------------|---------|
| `->` | Get object | `data->'user'` |
| `->>` | Get as text | `data->>'name'` |
| `@>` | Contains | `data @> '{"active":true}'` |
| `?` | Key exists | `data ? 'email'` |

### Index Patterns
```sql
CREATE INDEX idx_data ON t USING GIN(data);  -- Containment
CREATE INDEX idx_data_path ON t USING GIN(data jsonb_path_ops);  -- Faster @>
CREATE INDEX idx_status ON t ((data->>'status'));  -- Specific key
```

### Common Operations
```sql
-- Nested update
UPDATE docs SET data = jsonb_set(data, '{user,verified}', 'true');

-- Array append
UPDATE docs SET data = jsonb_set(data, '{tags}', (data->'tags') || '"new"');

-- Aggregate
SELECT jsonb_agg(jsonb_build_object('id', id, 'name', name)) FROM users;
```

## Troubleshooting

| Error | Cause | Solution |
|-------|-------|----------|
| `22P02` | Invalid JSON | Validate syntax |
| Slow @> | No GIN index | Create GIN index |
| NULL path | Key missing | Check with ? |

## Usage

```
Skill("postgresql-json")
```

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
1424 chars