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 skills add loulanyue/awesome-claude-notes --skill postgres-patternsgit clone --depth 1 https://github.com/loulanyue/awesome-claude-notesWrote 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/skills/loulanyue/awesome-claude-notes/postgres-patterns)<a href="https://agentmods.dev/skills/loulanyue/awesome-claude-notes/postgres-patterns"><img src="https://agentmods.dev/badge/skills/loulanyue/awesome-claude-notes/postgres-patterns.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.1 | $0.00028 | $0.01319 |
| Opus 5 | $0.00014 | $0.00660 |
| Sonnet 5 | $0.00006 | $0.00264 |
| Haiku 4.5 | $0.00003 | $0.00132 |
Grade A, and why
postgres-patterns 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.
Copies of this mod
1 near-identical copy found in the catalogue:
- postgres-patterns — 88% identical, 107 lines differ
How it starts
The opening of the file, as written. The whole thing — 156 lines — stays where its author put it; the contents beside it link to each section on GitHub.
PostgreSQL パターン
PostgreSQLベストプラクティスのクイックリファレンス。詳細なガイダンスについては、database-reviewer エージェントを使用してください。
起動タイミング
- SQLクエリまたはマイグレーションの作成時
- データベーススキーマの設計時
- 低速クエリのトラブルシューティング時
- Row Level Securityの実装時
- コネクションプーリングの設定時
クイックリファレンス
インデックスチートシート
| クエリパターン | インデックスタイプ | 例 |
|---|---|---|
WHERE col = value |
B-tree(デフォルト) | CREATE INDEX idx ON t (col) |
WHERE col > value |
B-tree | CREATE INDEX idx ON t (col) |
WHERE a = x AND b > y |
複合 | CREATE INDEX idx ON t (a, b) |
WHERE jsonb @> '{}' |
GIN | CREATE INDEX idx ON t USING gin (col) |
WHERE tsv @@ query |
GIN | CREATE INDEX idx ON t USING gin (col) |
| 時系列範囲 | BRIN | CREATE INDEX idx ON t USING brin (col) |
データタイプクイックリファレンス
| 用途 | 正しいタイプ | 避けるべき |
|---|---|---|
| ID | bigint |
int、ランダムUUID |
| 文字列 | text |
varchar(255) |
| タイムスタンプ | timestamptz |
timestamp |
| 金額 | numeric(10,2) |
float |
| フラグ | boolean |
varchar、int |
一般的なパターン
複合インデックスの順序:
-- 等価列を最初に、次に範囲列
CREATE INDEX idx ON orders (status, created_at);
-- 次の場合に機能: WHERE status = 'pending' AND created_at > '2024-01-01'
カバリングインデックス:
CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
-- SELECT email, name, created_at のテーブル検索を回避
部分インデックス:
CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
-- より小さなインデックス、アクティブユーザーのみを含む
RLSポリシー(最適化):
CREATE POLICY policy ON orders
USING ((SELECT auth.uid()) = user_id); -- SELECTでラップ!
UPSERT:
INSERT INTO settings (user_id, key, value)
VALUES (123, 'theme', 'dark')
ON CONFLICT (user_id, key)
DO UPDATE SET value = EXCLUDED.value;
カーソルページネーション:
SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
-- O(1) vs OFFSET は O(n)
キュー処理:
UPDATE jobs SET status = 'processing'
WHERE id = (
SELECT id FROM jobs WHERE status = 'pending'
ORDER BY created_at LIMIT 1
FOR UPDATE SKIP LOCKED
) RETURNING *;
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.
- 2d ago First seen · 156 lines · 28 tokens per session scan A df2d82453421
postgres-patterns is a skill published in the GitHub repository loulanyue/awesome-claude-notes (270 stars, last pushed 3d ago), licensed MIT. It adds 28 tokens to every session and 1,319 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-09-03.
Other skills, from other repositories
database-expert
Advanced database design and administration for PostgreSQL, MongoDB, and Redis. Use when designing schemas, optimizing queries, managing database performance, or implementing data patterns.
google-analytics
Skill "google-analytics" from VKirill/claude-lane-stack, covering version requirements (may 2026), usage, use this skill when, do not use this skill when and purpose.
agent-database-reviewer
PostgreSQL database specialist for query optimization, schema design, security, and performance. Use PROACTIVELY when writing SQL, creating migrations, designing schemas, or troubleshooting database performance. Incorporates Supabase best practices.
postgresql
Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features.
postgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
postgres-database-migration
Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…