database-patterns
Skill3 starsChanged 4 days agoApache-2.0View on GitHub
SOVA database conventions (async SQLAlchemy 2.0, ORM models, session management, migrations, JSON column gotchas). Auto-activates when working on sova/db/ models, session code, or Alembic migrations.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- jokob-sk/NetAlertXtheir own version, first seen Nov 1, 2026
- netalertx/NetAlertXtheir own version, first seen Nov 1, 2026
- mikulgohil/claude-skillstheir own version, first seen Oct 13, 2026
- Nadav011/apex-skillstheir own version, first seen Apr 22, 2026
- zebbern/termstacktheir own version, first seen Apr 16, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- jokob-sk/NetAlertX★ 7.4ksame name
- netalertx/NetAlertX★ 7.4ksame name
- zebbern/termstack★ 4same name
- mikulgohil/claude-skills★ 0same name
- Nadav011/apex-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- templates/CLAUDE.mdCLAUDE.md
- dashboard-designSkill
- database-patternsSkill
- design-systemSkill
- design-tasteSkill
- issue-templateSkill
- sova-address-prSkill
- sova-after-mergeSkill
- sova-agent-readinessSkill
- sova-audit-instructionsSkill
- sova-debugSkill
- sova-develop-explainSkill
- sova-develop-fullSkill
- sova-developSkill
- sova-extract-knowledgeSkill
- sova-find-taskSkill
- sova-health-auditSkill
- sova-ingest-reviewSkill
- sova-integrate-prSkill
- sova-issueSkill
- sova-new-featureSkill
- sova-optimize-knowledgeSkill
- sova-prSkill
- sova-rearrange-commitsSkill
- sova-researchSkill
- sova-review-fullSkill
- sova-review-prSkill
- sova-reviewSkill
- sova-simplifySkill
- sova-specSkill
- sova-standupSkill
- sova-statusSkill
- sova-testSkill
- sova-update-docsSkill
- testing-patternsSkill
- visual-auditSkill
- dashboard-designSkill
- design-tasteSkill
- issue-templateSkill
- testing-patternsSkill
- visual-auditSkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 1 is distinctive, and 6 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
When working on sova/db/, ORM models, or migrations, follow these conventions.
- Distinctive: line 13
Always use the async context manager:
- Very specific: line 18
Never acquire sessions without async with: it leaks on exception.
- Very specific: line 33
Use if not handoff: to catch both None and {}
- Very specific: line 43
Use TASK_RUN_TERMINAL for DB queries.
- Very specific: line 51
Always use batch_alter_table (SQLite requires it)
- Very specific: line 52
Use idempotent helpers: _column_exists(), _table_exists(), _index_exists()
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SOVA Database Patterns
When working on sova/db/, ORM models, or migrations, follow these conventions. Reference: docs/database-guidelines.md.
Session Management
Always use the async context manager:
async with await get_session() as session:
result = await session.execute(select(TaskRun))Never acquire sessions without async with: it leaks on exception. All factories use expire_on_commit=False.
ORM Model Conventions (sova/db/models.py)
- Type-annotated columns:
Mapped[str]withmapped_column(String(50)) - Money:
Numeric(10, 6)withDecimal("0")default - Timestamps:
DateTime(timezone=True)withlambda: datetime.now(timezone.utc) - FK constants:
_FK_TASK_RUNS_ID = "task_runs.id" - Indexes in
__table_args__:Index("ix_{table}_{column}", "column") - Input normalization:
@validatesdecorator (e.g., strip#from issue numbers)
JSON Column NULL Gotcha
SQLAlchemy JSON defaults to none_as_null=False. Python None becomes JSON "null", not SQL NULL.
TaskRun.handoff_json.isnot(None)only catches SQL NULLs- Use
if not handoff:to catch bothNoneand{}
Terminal Status Sets
_TERMINAL = frozenset({TaskStatus.DONE, TaskStatus.FAILED, TaskStatus.REJECTED}) # state machine
TASK_RUN_TERMINAL = frozenset(
{"done", "failed", "rejected", "interrupted", "paused", "awaiting_approval"}
) # DB queries, sova/core/state.pyUse TASK_RUN_TERMINAL for DB queries. Always guard finalization:
if task_run.status in TASK_RUN_TERMINAL:
return # don't overwrite, but still update costMigrations
- Always use
batch_alter_table(SQLite requires it) - Use idempotent helpers:
_column_exists(),_table_exists(),_index_exists() - Sequential numbering (currently up to
034), not Alembic UUIDs - Engine disposal after migration for file-backed SQLite (stale schema cache)
- Self-healing: if Alembic fails, drops corrupted
alembic_version, runscreate_all+ stamps head
Multi-Project
get_session(project_dir=...) routes to per-project engine. Each project gets its own .claude/sova.db.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

