Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aj-geddes avatar

Stored Procedures

  • 403 installs
  • 305 repo stars
  • Updated March 4, 2026
  • aj-geddes/useful-ai-prompts

stored-procedures is a Claude Code skill that implements PostgreSQL and MySQL stored procedures, functions, and triggers for developers who need reusable server-side database logic and validation.

About

stored-procedures is a database skill from aj-geddes/useful-ai-prompts that guides agents through writing PostgreSQL plpgsql functions, multi-step procedures, error-handling patterns, and MySQL or PostgreSQL triggers. It opens with a PostgreSQL scalar-function quick start—calculate_order_total with IMMUTABLE semantics—and links six reference guides for simple functions, stored procedures, complex error handling, and database-specific triggers. Developers use stored-procedures when business rules belong in the database layer, when multi-step transactions need atomic server-side execution, or when audit trails and validation must run close to data. The skill stresses reusable routines, performance-aware design, and disciplined testing before deployment rather than scattering logic across application code.

  • AI
  • Developer tool

Stored Procedures by the numbers

  • 403 all-time installs (skills.sh)
  • Ranked #1,963 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill stored-procedures

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs403
repo stars305
Last updatedMarch 4, 2026
Repositoryaj-geddes/useful-ai-prompts

How do you write PostgreSQL stored procedures?

For integrating A developer tool for AI integration and automation

Who is it for?

Backend developers moving validation, calculations, or multi-step data workflows into PostgreSQL or MySQL routines.

Skip if: ORM-only application layers where all business logic must stay in application code with no database routines.

When should I use this skill?

A developer asks to create a stored procedure, database function, or trigger in PostgreSQL or MySQL.

What you get

SQL function and procedure definitions, trigger scripts, error-handling patterns, and reference implementations for PostgreSQL and MySQL.

  • SQL stored procedures
  • database functions
  • trigger definitions

By the numbers

  • Includes 6 reference guides for functions, procedures, and triggers
  • Covers PostgreSQL plpgsql and both PostgreSQL and MySQL triggers

Files

SKILL.mdMarkdownGitHub ↗

Stored Procedures & Functions

Table of Contents

Overview

Implement stored procedures, functions, and triggers for business logic, data validation, and performance optimization. Covers procedure design, error handling, and performance considerations.

When to Use

  • Business logic encapsulation
  • Complex multi-step operations
  • Data validation and constraints
  • Audit trail maintenance
  • Performance optimization
  • Code reusability across applications
  • Trigger-based automation

Quick Start

PostgreSQL - Scalar Function:

-- Create function returning single value
CREATE OR REPLACE FUNCTION calculate_order_total(
  p_subtotal DECIMAL,
  p_tax_rate DECIMAL,
  p_shipping DECIMAL
)
RETURNS DECIMAL AS $$
BEGIN
  RETURN ROUND((p_subtotal * (1 + p_tax_rate) + p_shipping)::NUMERIC, 2);
END;
$$ LANGUAGE plpgsql IMMUTABLE;

-- Use in queries
SELECT id, subtotal, calculate_order_total(subtotal, 0.08, 10) as total
FROM orders;

-- Or in application code
SELECT * FROM orders
WHERE calculate_order_total(subtotal, 0.08, 10) > 100;

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Simple FunctionsSimple Functions
Stored ProceduresStored Procedures
Simple ProceduresSimple Procedures
Complex Procedures with Error HandlingComplex Procedures with Error Handling
PostgreSQL TriggersPostgreSQL Triggers
MySQL TriggersMySQL Triggers

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

Related skills

How it compares

Use stored-procedures for server-side SQL routines rather than ORM migration or schema-design skills.

FAQ

Which databases does stored-procedures support?

stored-procedures focuses on PostgreSQL plpgsql functions and procedures plus PostgreSQL and MySQL triggers. Six reference guides cover simple functions, procedures, complex error handling, and database-specific trigger syntax.

When should logic move into a stored procedure?

stored-procedures recommends database routines for business-rule encapsulation, multi-step atomic operations, audit trails, and performance-sensitive calculations reused across applications. Skip it when all logic must remain in application services.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.