Agent skill

Generating Stored Procedures

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

A skill your agent uses when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server.

MITAuto-check passedDatabases

Install Generating Stored Procedures

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-stored-procedures -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace generating-stored-procedures --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/generating-stored-procedures .claude/skills/generating-stored-procedures && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
generating-stored-procedures
GitHub stars
2.8k
Token cost
~1.8k tokens
SKILL.md length
231 words
Files
13 (incl. scripts, references, assets)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server.

  • Works in 5 steps: Identify Database Type and Requirements → Generate Stored Procedure → Add Transaction Management → …
  • You need to generate
  • SKILL.md covers Prerequisites, Instructions, Output and Error Handling, plus 3 more sections
  • Runs Python scripts from its folder; calls python3

What it does

Generating Stored Procedures is an agent skill from jeremylongshore/tons-of-skills-marketplace. Use when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server. Creates database functions, triggers, and procedures with proper error handling and transaction management. Trigger with phrases like "generate stored procedure", "create database function", "write SQL procedure", "add trigger to table", or "create CRUD procedures".

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 16 other files, including scripts, reference files and assets (for example `assets/README.md`, `config/settings.yaml` and `references/README.md`). Compatibility notes: Designed for Claude Code

It sits in Databases, covering SQL and Error handling. It works with PostgreSQL, MySQL, Microsoft SQL Server and SQL. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • You need to generate
  • Deploy stored procedures for PostgreSQL
  • With phrases like generate stored procedure
  • Create database function

Example prompts

  • “generate stored procedure”
  • “create database function”
  • “write SQL procedure”
  • “/generating-stored-procedures”

Requirements

  • Python 3
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(sqlcmd:*), Bash(python3:*)

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Identify Database Type and Requirements
  2. Generate Stored Procedure
  3. Add Transaction Management
  4. Validate Syntax
  5. Deploy to Database

What it can do on your machine

