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/brendadeeznuts1111/betting-brain-v3/database-patternsgit clone --depth 1 https://github.com/brendadeeznuts1111/betting-brain-v3Wrote 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/brendadeeznuts1111/betting-brain-v3/database-patterns)<a href="https://agentmods.dev/rules/brendadeeznuts1111/betting-brain-v3/database-patterns"><img src="https://agentmods.dev/badge/rules/brendadeeznuts1111/betting-brain-v3/database-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 | $0.02036 | $0.02036 |
| Opus 5 | $0.01018 | $0.01018 |
| Sonnet 5 | $0.00407 | $0.00407 |
| Haiku 4.5 | $0.00204 | $0.00204 |
Grade A, and why
database-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 5d 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 — 314 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Patterns
🔍 Code Searchability Patterns
Find database-patterns Issues with ast-grep
# Find env.$DB.prepare($QUERY)
# Find await stmt.bind($$$).all()
# Find await stmt.bind($$$).first()
# Find normalizeD1Result<$$$>($$$)
ast-grep --pattern 'env.$DB.prepare($QUERY)' src/
ast-grep --pattern 'await stmt.bind($$$).all()' src/
ast-grep --pattern 'await stmt.bind($$$).first()' src/
ast-grep --pattern 'normalizeD1Result<$$$>($$$)' src/
sg -p 'env.$DB.prepare($QUERY)' src/
sg -p 'await' src/
sg -p 'await' src/
sg -p 'normalizeD1Result<$$$>($$$)' src/
database-patterns Discovery Commands
sg search "env.ANALYTICS.prepare" src/
sg search "normalizeD1Result" src/
sg search ".bind(" src/
sg search ".all()" src/
Search Examples
# Find all database queries
sg search 'env.$DB.prepare($QUERY)' src/
# Find D1 result normalization
sg search 'await' src/
# Find parameterized queries
sg search 'await' src/
# Find query execution patterns
sg search 'normalizeD1Result<$$$>($$$)' src/
D1 Database Usage
Environment Bindings
Primary Databases:
ANALYTICS- Main betting analytics databaseRAW_FEED_DB- Raw feed database
Configuration: wrangler.toml
Query Patterns
Parameterized Queries (CRITICAL)
// ✅ CORRECT: Parameterized query
const result = await env.ANALYTICS.prepare(`
SELECT * FROM line_movements
WHERE eid = ? AND ts > ?
LIMIT ?
`).bind(eventID, timestamp, limit).all();
// ❌ WRONG: String interpolation (SQL injection risk)
const result = await env.ANALYTICS.prepare(`
SELECT * FROM line_movements
WHERE eid = '${eventID}' AND ts > '${timestamp}'
LIMIT ${limit}
`).all();
Type Safety
import { normalizeD1Result } from '../utils/request';
// Query with type conversion
const result = await env.ANALYTICS.prepare(`
SELECT eid, mt, ts, old_line, new_line
FROM line_movements
WHERE eid = ?
ORDER BY ts DESC
LIMIT ?
`).bind(eventID, limit).all();
// Normalize with proper typing
type Movement = {
eid: string;
mt: string;
ts: string;
old_line: number;
new_line: number;
};
const movements = normalizeD1Result<Movement>(result);
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.
- 5d ago First seen · 314 lines · 2,036 tokens per session scan A 6c2870855ffe
database-patterns is a cursor rule published in the GitHub repository brendadeeznuts1111/betting-brain-v3 (8 stars, last pushed 11mo ago), licensed MIT. It adds 2,036 tokens to every session, about $0.0102 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.
Other cursor rules, from other repositories
migrations
how to create and apply database migrations.
db-preview-env
PR-isolated DB preview environment capability + safety contract(不限工具、不限 topology).
database-access
資料庫存取模式(Supabase client/server 分工).
rls-policy
🔒 LOCKED — managed by clade Source: rules/modules/db-schema/supabase/rls-policy.md Edit at: $CLADEHOME Local edits will be reverted by the next sync. -->.
user-lifecycle
User lifecycle 規範(soft-delete / suspend / hard-delete 的 FK 策略與 guard pattern).
query-optimization
查詢優化、EXPLAIN、index 設計與 RLS 效能測量.