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/bybren-llc/a-safe-pulse/12-database-sqlgit clone --depth 1 https://github.com/bybren-llc/a-safe-pulseWrote 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/bybren-llc/a-safe-pulse/12-database-sql)<a href="https://agentmods.dev/rules/bybren-llc/a-safe-pulse/12-database-sql"><img src="https://agentmods.dev/badge/rules/bybren-llc/a-safe-pulse/12-database-sql.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.00000 | $0.00651 |
| Opus 5 | $0.00000 | $0.00326 |
| Sonnet 5 | $0.00000 | $0.00130 |
| Haiku 4.5 | $0.00000 | $0.00065 |
Grade A, and why
12-database-sql 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 yesterday.
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 — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database and SQL Rules
These rules apply when working on database schemas, queries, and migrations.
Technology
- Database: PostgreSQL (production), SQLite (development)
- ORM: None -- direct
pgqueries - Migrations: Raw SQL files in
src/db/migrations/ - RLS: Row Level Security (MANDATORY for target architecture)
Row Level Security (RLS)
CRITICAL: RLS is mandatory for ALL tables containing user data.
RLS Context Helpers
Every database operation MUST use the appropriate context helper:
| Helper | Use Case |
|---|---|
withUserContext |
User-scoped operations |
withAdminContext |
Admin-scoped operations |
withSystemContext |
Background/webhook operations |
Zero Tolerance
- No direct query calls without RLS context wrappers
- No bypassing RLS policies for convenience
- No using superuser credentials in application code
RLS Validation
After any schema change, validate RLS:
- User isolation: User A cannot see User B's data
- Admin access: Admin can see data within policy scope
- System context: Background tasks use system context
Migration Workflow
# 1. Create a new migration file
# Use the next sequential number: XXX_description.sql
touch src/db/migrations/008_add_new_table.sql
# 2. Write the migration SQL (CREATE TABLE, ALTER TABLE, etc.)
# 3. Add RLS policies if new table contains user data
# 4. Register the migration in src/db/migrations/index.ts
# 5. Test locally
npm run dev
# 6. Commit
git add src/db/migrations/
git commit -m "feat(db): description [ASP-XXX]"
Migration Rules
- Never use
DROP TABLEwithout a backup strategy - Never apply manual DDL in production outside of migrations
- Always add proper indexes for query patterns
- Add RLS policies for every new table with user data
- Schema changes REQUIRE System Architect approval
- Follow naming convention:
XXX_description.sql(e.g.,008_add_audit_log.sql)
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.
- yesterday First seen · 85 lines · 0 tokens per session scan A b9e06e952ca4
12-database-sql is a cursor rule published in the GitHub repository bybren-llc/a-safe-pulse (9 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 651 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-09-04.
Other cursor rules, from other repositories
adapter-features
Database-specific features must be implemented in the specialized adapter only. Base adapters (postgres, mysql, etc.) must remain database-agnostic.
unit-tests-tdd
TDD required for behavior changes; ≥80% package coverage on touched packages; unit-test conventions.
integration-tests
Human-readable integration test requests; helpers vs httptest; suites/ vs per-DB placement.
postgresql
PostgreSQL production rules. Safe migrations, parameterized queries, TIMESTAMPTZ, proper indexing strategy.
postgresql
This guide defines the definitive best practices for writing clean, performant, and maintainable PostgreSQL SQL, focusing on modern conventions and avoiding common pitfalls.
database-access
資料庫存取模式(Supabase client/server 分工).