Read from SKILL.md and the folder at commit cfae287. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(psql:*)
    • Bash(mysql:*)
    • Bash(sqlcmd:*)
    • Bash(python3:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 4 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Generating Stored Procedures loads about 1.8k tokens when it runs, and up to ~10k if it reads all its reference files. Until then it costs about 101 tokens; SKILL.md has 231 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~101
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~10k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit cfae287, republished under its MIT licence (© jeremylongshore). 231 words, ~1,776 tokens.

Download SKILL.mdSave it as .claude/skills/generating-stored-procedures/SKILL.md (or your agent's skills folder). This skill also uses 12 other files; get the full folder from GitHub.
name
generating-stored-procedures
description
Use when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server. Creates database functions, triggers, and procedures with proper error handling and transaction management. Trigger with phrases like "generate stored procedure", "create database function", "write SQL procedure", "add trigger to table", or "create CRUD procedures".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(sqlcmd:*), Bash(python3:*)
compatibility
Designed for Claude Code
version
1.29.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
database, deployment, postgresql, mysql

Stored Procedure Generator

Generate production-ready stored procedures for PostgreSQL, MySQL, and SQL Server with proper error handling, transaction management, and security best practices.

Prerequisites

  • Database connection credentials (host, port, database, user, password)
  • Appropriate permissions: CREATE PROCEDURE, CREATE FUNCTION, EXECUTE
  • Target database type identified (PostgreSQL, MySQL, or SQL Server)

Instructions

Step 1: Identify Database Type and Requirements

Determine the target database and procedure requirements:

sql
-- PostgreSQL: Check version and extensions
SELECT version();
\dx

-- MySQL: Check version and settings
SELECT VERSION();
SHOW VARIABLES LIKE 'sql_mode';

-- SQL Server: Check version and edition
SELECT @@VERSION;
Step 2: Generate Stored Procedure

PostgreSQL Function (PL/pgSQL):

sql
CREATE OR REPLACE FUNCTION get_user_by_id(p_user_id INTEGER)
RETURNS TABLE(id INTEGER, username VARCHAR, email VARCHAR, created_at TIMESTAMP)
LANGUAGE plpgsql
AS $$
BEGIN
    RETURN QUERY
    SELECT u.id, u.username, u.email, u.created_at
    FROM users u
    WHERE u.id = p_user_id;

    IF NOT FOUND THEN
        RAISE EXCEPTION 'User with ID % not found', p_user_id
            USING ERRCODE = 'P0002';
    END IF;
END;
$$;

MySQL Stored Procedure:

sql
DELIMITER //
CREATE PROCEDURE GetUserById(IN p_user_id INT)
BEGIN
    DECLARE user_exists INT DEFAULT 0;

    SELECT COUNT(*) INTO user_exists FROM users WHERE id = p_user_id;

    IF user_exists = 0 THEN
        SIGNAL SQLSTATE '45000'  # 45000 = configured value
            SET MESSAGE_TEXT = 'User not found';
    END IF;

    SELECT id, username, email, created_at
    FROM users
    WHERE id = p_user_id;
END //
DELIMITER ;

SQL Server Stored Procedure (T-SQL):

sql
CREATE PROCEDURE dbo.GetUserById
    @UserId INT
AS
BEGIN
    SET NOCOUNT ON;

    IF NOT EXISTS (SELECT 1 FROM dbo.Users WHERE Id = @UserId)
    BEGIN
        RAISERROR('User with ID %d not found', 16, 1, @UserId);
        RETURN;
    END

    SELECT Id, Username, Email, CreatedAt
    FROM dbo.Users
    WHERE Id = @UserId;
END;
GO
Step 3: Add Transaction Management

PostgreSQL with Transaction:

sql
CREATE OR REPLACE FUNCTION transfer_funds(
    p_from_account INTEGER,
    p_to_account INTEGER,
    p_amount NUMERIC(15,2)
)
RETURNS BOOLEAN
LANGUAGE plpgsql
AS $$
BEGIN
    -- Debit source account
    UPDATE accounts SET balance = balance - p_amount
    WHERE id = p_from_account AND balance >= p_amount;

    IF NOT FOUND THEN
        RAISE EXCEPTION 'Insufficient funds or invalid source account';
    END IF;

    -- Credit destination account
    UPDATE accounts SET balance = balance + p_amount
    WHERE id = p_to_account;

    IF NOT FOUND THEN
        RAISE EXCEPTION 'Invalid destination account';
    END IF;

    RETURN TRUE;
EXCEPTION
    WHEN OTHERS THEN
        RAISE;
END;
$$;

MySQL with Transaction:

sql
DELIMITER //
CREATE PROCEDURE TransferFunds(
    IN p_from_account INT,
    IN p_to_account INT,
    IN p_amount DECIMAL(15,2)
)
BEGIN
    DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
        ROLLBACK;
        RESIGNAL;
    END;

    START TRANSACTION;

    UPDATE accounts SET balance = balance - p_amount
    WHERE id = p_from_account AND balance >= p_amount;

    IF ROW_COUNT() = 0 THEN
        SIGNAL SQLSTATE '45000'  # 45000 = configured value
            SET MESSAGE_TEXT = 'Insufficient funds';
    END IF;

    UPDATE accounts SET balance = balance + p_amount
    WHERE id = p_to_account;

    COMMIT;
END //
DELIMITER ;
Step 4: Validate Syntax

Use the validation script to check procedure syntax:

bash
# Validate PostgreSQL procedure
python3 ${CLAUDE_SKILL_DIR}/scripts/stored_procedure_syntax_validator.py \
    --db-type postgresql \
    --file procedure.sql

# Validate MySQL procedure
python3 ${CLAUDE_SKILL_DIR}/scripts/stored_procedure_syntax_validator.py \
    --db-type mysql \
    --file procedure.sql
Step 5: Deploy to Database
bash
# Deploy to PostgreSQL
python3 ${CLAUDE_SKILL_DIR}/scripts/stored_procedure_deployer.py \
    --db-type postgresql \
    --host localhost \
    --database mydb \
    --file procedure.sql

# Deploy to MySQL
python3 ${CLAUDE_SKILL_DIR}/scripts/stored_procedure_deployer.py \
    --db-type mysql \
    --host localhost \
    --database mydb \
    --file procedure.sql

Output

  • SQL procedure file with proper syntax for target database
  • Validation report confirming syntax correctness
  • Deployment confirmation with execution results
  • Rollback script for procedure removal

Error Handling

ErrorCauseSolution
permission deniedMissing CREATE PROCEDURE privilegeGRANT CREATE PROCEDURE ON database TO user;
syntax errorInvalid SQL for database typeUse database-specific syntax validator
function already existsProcedure exists without OR REPLACEAdd OR REPLACE or DROP first
undefined columnReferenced column doesn't existVerify table schema before deployment
transaction abortedError during transactionCheck EXCEPTION handler and ROLLBACK logic

Examples

Generate CRUD procedures for a table:

User: Generate CRUD stored procedures for the 'products' table in PostgreSQL

Claude: I'll create four procedures for the products table:
1. create_product - Insert new product
2. get_product - Retrieve by ID
3. update_product - Update existing product
4. delete_product - Soft delete product

Create audit trigger:

User: Create a trigger to log all changes to the orders table

Claude: I'll create an audit trigger that:
1. Creates an orders_audit table if not exists
2. Captures INSERT, UPDATE, DELETE operations
3. Records old/new values, user, and timestamp

Resources

  • ${CLAUDE_SKILL_DIR}/references/postgresql_stored_procedure_best_practices.md
  • ${CLAUDE_SKILL_DIR}/references/mysql_stored_procedure_best_practices.md
  • ${CLAUDE_SKILL_DIR}/references/sqlserver_stored_procedure_best_practices.md
  • ${CLAUDE_SKILL_DIR}/references/database_security_guidelines.md
  • ${CLAUDE_SKILL_DIR}/references/stored_procedure_optimization_techniques.md

Overview

Use when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 12 other files (scripts, references, assets) in skills/.curated/generating-stored-procedures of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • assets/README.md
  • config/settings.yaml
  • references/README.md
  • references/database_security_guidelines.md
  • references/mysql_stored_procedure_best_practices.md
  • references/postgresql_stored_procedure_best_practices.md
  • references/sqlserver_stored_procedure_best_practices.md
  • references/stored_procedure_optimization_techniques.md
  • scripts/README.md
  • scripts/database_connection_test.py
  • scripts/stored_procedure_deployer.py
  • scripts/stored_procedure_syntax_validator.py

Open the folder on GitHubat commit cfae287

Compare with similar skills

Generating Stored Procedures next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Generating Stored Procedures compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Generating Stored Procedures this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.8kAutomated safety check: PassMIT
Database Migrations SQL Migrationsrmyndharis/antigravity-skills1.7k3 repos~577Automated safety check: NotesMIT
SQL ProJeffallan/claude-skills12k—~1.3kAutomated safety check: PassMIT
SQL Optimizationgithub/awesome-copilot40k2 repos~2.3kAutomated safety check: PassMIT
SQL Code Reviewgithub/awesome-copilot40k1 repos~2.2kAutomated safety check: PassMIT
Cloud SQL Basicsgoogle/skills21k—~973Automated safety check: PassApache-2.0

Similar skills

  • Database Migrations SQL Migrations

    rmyndharis/antigravity-skills

    SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, SQL Server

    1.7k GitHub starsUsed in 3 repos~577 tokens
    DatabasesAuto-check: notes
  • SQL Pro

    Jeffallan/claude-skills

    Optimizes SQL queries and designs schemas using CTEs, window functions, covering indexes and EXPLAIN ANALYZE, with notes on dialect differences between major databases.

    12k GitHub stars~1.3k tokensUpdated 7 days ago
    DatabasesAuto-check passed
  • SQL Optimization

    github/awesome-copilot

    Official

    Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server…

    40k GitHub starsUsed in 2 repos~2.3k tokens
    DatabasesAuto-check passed
  • SQL Code Review

    github/awesome-copilot

    Official

    Universal SQL code review assistant that performs comprehensive security, maintainability, and code quality analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle).

    40k GitHub starsUsed in 1 repo~2.2k tokens
    DatabasesAuto-check passed
  • Cloud SQL Basics

    google/skills

    Official

    This file generates or explains Cloud SQL resources. An agent skill from google/skills.

    21k GitHub stars~973 tokensUpdated yesterday
    DatabasesAuto-check passed
  • Optimizing SQL

    ancoleman/ai-design-components

    Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server.

    525 GitHub stars~3k tokensUpdated 10 mo ago
    DatabasesAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Categories

Questions about Generating Stored Procedures

What does Generating Stored Procedures do?

A skill your agent uses when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server. Generating Stored Procedures is an agent skill from jeremylongshore/tons-of-skills-marketplace. Use when you need to generate, validate, or deploy stored procedures for PostgreSQL, MySQL, or SQL Server.

When should I use Generating Stored Procedures?

Generating Stored Procedures fits situations like: you need to generate; deploy stored procedures for PostgreSQL; with phrases like generate stored procedure; create database function.

How do I install Generating Stored Procedures in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-stored-procedures -a claude-code`. Or copy the skill folder (skills/.curated/generating-stored-procedures in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/generating-stored-procedures in your project. Claude Code loads it when a task matches its description.

How do I install Generating Stored Procedures in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-stored-procedures -a codex`. Or copy the skill folder (skills/.curated/generating-stored-procedures in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/generating-stored-procedures in your project. Codex loads it when a task matches its description.

Can I use Generating Stored Procedures in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-stored-procedures -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/generating-stored-procedures, .gemini/skills/generating-stored-procedures, .github/skills/generating-stored-procedures and .opencode/skills/generating-stored-procedures in your project.

What does Generating Stored Procedures need to run?

Going by SKILL.md and its folder, Generating Stored Procedures needs Python for the scripts in its folder and the command-line tools its instructions call (python3). Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(sqlcmd:*), Bash(python3:*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Generating Stored Procedures access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Generating Stored Procedures safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Generating Stored Procedures use?

Generating Stored Procedures is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Generating Stored Procedures use?

About 1.8k tokens (SKILL.md is roughly 7.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.5k tokens, read only when the agent opens those files.

What are the alternatives to Generating Stored Procedures?

Skills that share tags, products or a category with Generating Stored Procedures: Database Migrations SQL Migrations (rmyndharis/antigravity-skills, 1.7k stars), SQL Pro (Jeffallan/claude-skills, 12k stars), SQL Optimization (github/awesome-copilot, 40k stars) and SQL Code Review (github/awesome-copilot, 40k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Generating Stored Procedures?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,827 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 10, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.