write-script-postgresql

Write PostgreSQL queries with typed $N::TYPE parameter placeholders.

Updated Feb 21, 2026
One-click install
npx skills add https://github.com/adamkingsbury/unified-data-model --skill write-script-postgresql-adamkingsbury
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-script-postgresql
Source: https://github.com/adamkingsbury/unified-data-model/tree/main/.claude/skills/write-script-postgresql
Command: npx skills add https://github.com/adamkingsbury/unified-data-model --skill write-script-postgresql-adamkingsbury

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL developers often write ad-hoc queries with inline literals and untyped placeholders, which leads to type mismatches, SQL injection risks, and hard-to-maintain scripts. This Skill standardizes parameter usage and typing to improve reliability.

Core Features & Use Cases

  • Inline parameter declarations using $N::{TYPE} and a preceding comment line to name the parameter, e.g. -- $1
  • Support for typed parameters (TEXT, INT, DATE, etc.) to ensure correct casting and comparisons
  • Produces deterministic SQL scripts that are easy to read, review, and reuse as templates for common tasks like data retrieval and updates

Quick Start

Use a PostgreSQL script that declares parameters with $N::TYPE and comments like -- $1 user_id before the statement to create a reusable, typed query template.

Frequently Asked Questions about write-script-postgresql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write PostgreSQL queries with safe, typed parameterized placeholders?

To write PostgreSQL queries with typed parameterized placeholders, declare parameters inline using $N::{TYPE} syntax with preceding comment lines for naming, ensuring correct casting and reducing type mismatch errors.

What is the best way to prevent SQL injection risks in ad-hoc PostgreSQL scripts?

The best way to prevent SQL injection risks in ad-hoc PostgreSQL scripts is to standardize parameter usage with typed placeholders like $1::INT, avoiding inline literals and enforcing predictable, type-checked statements.

How do I create reusable query templates for PostgreSQL data retrieval?

To create reusable PostgreSQL query templates, use deterministic SQL scripts with inline parameter declarations like $N::TEXT and comment-based parameter names, producing easy-to-read and review templates for common tasks.

Does PostgreSQL support inline parameter declaration with type casting?

Yes, PostgreSQL supports inline parameter declaration with type casting using the $N::{TYPE} syntax, ensuring correct data type comparisons and providing predictable, type-checked scripts for development and production environments.

Why do my PostgreSQL scripts fail with type mismatch errors using untyped placeholders?

PostgreSQL scripts fail with type mismatch errors when using untyped placeholders because standard parameters lack enforced casting, whereas using $N::{TYPE} ensures correct type casting and prevents comparison errors.

Can I use typed parameterized queries for both development and production PostgreSQL environments?

Yes, you can use typed parameterized queries in both development and production PostgreSQL environments, as they produce deterministic SQL scripts that are easy to read, review, and reuse as templates for data retrieval and updates.