cli-forge-data
Skill0 starsChanged 3 months agoMITView on GitHub
Design and implement safe PostgreSQL database changes for Rust/SQLx applications. Use for new schemas, migrations, constraints, indexes, repositories, transaction boundaries, state machines, idempotency, concurrency control, queues, multi-tenancy, soft deletion, ledgers, outbox/inbox, repair jobs, or corrections handed off by cli-audit-data.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- Destynova2/cli-code-skillsedited, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Destynova2/cli-code-skills★ 5100% same
Wrote their own version · 0
None found.
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 repository39 other files it gives its agents.
- .cursor/rules/cli-audit-code.mdcCursor rule
- .cursor/rules/cli-audit-doc.mdcCursor rule
- .cursor/rules/cli-forge-arch.mdcCursor rule
- .cursor/rules/cli-forge-schema.mdcCursor rule
- cli-audit-codeSkill
- cli-audit-dataSkill
- cli-audit-docSkill
- cli-audit-driftSkill
- cli-audit-hanoiSkill
- cli-audit-reviewSkill
- cli-audit-shellSkill
- cli-audit-syncSkill
- cli-audit-tangleSkill
- cli-audit-testSkill
- cli-audit-wizardSkill
- cli-audit-xraySkill
- cli-cycleSkill
- cli-forge-archSkill
- cli-forge-chefSkill
- cli-forge-choice-uxSkill
- cli-forge-demoSkill
- cli-forge-docSkill
- cli-forge-githubSkill
- cli-forge-hldSkill
- cli-forge-infraSkill
- cli-forge-lldSkill
- cli-forge-oci-rootlessSkill
- cli-forge-perfSkill
- cli-forge-pipelineSkill
- cli-forge-plumeSkill
- cli-forge-prezSkill
- cli-forge-profileSkill
- cli-forge-quorumSkill
- cli-forge-readmeSkill
- cli-forge-resilienceSkill
- cli-forge-schemaSkill
- cli-forge-treeSkill
- cli-git-conventionalSkill
- cli-watermarkSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 12 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Read ../shared/data-invariants.md before acting.
- Very specific: line 33
Read ../shared/data-invariant-catalog.md when discovering domain rules, and ../shared/postgres-sqlx-patterns.md before writing non-trivial …
- Distinctive: line 44
Do not implement in design-only mode.
- Distinctive: line 51
Put every write belonging to one business decision in one explicit transaction.
- Distinctive: line 52
Never perform network I/O while a PostgreSQL transaction is open.
- Distinctive: line 53
Treat zero affected rows as a business result when the command is conditional.
- Distinctive: line 56
Use a transactional outbox/inbox protocol for cross-system effects.
- Distinctive: line 58
Never edit an already-applied migration silently.
- Distinctive: line 61
Never use SQLite or mocks as proof of PostgreSQL concurrency behavior.
- Distinctive: line 62
Never claim cross-system exactly-once behavior without a demonstrated protocol.
- Distinctive: line 94
Do not accept an invariant enforced only by Rust validation when PostgreSQL can protect it.
- Distinctive: line 98
Write concrete A/B interleavings for every read-before-write flow.
- Very specific: line 112
Use named NOT NULL, CHECK, UNIQUE, partial unique indexes, foreign keys, composite tenant keys, exclusion constraints, conditional DML, or …
- Very specific: line 121
Prefer compile-time checked query!, query_as!, query_scalar!, and query_file!
- Distinctive: line 126
Place the transaction boundary at the business use case and pass the same transaction or connection through participating functions.
- Very specific: line 128
Verify the exact SQLx Executor/Transaction API against the project's pinned version.
- Very specific: line 154
Use the database T0-T4/M0 mapping in ../shared/data-invariants.md.
- Very specific: line 175
Run /cli-audit-data after implementation for L1+ changes or whenever this skill was triggered by a database-safety finding.
- Distinctive: line 193
every runtime-dependent claim as:
- Very specific: line 199
When running under cli-cycle, emit .agents/cli-forge-data.json using ../shared/result-schema.md.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Optimization: Load the shared invariant contract first, then only the PostgreSQL/SQLx references needed by the requested change.
Language rule: Write user-facing decisions and reports in the project's dominant language. Keep SQL, Rust identifiers, SQLSTATE values, and the mandatory uncertainty marker unchanged.
Forge Data — Safe PostgreSQL and SQLx Changes
Design or implement database changes whose safety comes from explicit invariants, PostgreSQL guarantees, short atomic operations, compatible evolution, and reproducible proof.
Read ../shared/data-invariants.md before acting. Read ../gotchas.md before producing output.
Read ../shared/data-invariant-catalog.md when discovering domain rules, and
../shared/postgres-sqlx-patterns.md before writing non-trivial SQL.
Modes
| Mode | Trigger | Behavior |
| Design | User asks for schema, transaction, migration, or data architecture | Produce a database decision and proof plan before code |
| Implementation | User asks to build/fix the change or accepts a design | Edit migrations/Rust/tests, then execute the relevant gates |
| Correction | cli-audit-data finding is supplied | Preserve the finding's invariant and close the smallest unsafe gap |
Do not implement in design-only mode. In implementation or correction mode, inspect the existing schema and code before editing; never infer the database solely from Rust structs.
Non-negotiable rules
- Give every business fact one authoritative owner.
- Protect persistent invariants in PostgreSQL whenever a declarative guarantee exists.
- Put every write belonging to one business decision in one explicit transaction.
- Never perform network I/O while a PostgreSQL transaction is open.
- Treat zero affected rows as a business result when the command is conditional.
- Give every retryable command an explicit idempotency protocol.
- Retry a whole failed transaction, never one middle statement.
- Use a transactional outbox/inbox protocol for cross-system effects.
- Design migrations for old code, new code, and mixed-version deployment.
- Never edit an already-applied migration silently.
- Include tenant scope in database keys and references, not only query filters.
- Make derived facts reconstructible or provide auditable detection and repair.
- Never use SQLite or mocks as proof of PostgreSQL concurrency behavior.
- Never claim cross-system exactly-once behavior without a demonstrated protocol.
Workflow
1. Inspect existing truth
Inspect relevant migrations, tables, types, constraints, indexes, triggers, functions, views, RLS, extensions, SQLx queries, transaction boundaries, background jobs, messages, external effects, versions, migration runner, deployment order, and incident history.
Proceed with explicit assumptions when information is missing. Stop before destructive or irreversible work whose semantics cannot be safely inferred.
2. Classify scope and criticality
Choose S/M/L/XL from ../shared/tiering.md for output depth and L0-L3 from
../shared/data-invariants.md for proof depth. State both. Bias scope down and criticality up when
uncertain.
3. Write the decision and invariants
Complete the database decision, source-of-truth map, invariant matrix, conservation laws, and state
transition tables defined in ../shared/data-invariants.md.
For each invariant choose:
- a primary PostgreSQL guarantee;
- defense in depth where useful;
- an audit query and threshold;
- a repair or reconstruction path;
- an executable proof.
Do not accept an invariant enforced only by Rust validation when PostgreSQL can protect it.
4. Break concurrent and failure cases
Write concrete A/B interleavings for every read-before-write flow. Cover duplicate requests, stale writes, lost responses, crash boundaries, retries, old/new binaries, wrong tenant, cancellation, and deadlock or serialization failure.
Prefer, in order:
- declarative constraint plus atomic DML;
INSERT ... ON CONFLICTor conditionalUPDATE ... RETURNING;- targeted row locking in a short transaction;
SERIALIZABLEwith bounded whole-transaction retry;- advisory locking only with a stable key and shared documented protocol.
5. Select PostgreSQL guarantees
Use named NOT NULL, CHECK, UNIQUE, partial unique indexes, foreign keys, composite tenant
keys, exclusion constraints, conditional DML, or outbox/inbox as appropriate.
Choose every ON DELETE and ON UPDATE action. Do not claim a row CHECK protects a multi-row
invariant. Justify indexes from real access paths and representative volumes. Use triggers only
when their central guarantee outweighs hidden complexity and they are observable and tested.
6. Implement with SQLx
Prefer compile-time checked query!, query_as!, query_scalar!, and query_file! variants.
Require explicit columns, bound values, allowlisted dynamic identifiers, justified nullability,
RETURNING where it removes a second read, zero-row handling, and error mapping by SQLSTATE and
named constraint.
Place the transaction boundary at the business use case and pass the same transaction or
connection through participating functions. Do not reacquire from the pool inside the use case.
Verify the exact SQLx Executor/Transaction API against the project's pinned version.
7. Evolve the schema compatibly
Classify the migration as additive, compatible transformation, backfill, destructive, locking, rewriting, extension-dependent, or version-incompatible.
For non-trivial changes use:
EXPAND -> MIGRATE -> SWITCH -> CONTRACTProve old/old, old/new, new/old, new/new, and old+new/new combinations where deployment overlap exists. Analyze locks, rewrite, disk, replication lag, pool impact, batch size, resumability, interruption recovery, and runner transaction behavior. Contract only after telemetry proves old representations and binaries are gone.
8. Build homeostasis
For critical invariants define audit query, frequency, metric, threshold, owner, dry-run repair, audited repair, and replay path. For eventual consistency define nominal and maximum lag, user-visible degraded behavior, retry limit, failed-item storage, and escalation.
9. Implement the proof ladder
Use the database T0-T4/M0 mapping in ../shared/data-invariants.md.
At minimum run the commands supported by the project version:
cargo fmt --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo sqlx prepare --workspace --check
cargo test --workspaceFor L2+, use synchronized transactions against real PostgreSQL. For L3, add property-based or state-model proof, crash-boundary simulation, full replay, and repair testing. Never report a command as successful unless it ran.
10. Pass the done gate
Apply ../shared/done-gate.md: confirm the decision and baseline before editing, keep the change
reversible during implementation, and capture reproducible post-verification. Apply
../shared/determinism.md to fixtures, IDs, clocks, retry schedules, and migration data.
Run /cli-audit-data after implementation for L1+ changes or whenever this skill was triggered by
a database-safety finding.
Mandatory output
End with:
- scope tier and data criticality;
- database decision;
- sources of truth and invariant matrix;
- conservation laws and state machine;
- concurrency and idempotency analysis;
- PostgreSQL guarantees;
- SQLx implementation notes;
- migration compatibility matrix;
- proof executed and not executed;
- homeostasis and repair;
- residual risks and rollback/forward-repair path;
- every runtime-dependent claim as:
À PROUVER SUR POSTGRESQL RÉEL — ...When running under cli-cycle, emit .agents/cli-forge-data.json using
../shared/result-schema.md.
Dynamic handoffs
| Condition detected | Recommend | Why |
| Implementation or migration is ready for an independent safety gate | /cli-audit-data | Verify invariants and dangerous interleavings |
| Contract intent is missing or disagrees with code | /cli-audit-drift | Establish semantic ownership |
| Component architecture or API boundary is unresolved | /cli-forge-lld | Anchor the database design in the component design |
| Backup, restore, failover, or incident response is incomplete | /cli-forge-resilience | Build operational proof |
| Query/index/locking performance is uncertain | /cli-forge-perf | Measure rather than speculate |
| A state machine or data flow needs visualization | /cli-forge-schema | Generate the appropriate Mermaid diagram |
Rule: recommend handoffs; do not execute them automatically outside cli-cycle.
Completion criterion
The change is complete only when its laws are explicit, PostgreSQL protects them as far as possible, concurrent and failure executions have concrete answers, old and new versions can coexist safely, proof is reproducible, and remaining drift is observable and repairable.
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.

