mini-taiwan-pulse: Command for Claude Code

.claude/commands/check-rpc.md

check-rpc is a command for Claude Code from ianlkl11234s/mini-taiwan-pulse. It costs 22 tokens per session (706 once invoked), scanned A, original, MIT.

A command for checking how a Supabase database function (RPC) runs, including its query plan and actual response time. It uses PostgreSQL's EXPLAIN ANALYZE to inspect the work the database performs.

In plain words
What is it for?
Use it to test a named Supabase RPC with an optional date or other test value, inspect its execution plan, count returned rows, and measure elapsed time. It also applies stated thresholds to suggest whether to leave the function alone, monitor it, or optimize it.
Why use it?
It helps identify slow database functions and whether they are processing more rows or doing costly operations than expected. This gives a basis for deciding whether to use pre-aggregation, which prepares summary data in advance.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: positional $N argument.

This is ianlkl11234s/mini-taiwan-pulse's own configuration. It tells Claude Code how to work on mini-taiwan-pulse itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mini-taiwan-pulse configures →

Reuse

Borrowing it

Nothing to install: this file belongs to ianlkl11234s/mini-taiwan-pulse. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/ianlkl11234s/mini-taiwan-pulse/master/.claude/commands/check-rpc.md
Clone the repo
git clone --depth 1 https://github.com/ianlkl11234s/mini-taiwan-pulse

Made for: Claude Code.

Wrote 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.

agentmods badge for check-rpc

README.md
[![agentmods](https://agentmods.dev/badge/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc/github.svg)](https://agentmods.dev/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc)
Your own site
<a href="https://agentmods.dev/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc"><img src="https://agentmods.dev/badge/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for check-rpc

Your own site · 80×15
<a href="https://agentmods.dev/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc"><img src="https://agentmods.dev/badge/commands/ianlkl11234s/mini-taiwan-pulse/check-rpc.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 706 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00022 $0.00706
Opus 5 $0.00011 $0.00353
Sonnet 5 $0.00004 $0.00141
Haiku 4.5 $0.00002 $0.00071

Measured 11d ago against content hash daea81368cc4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

check-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 11d 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.

.claude/commands/check-rpc.md · 57 lines

What it actually says

/check-rpc

檢查某個 Supabase RPC 的執行計畫與實際耗時,判斷是否需要套用 pre-aggregate pattern(詳見 docs/supabase-optimization.md)。

參數

  • $1 (必填): RPC 名稱,例如 get_ship_trails
  • $2 (選填): 測試參數(通常是日期),預設 CURRENT_DATE

執行步驟

  1. 讀取 SUPABASE_DB_URL(從 .env
  2. 找到 RPC 定義
    psql "$SUPABASE_DB_URL" -c "\sf public.$1"
    
  3. EXPLAIN ANALYZE(重點看 plan 結構):
    psql "$SUPABASE_DB_URL" -c "EXPLAIN (ANALYZE, BUFFERS, COSTS OFF) SELECT * FROM public.$1('${2:-CURRENT_DATE}');"
    
  4. 測實際 RPC 響應
    time psql "$SUPABASE_DB_URL" -c "SELECT count(*) FROM public.$1('${2:-CURRENT_DATE}');"
    

判斷準則

現況 建議
響應 < 500ms、rows < 5k ✅ 不需優化
響應 500ms ~ 1s、plan 穩定 🟡 監控即可,加進 audit 報告
響應 > 1s 或 rows > 10k 🔴 必須 套 pre-aggregate pattern
看到 Sort + 大量 rows 🔴 可能是 plan 問題,先跑 ANALYZE <source_table>
看到 Parallel Append + Sort global 🔴 planner 選錯 plan,試圖 force Merge Append + index
string_agg / ST_Union / 複雜 JOIN 🔴 一律套 pre-aggregate

套 pre-aggregate 的下一步

使用 skill supabase-optimize 產生 SQL 範本:

使用 supabase-optimize skill 為 $1 產生 pre-aggregate SQL

或手動參考 docs/supabase-optimization.md../data-collectors/docs/sql/matview_*.sql 範本。

注意事項

  • Supabase pooler 強制 2min statement_timeout,若 EXPLAIN ANALYZE 超時,代表現況已不可用,必須優化
  • anon role default timeout 3s,前端實際可用時間更短
  • 若 plan 有 stale stats 嫌疑,先 ANALYZE realtime.xxx_source_YYYYMMDD; 看是否改善
  • 大 payload RPC 記得加 SET statement_timeout TO '60s' function 屬性
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. 11d ago First seen · 57 lines · 22 tokens per session scan A daea81368cc4

Subscribe to this mod's changes

check-rpc is a command published in the GitHub repository ianlkl11234s/mini-taiwan-pulse (504 stars, last pushed today), licensed MIT. It adds 22 tokens to every session and 706 once invoked, about $0.0001 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-30.