Use when a code-review diff changes shared persistent state, locking, transactions, file publication, or Redis/cache read-modify-write paths and needs an evidence-based audit of atomicity, crash consistency, and lost updates.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Atomicity Audit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/pekral-atomicity-audit)
---
name: atomicity-audit
description: "Use when a code-review diff changes shared persistent state, locking, transactions, file publication, or Redis/cache read-modify-write paths and needs an evidence-based audit of atomicity, crash consistency, and lost updates."
license: MIT
metadata:
author: "Petr Král (pekral.cz)"
---
## Constraints
- Apply `@rules/code-review/general.md`, `@rules/security/general.md`, and `@rules/general/general.md` *Verified statements only*.
- Read the changed lines and only the callers, readers, writers, transaction boundaries, queue jobs, retries, and backend configuration needed to judge them. Do not inspect a live provider, read an environment value, mutate the project, or run a test.
- Report only a concrete invariant failure anchored to a changed line. A surrounding reader or writer may prove the finding but is not a finding of its own.
- Treat a documented atomic SQL/Redis primitive, verified transaction rollback, and rebuildable non-authoritative cache as the guarantee they prove. Do not replace them with a blanket lock or transaction recommendation.
## Mode: `MODE=cr`
This mode is read-only. It changes no project file, authors no test, stages, commits, or pushes nothing, and runs no fixer or checker. It scopes analysis to added or modified lines and returns Markdown findings only. A non-matching diff returns no finding.
## Use when
- A review changes a persistent file write or publish, lock, transaction boundary, Redis/cache mutation, or synchronous/asynchronous writer of shared state.
## Execution
1. Name the state and the invariant that must remain indivisible. Stop with no finding when the value is rebuildable cache or no invariant crosses the operation.
2. Trace the relevant readers and writers, including jobs, listeners, workers, retries, and concurrent requests. Record only paths the code proves.
3. Separate the required guarantee: mutual exclusion, all-or-old-or-new visibility, and crash durability. A lock, transaction, or atomic backend command proves only its documented guarantee.
4. Apply AT-1 through AT-7 in `references/checks.md`, including each check's negative cases.
5. Build one failure sequence: interleaving or stop point, observable inconsistent state, and impact on the named invariant. Without all three, write `Not verified` and name the local fixture or backend documentation check that settles it.
6. Propose the smallest fix that preserves the invariant and existing backend guarantee.
## Output
Fold each finding into the normal Critical / Moderate buckets. Include the standard review fields plus:
- **Impact:** `Atomicity risk:` followed by the invariant, failure sequence, and observable impact.
- **Evidence:** `logic-trace`, or `runtime-failure` only for an already-supplied local fixture result.
- **Faulty Example:** the bounded concurrent or crash sequence.
- **Expected behavior:** the all-or-old-or-new, rollback, or no-lost-update invariant.
- **Test hint:** the smallest local fixture that proves the sequence.
- **Suggested fix:** the narrowest durable or atomic operation the established backend supports.
## Done when
- Every in-scope changed state mutation has an identified invariant or explicit no-invariant/rebuildable-cache reason.
- Every finding states its guarantee class, failure sequence, impact, and minimal fix.
- No finding duplicates another review lens or asks for a blanket transaction or lock.
## References
- `references/checks.md` — AT-1 through AT-7 and their negative cases.