Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/pridiuksson/orchestration-patterns-for-llms/supabase-function-startergit clone --depth 1 https://github.com/pridiuksson/orchestration-patterns-for-llmsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/pridiuksson/orchestration-patterns-for-llms/supabase-function-starter)<a href="https://agentmods.dev/rules/pridiuksson/orchestration-patterns-for-llms/supabase-function-starter"><img src="https://agentmods.dev/badge/rules/pridiuksson/orchestration-patterns-for-llms/supabase-function-starter.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01848 |
| Opus 5 | $0.00000 | $0.00924 |
| Sonnet 5 | $0.00000 | $0.00370 |
| Haiku 4.5 | $0.00000 | $0.00185 |
Grade A, and why
supabase-function-starter scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 195 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Supabase Function Starter Template
FOR AI AGENTS: Use this exact boilerplate for new Edge Functions. All patterns are production-tested and include critical environment-aware logic.
📁 Create: supabase/functions/[function-name]/index.ts
import { createClient } from 'npm:@supabase/supabase-js@2';
// AI imports (uncomment if needed):
// import { getChatCompletion } from '../_shared/ai_adapters/gemini_2_5_flash_adapter.ts';
// import { GoogleGenAI } from 'npm:@google/[email protected]';
// import { Buffer } from 'node:buffer';
Deno.serve(async (req) => {
// Standard CORS (never modify)
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
};
if (req.method === 'OPTIONS') {
return new Response('ok', { headers: corsHeaders });
}
try {
// Environment validation (production pattern)
const requiredVars = ['SUPABASE_URL', 'SUPABASE_ANON_KEY'];
for (const envVar of requiredVars) {
if (!Deno.env.get(envVar)) {
throw new Error(`Missing environment variable: ${envVar}`);
}
}
// === ADMIN AUTH SECTION (remove entire block for public functions) ===
const authHeader = req.headers.get('Authorization');
if (!authHeader?.startsWith('Bearer ')) {
return new Response(JSON.stringify({ error: 'Unauthorized - Bearer token required' }), {
status: 401, headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
const adminSecret = authHeader.replace('Bearer ', '').trim();
if (adminSecret !== Deno.env.get('ADMIN_SECRET_KEY')) {
return new Response(JSON.stringify({ error: 'Invalid admin credentials' }), {
status: 401, headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
// === END ADMIN AUTH ===
// Database clients (choose based on function needs)
const supabaseAdmin = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')! // For writes/admin operations
);
const supabaseClient = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_ANON_KEY')! // For reads (respects RLS)
);
// Request parsing (adjust for GET vs POST)
const requestData = await req.json(); // POST functions
// const url = new URL(req.url); const param = url.searchParams.get('id'); // GET functions
// Input validation (always validate)
const { requiredField } = requestData;
if (!requiredField) {
return new Response(JSON.stringify({ error: 'Missing required field: requiredField' }), {
status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
// === 🔴 CRITICAL: Environment-Aware URL Generation (MANDATORY for functions creating public URLs) ===
// This pattern prevents the exact production failure where hardcoded local URLs break in production.
// Use this when uploading files to storage and need to return their public URLs.
const isProduction = Deno.env.get('SUPABASE_URL')?.includes('yevyfxmmijukjohbdjwv');
const baseUrl = isProduction
? 'https://yevyfxmmijukjohbdjwv.supabase.co'
: 'http://127.0.0.1:54321';
// Example usage: const publicUrl = `${baseUrl}/storage/v1/object/public/my-bucket/${imagePath}`;
// === END CRITICAL URL GENERATION ===
// === IMAGEN 3 PATTERN (production-optimized, uncomment if generating images) ===
/*
const gcpApiKey = Deno.env.get('GCP_API_KEY');
if (!gcpApiKey) throw new Error("GCP_API_KEY is not set");
const ai = new GoogleGenAI({ apiKey: gcpApiKey });
const response = await ai.models.generateImages({
model: 'imagen-3.0-generate-002',
prompt: `Character illustration: ${description}. Fantasy art style.`,
config: {
numberOfImages: 1,
aspectRatio: "1:1",
// 🔴 CRITICAL: Production file size optimization (prevents upload limit errors)
outputMimeType: "image/jpeg", // JPEG format for smaller file size
outputCompressionQuality: 60, // 60% compression for optimal size/quality
personGeneration: "ALLOW_ALL", // Allow generation of people of all ages
enhancePrompt: true, // Use prompt rewriting logic for better results
}
});
// Safety filter handling
if (response.raiFilteredReason) {
throw new Error(`Image generation blocked: ${response.raiFilteredReason}`);
}
// Image processing with size monitoring
const imageBytes = response.generatedImages[0].image.imageBytes;
const imageSizeMB = (imageBytes.length / 1024 / 1024).toFixed(2);
console.log(`Generated JPEG image: ${imageSizeMB} MB`);
const imageBuffer = Buffer.from(imageBytes, "base64");
const imagePath = `public/${crypto.randomUUID()}.jpg`; // JPEG extension
// Storage upload
const { error: uploadError } = await supabaseAdmin.storage
.from('card-images')
.upload(imagePath, imageBuffer, {
contentType: 'image/jpeg', // JPEG content type
cacheControl: '3600'
});
if (uploadError) throw uploadError;
// Environment-aware public URL generation
const publicImageUrl = `${baseUrl}/storage/v1/object/public/card-images/${imagePath}`;
*/
// === END IMAGEN 3 PATTERN ===
// ===== BUSINESS LOGIC (replace this section) =====
// Database operation example
const { data, error } = await supabaseClient
.from('cards')
.select('*')
.eq('id', requiredField)
.single();
// Production error handling (never modify this pattern)
if (error) {
if (error.code === 'PGRST116' || error.message.includes('JSON object requested, multiple (or no) rows returned')) {
return new Response(JSON.stringify({ error: 'Resource not found' }), {
status: 404, headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
throw error; // Other errors become 500
}
// ===== END BUSINESS LOGIC =====
// Success response (standard format)
return new Response(JSON.stringify({
success: true,
data: data // Replace with your actual response data
}), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
} catch (error) {
console.error(`[${req.url}] Function error:`, error);
return new Response(JSON.stringify({
error: error.message || 'Internal server error'
}), {
status: 500,
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
});
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 195 lines · 0 tokens per session scan A d64a03732df1
supabase-function-starter is a cursor rule published in the GitHub repository pridiuksson/orchestration-patterns-for-llms (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,848 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.