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/modelengine-group/nexent/database_layer_rulesgit clone --depth 1 https://github.com/ModelEngine-Group/nexentWhat 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.00973 |
| Opus 5 | $0.00000 | $0.00487 |
| Sonnet 5 | $0.00000 | $0.00195 |
| Haiku 4.5 | $0.00000 | $0.00097 |
Grade A, and why
database_layer_rules 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 — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Layer Standards
Scope: all Python under backend/database/**/*.py. Concise standards for models, CRUD, transactions, and exceptions.
- Models: define in backend/database/db_models.py.
- Sessions: use
get_db_session()from backend/database/client.py. - Exceptions: share a DB exception type in backend/consts/exceptions.py.
- SQLAlchemy Core: prefer
insert/update/selectwithsession.execute()/session.scalars(); ORMsession.add()is allowed but not default.
1) Models and audit fields
- Inherit all models from
TableBase. - Shared fields:
create_time,update_time,created_by,updated_by,delete_flag(Y/N). - Never re-declare shared fields; add only table-specific columns.
2) CRUD and audit
- Create: set
created_by,updated_by, defaultdelete_flag='N'; timestamps are server-managed. - Update: set
updated_by; do not changecreate_time/created_by. - Delete: soft-delete only (
delete_flag='Y', setupdated_by). Cascade by soft-deleting children in same transaction when needed. - Read: exclude soft-deleted rows by default (
delete_flag='N').
3) Transactions and sessions
- Always use
with get_db_session() as session:. - Never call
commit(),rollback(), orclose()in DB-layer code. - The context manager centrally handles commit/rollback/close.
4) Exceptions
- Do not catch DB exceptions in
backend/database/**; let them propagate. - Central handling occurs in
get_db_session(). - Services that must proceed non-blockingly may catch a shared type (e.g.,
DatabaseOperationError).
5) Exception flow (inside get_db_session)
- On exception:
rollback→ re-raise →close→ propagate to callers.
6) Reference patterns (Core; no explicit commit/rollback)
from sqlalchemy import insert, update, select
from database.client import get_db_session, as_dict
def create_entity(data: dict):
with get_db_session() as session:
return session.execute(
insert(SomeModel).values(**data).returning(SomeModel.id)
).scalar_one()
def update_entity(entity_id: int, updates: dict, actor: str):
with get_db_session() as session:
session.execute(
update(SomeModel)
.where(SomeModel.id == entity_id, SomeModel.delete_flag == 'N')
.values(**updates, updated_by=actor)
)
def soft_delete_entity(entity_id: int, actor: str):
with get_db_session() as session:
session.execute(
update(SomeModel)
.where(SomeModel.id == entity_id, SomeModel.delete_flag == 'N')
.values(delete_flag='Y', updated_by=actor)
)
def read_active_entity(entity_id: int):
with get_db_session() as session:
record = session.scalars(
select(SomeModel).where(
SomeModel.id == entity_id,
SomeModel.delete_flag == 'N',
)
).first()
return None if record is None else as_dict(record)
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 · 92 lines · 0 tokens per session scan A dfd062607f6b
database_layer_rules is a cursor rule published in the GitHub repository ModelEngine-Group/nexent (5,841 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 973 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
latest-ai-models
Use only the latest AI models from all providers (updated Feb 2026).
callback-system
Lifecycle callback system design for agentic loops.
react-loop
ReAct loop implementation design and pattern details.
laravel-ai-sdk-integration
How Laragentic integrates with and extends the Laravel AI SDK.
developer-experience
Developer experience principles and usage patterns for Laragentic.
package-structure
Directory structure and file organization conventions for the Laragentic package.