stored-procedures

aj-geddes/useful-ai-prompts · updated Apr 8, 2026

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill stored-procedures
0 commentsdiscussion
summary

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

skill.md

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:

Guide Contents
Simple Functions Simple Functions
Stored Procedures Stored Procedures
Simple Procedures Simple Procedures
Complex Procedures with Error Handling Complex Procedures with Error Handling
PostgreSQL Triggers PostgreSQL Triggers
MySQL Triggers MySQL 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

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.572 reviews
  • Naina Li· Dec 24, 2024

    stored-procedures is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Carlos Shah· Dec 20, 2024

    Useful defaults in stored-procedures — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Naina Tandon· Dec 12, 2024

    stored-procedures has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Xiao Gonzalez· Dec 4, 2024

    stored-procedures fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Alexander Rao· Nov 23, 2024

    We added stored-procedures from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Noor Zhang· Nov 23, 2024

    stored-procedures reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Kaira Jackson· Nov 15, 2024

    Keeps context tight: stored-procedures is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Kwame Tandon· Nov 11, 2024

    stored-procedures has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Alexander Thomas· Nov 11, 2024

    I recommend stored-procedures for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Xiao Park· Nov 3, 2024

    Useful defaults in stored-procedures — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

showing 1-10 of 72

1 / 8