Skills Azure PostgreSQL for TypeScript (node-postgres)
📦

Azure PostgreSQL for TypeScript (node-postgres)

Safe 🔑 Env variables

Connect TypeScript Apps to Azure PostgreSQL with Enterprise Security

Building production applications requires secure, scalable database connections. This skill provides complete patterns for Azure PostgreSQL with connection pooling, transactions, and passwordless Microsoft Entra ID authentication.

Supports: Claude Codex Code(CC)
📊 69 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "Azure PostgreSQL for TypeScript (node-postgres)". User asks for a basic PostgreSQL connection setup

Expected outcome:

Provides a complete TypeScript code example showing Client initialization with environment variables, SSL configuration, connection establishment, query execution, and proper connection cleanup in a try/finally block.

Using "Azure PostgreSQL for TypeScript (node-postgres)". User needs connection pooling for production

Expected outcome:

Delivers a Pool configuration with production settings including max 20 connections, 30 second idle timeout, examples of query execution, explicit client checkout for multiple queries, and proper release patterns.

Using "Azure PostgreSQL for TypeScript (node-postgres)". User wants passwordless Entra ID authentication

Expected outcome:

Shows DefaultAzureCredential setup, token acquisition for PostgreSQL resource, using the token as password in client configuration, and a wrapper class for automatic token refresh before expiry.

Security Audit

Safe
v1 • 2/25/2026

This is a prompt-only skill containing documentation and code examples for Azure PostgreSQL connections. Static analysis scanned 0 files with 0 code lines since the skill only contains a SKILL.md documentation file. No executable code patterns, external commands, network calls, or dangerous operations were detected. The skill provides educational content about secure database connection practices including parameterized queries, SSL configuration, and proper credential handling.

0
Files scanned
0
Lines analyzed
1
findings
1
Total audits

Risk Factors

🔑 Env variables (1)
Audited by: claude

Quality Score

38
Architecture
100
Maintainability
87
Content
32
Community
100
Security
74
Spec Compliance

What You Can Build

Production API Backend

Build scalable backend services with connection pooling that efficiently handles concurrent database requests and automatic connection management.

Enterprise Secure Applications

Implement passwordless database authentication using Microsoft Entra ID managed identities for enhanced security compliance.

Data-Intensive Applications

Execute complex multi-statement operations with transaction support ensuring data consistency and integrity.

Try These Prompts

Basic PostgreSQL Connection
Show me how to connect to Azure PostgreSQL from TypeScript using the pg client with password authentication and SSL enabled.
Connection Pool Configuration
Create a connection pool for Azure PostgreSQL with proper configuration for production use including max connections, idle timeout, and connection timeout settings.
Microsoft Entra ID Authentication
Show me how to implement passwordless authentication to Azure PostgreSQL using Microsoft Entra ID managed identity with automatic token refresh.
Transaction with Error Handling
Create a transaction helper function that wraps database operations with BEGIN, COMMIT, and ROLLBACK logic including proper error handling and connection release.

Best Practices

  • Always use parameterized queries instead of string concatenation to prevent SQL injection vulnerabilities
  • Use connection pools instead of single connections for production applications to improve performance and resource utilization
  • Enable SSL with rejectUnauthorized set to true for all Azure PostgreSQL connections to ensure encrypted communication

Avoid

  • Never concatenate user input directly into SQL queries - always use parameterized queries with placeholders
  • Avoid creating new Client instances for every query - this exhausts database connections and degrades performance
  • Do not skip token refresh logic when using Entra ID authentication - tokens expire after approximately one hour

Frequently Asked Questions

What is the difference between Client and Pool in node-postgres?
Client represents a single database connection suitable for simple scripts. Pool manages multiple connections, automatically handling checkout and release for concurrent requests, making it ideal for production applications.
How do I handle Microsoft Entra ID token expiration?
Implement a wrapper class that tracks token expiry time and acquires a fresh token 5 minutes before expiration. The provided AzurePostgresPool class demonstrates this pattern automatically.
Why does Azure PostgreSQL require SSL with rejectUnauthorized set to true?
Azure enforces encrypted connections for security. Setting rejectUnauthorized to true ensures the server certificate is validated, preventing man-in-the-middle attacks.
What pool size should I use for Azure PostgreSQL?
Start with max 20 connections for medium workloads. Adjust based on your Azure tier's connection limits and monitor pool.waitingCount to detect when connections are exhausted.
How do I run the same query for multiple parameter sets efficiently?
Use pool.query() for single queries or checkout a client with pool.connect() for multiple related queries. Always release the client back to the pool using client.release() in a finally block.
Can I use this skill with PostgreSQL servers not hosted on Azure?
Yes, the core pg package works with any PostgreSQL server. However, Microsoft Entra ID authentication and some Azure-specific configurations only apply to Azure Database for PostgreSQL.

Developer Details

File structure

📄 SKILL.md