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/lawofall/agentcore/databasegit clone --depth 1 https://github.com/Lawofall/AgentCoreWhat 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.00000 | $0.00609 |
| Opus 5 | $0.00000 | $0.00304 |
| Sonnet 5 | $0.00000 | $0.00122 |
| Haiku 4.5 | $0.00000 | $0.00061 |
Grade A, and why
database 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.
What it actually says
数据库 & ORM 规范
本规则是可执行约定(怎么写)。约定背后的设计理由(为何不用 ForeignKey、软删除架构选型、JSONB 索引策略、ORM 为何是 schema 真相源)见
docs/02-架构/核心接口定义.md§6.2,勿在此重复展开。
SQLAlchemy 模型
- 使用 SQLAlchemy 2.0
Mapped+mapped_column声明式 - 所有表主键:
PG_UUID(as_uuid=False),应用层str(uuid4())生成 - 默认值必须用
server_default(seed 脚本和裸 SQL 不触发 Python 级 default) - 枚举字段用
CheckConstraint固化合法值 - 不使用 ForeignKey(应用层维护引用完整性),外键字段加
index=True - JSONB 字段同时设
default=dict/list和server_default=text("'{}'::jsonb") - JSONB 值与 UUID 列比较时用
cast(..., PG_UUID(as_uuid=False)) - 软删除:设置
deleted_at而非物理删除 - ORM 是 schema 单一真相源:
alembic check必须零漂移
标准字段
| 字段 | 类型 | 要求 |
|---|---|---|
id |
PG_UUID(as_uuid=False) |
主键 |
created_at |
DateTime(timezone=True) |
server_default=func.now() |
updated_at |
DateTime(timezone=True) |
server_default=func.now(), onupdate=func.now() |
deleted_at |
DateTime(timezone=True), nullable |
软删除标记 |
status |
String(20) |
配 CheckConstraint |
Repository 层
- 只做数据访问,不含业务判断
- 查询用
select()构建式,不用 raw SQL - 分页返回
tuple[list[Model], int](数据 + 总数) - 默认按
created_at.desc()排序 commit()和refresh()由 repository 负责
Alembic 迁移
- schema 与数据严格分离:结构走迁移,初始数据走 seed 脚本
upgrade()和downgrade()必须成对实现- 复杂数据迁移用
op.execute()
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 · 50 lines · 0 tokens per session scan A 0257cacdcacf
database is a cursor rule published in the GitHub repository Lawofall/AgentCore (78 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 609 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-08-30.
Other cursor rules, from other repositories
code-patterns
Python code style and recurring patterns (config, logging, errors, paths).
project-overview
Core project architecture, patterns, and conventions for the AI Documentation Generator.
cursorrules
You are an AI agent building the module: {{MODULENAME}} This module is part of the Mnemosyne Neural OS ecosystem by XPACEGEMS LLC.
backend-python
Python and FastAPI standards for the backend.
core-project-context
Canonical project context and ownership rules.
dashboard-typescript
React and TypeScript standards for the operator dashboard.