supabase-functions

Generate secure PostgreSQL functions for Supabase with SECURITY INVOKER and explicit search_path.

4|Updated Dec 13, 2025
One-click install
npx skills add https://github.com/linehaul-ai/linehaulai-claude-marketplace --skill supabase-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supabase-functions
Source: https://github.com/linehaul-ai/linehaulai-claude-marketplace/tree/main/.claude-plugin/supabase/skills/postgres-functions
Command: npx skills add https://github.com/linehaul-ai/linehaulai-claude-marketplace --skill supabase-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps generate PostgreSQL functions for Supabase with security-focused patterns, including SECURITY INVOKER defaults and safe search_path usage, to ensure secure, production-ready database logic.

Core Features & Use Cases

  • Function Templates: Basic function, parameterized functions, error handling
  • Security Patterns: SECURITY INVOKER, set search_path, fully qualified names
  • Triggers & Helpers: Trigger functions and helper patterns for RLS
  • Use case: Implement server-side calculations or data transformations in the database.

Quick Start

Example: create a function my_schema.calculate_total_price(order_id bigint) with SECURITY INVOKER and set search_path to ''.

Frequently Asked Questions about supabase-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create secure PostgreSQL functions for Supabase?

Secure PostgreSQL functions for Supabase use SECURITY INVOKER by default, explicit search_path configuration, and fully qualified object references. This enforces least-privilege execution, prevents privilege escalation, and ensures predictable behavior across schemas and security contexts in production environments.

What is SECURITY INVOKER and why does it matter in Supabase functions?

SECURITY INVOKER makes a PostgreSQL function execute with the caller's privileges rather than the function owner's. This prevents privilege escalation attacks and is the security-first default for Supabase functions, especially critical when functions interact with Row-Level Security policies.

How do I safely handle dynamic SQL in PostgreSQL functions?

Safe dynamic SQL uses parameterized queries, input validation, and explicit error handling. Avoid string concatenation; use format() with %I for identifiers and %L for literals, validate all inputs before execution, and implement try-catch patterns to prevent SQL injection and uncontrolled failures.

Can I use PostgreSQL functions with Supabase Row-Level Security?

Yes. PostgreSQL functions work with Supabase RLS through helper routines and trigger functions that respect security context. Functions must use SECURITY INVOKER and fully qualified references to integrate safely with RLS policies and client-library authentication.

What's the best way to organize search_path in Supabase functions?

Set search_path explicitly to the schemas your function needs, typically starting with an empty string to require fully qualified names. This prevents schema conflicts, ensures predictable object resolution, and blocks privilege-escalation attacks via malicious schema precedence.

Do I need to validate inputs in every Supabase function I write?

Yes. Input validation is essential for production-ready Supabase functions. Validate data types, ranges, and formats before use; combine with parameterized queries and error handling to prevent injection attacks, logic errors, and unhandled database failures.