postgresql-server-programming/SKILL.md
PostgreSQL server-side programming sourced from "PostgreSQL Server Programming" (Usama Dar, Packt) and "Introduction to PostgreSQL for the Data Professional". Covers PL/pgSQL functions and procedures (structure, variables, error handling, loops, cursors), trigger functions (row-level, statement-level, WHEN conditions), event triggers (DDL auditing), extensions (creating and publishing), and best practices (SOA, DRY, KISS). Companion to postgresql-fundamentals and postgresql-advanced-sql.
npx skillsauth add peterbamuhigire/skills-web-dev postgresql-server-programmingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
postgresql-server-programming or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.Use server-side code for integrity, auditing, and data-local transformation. Keep business logic that requires application context in the application layer.
CREATE OR REPLACE FUNCTION function_name(param1 type, param2 type)
RETURNS return_type
LANGUAGE plpgsql
AS $$
DECLARE
var1 data_type := initial_value;
var2 data_type;
rec RECORD;
BEGIN
-- body
RETURN result;
END;
$$;
| Category | Description | Optimiser Benefit |
|---|---|---|
| IMMUTABLE | Same input always gives same output, no DB access | Most aggressive inlining |
| STABLE | Same input gives same output within a transaction | Safe for index scans |
| VOLATILE (default) | Can return different results or modify data | No optimisation |
-- Immutable: pure computation
CREATE FUNCTION slugify(text) RETURNS text LANGUAGE sql IMMUTABLE AS $$
SELECT lower(regexp_replace(regexp_replace($1, '[^a-zA-Z0-9\s-]', '', 'g'), '\s+', '-', 'g'));
$$;
-- Stable: reads DB but doesn't modify it
CREATE FUNCTION get_exchange_rate(currency text) RETURNS numeric LANGUAGE sql STABLE AS $$
SELECT rate FROM exchange_rates WHERE code = currency;
$$;
Extended guidance for postgresql-server-programming was moved to references/skill-deep-dive.md to keep this entrypoint compact and fast to load.
Use that deep dive for:
Variables and Data TypesControl FlowError HandlingReturning Structured DataStored ProceduresTrigger FunctionsEvent Triggers (DDL Auditing)CursorsExtensionsProgramming Best PracticesAnti-Patternsdata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...