rpc

A guide for accessing Supabase data through database functions called RPCs, which are named operations the application can call. It requires data access, CRUD actions, search, filtering, pagination, and business logic to use functions in the exposed api schema rather than direct table queries.

In plain words
What is it for?
Creating or debugging database functions and implementing record creation, reading, updating, deletion, pagination, searches, filters, batch operations, and other data access.
Why use it?
It prevents code from using database access patterns that this project does not expose and sets a consistent place for validation and data rules.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/tomaspozo/agentlink/rpc
Any agent
npx skills add tomaspozo/agentlink --skill rpc
Clone the repo
git clone --depth 1 https://github.com/tomaspozo/agentlink

Made for: Claude Code, Codex.

Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,877 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00089 $0.03877
Opus 5 $0.00044 $0.01938
Sonnet 5 $0.00018 $0.00775
Haiku 4.5 $0.00009 $0.00388

Measured 2d ago against content hash c9e33ca79bfc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rpc 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 2d 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.

skills/rpc/SKILL.md · 275 lines

How it starts

The opening of the file, as written. The whole thing — 275 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RPC-First Data Access

Every data operation is a function in the api schema. No .from(). No direct table queries. No views. The api schema is the only schema exposed via the Supabase Data API — tables in public are invisible. This applies to all code: frontend components, edge functions, webhooks, cron jobs, server routes — no exceptions.

// ❌ WRONG — .from() cannot reach tables (public schema is not exposed)
const { data } = await supabase.from("charts").select("*");

// ❌ ALSO WRONG — even with service role key, .from() won't reach public tables
const admin = createClient(url, secretKey, { db: { schema: "public" } });
const { data } = await admin.from("charts").select("*");

// ✅ CORRECT
const { data } = await supabase.rpc("chart_get_by_user");

// ✅ CORRECT — within withSupabase context
const { data } = await ctx.supabase.rpc("chart_get_by_user");
const { data } = await ctx.supabaseAdmin.rpc("chart_admin_cleanup");

Function Anatomy

Every api schema function follows this structure:

CREATE OR REPLACE FUNCTION api.chart_get_by_id(p_chart_id uuid)
RETURNS jsonb
LANGUAGE plpgsql
SECURITY INVOKER
SET search_path = ''
AS $$
DECLARE
  v_result jsonb;
BEGIN
  SELECT jsonb_build_object(
    'id', c.id,
    'name', c.name,
    'created_at', c.created_at
  ) INTO v_result
  FROM public.charts c
  WHERE c.id = p_chart_id;

  IF v_result IS NULL THEN
    RAISE EXCEPTION 'Chart not found: %', p_chart_id;
  END IF;

  RETURN v_result;
END;
$$;

Key rules:

  • api. schema — all data access functions live here
  • SECURITY INVOKER — runs as the caller; isolation RLS applies automatically
  • Permission gate first — mutating RPCs PERFORM public.auth_verify_access('<entity>.<action>') as the first statement, then scope queries with WHERE tenant_id = (SELECT public._auth_tenant_id()). Permissions live in the RPC, not in RLS (which is isolation-only).
  • SET search_path = '' — prevents search path injection
  • Fully qualified namespublic.charts, public._auth_*, public._internal_admin_* — never bare names
  • Grant EXECUTE per function — every api RPC (default-deny, like tables; there is no schema-wide GRANT ON ALL FUNCTIONS). After the definition add REVOKE ALL ON FUNCTION api.<fn>(<arg-types>) FROM PUBLIC; then GRANT EXECUTE ON FUNCTION api.<fn>(<arg-types>) TO authenticated, service_role;. The REVOKE strips Postgres' built-in PUBLIC EXECUTE (so anon can't reach it); a forgotten grant fails fast (42501). Anon-callable RPC: GRANT … TO anon, authenticated, service_role and make it SECURITY DEFINER. api._admin_* (service_role-only): REVOKE … FROM PUBLIC, anon, authenticated; GRANT EXECUTE … TO service_role (also silences DEFINER lint 0028). See the Grants section in references/rpc_patterns.md.
  • p_ prefix on parameters, v_ prefix on local variables

Read the full file on GitHub · 275 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

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.

  1. 2d ago First seen · 275 lines · 89 tokens per session scan A c9e33ca79bfc

Subscribe to this mod's changes

rpc is a skill published in the GitHub repository tomaspozo/agentlink (6 stars, last pushed 1mo ago), licensed MIT. It adds 89 tokens to every session and 3,877 once invoked, about $0.0004 per session on Opus 5. 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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens