agentleFS
huialihuiali/rust-skills/skills/rust-database/SKILL.md

rust-database

Skill47 starsChanged 10 months agoMITView on GitHub

How do we guarantee data correctness while keeping queries and migrations operationally safe?

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep repository/data-access layer separate from business logic.

    line 13
  2. Distinctive:

    Do not perform network calls inside transactions.

    line 23
  3. Distinctive:

    Use indexes based on real access patterns.

    line 28
  4. Distinctive:

    Prefer additive migrations for rolling deployments.

    line 34
  5. Distinctive:

    Verify backward/forward compatibility windows.

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: rust-database description: "Rust database skill for SQLx/Diesel/SeaORM design, transaction boundaries, migration safety, query performance, and operational reliability."---

Rust Database Skill

Core Question

How do we guarantee data correctness while keeping queries and migrations operationally safe?

Persistence Architecture

- Keep repository/data-access layer separate from business logic. - Define explicit transaction boundaries around business invariants. - Choose stack by need: - sqlx: explicit SQL and compile-time query checks. - diesel: typed query builder with strong schema coupling. - sea-orm: async ORM convenience with rapid CRUD iteration.

Transaction and Consistency Rules

- Keep transactions short. - Do not perform network calls inside transactions. - Handle deadlock/serialization retries with bounded policy.

Query Performance

- Use indexes based on real access patterns. - Detect and remove N+1 query behavior. - Inspect query plans for slow paths.

Migration Safety

- Prefer additive migrations for rolling deployments. - Separate destructive changes into phased rollouts. - Verify backward/forward compatibility windows.

Common Pitfalls

- Long-lived transactions causing lock contention. - Schema changes incompatible with old app versions. - Inconsistent timezone/nullability handling across layers. - Pool exhaustion under burst traffic.

Review Checklist

- [ ] Transaction boundaries align with domain invariants. - [ ] Retry/timeout policy is explicit for DB operations. - [ ] Migrations are safe for rolling deploy. - [ ] Query plans and indexes are validated. - [ ] Metrics cover pool usage, latency, and error rates.

Verification Commands

cargo check
cargo test
cargo clippy
cargo sqlx prepare
cargo sqlx migrate run

Related Skills

- rust-web - rust-cache - rust-observability

Localized Reference

- Original Chinese version is preserved in SKILL_ZH.md.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.