Reference
Prompts
Thirty-seven audit prompts for production systems — performance, concurrency, reliability, data integrity, scalability, and maintainability. Written to be handed to a code-reviewing agent as-is.
By Nathaniel Arfin · Published
Each prompt is scoped to one class of failure. Run them against a real codebase, not a description of one — the useful output is the specific file, line, and query that changes.
1. Performance & efficiency
1. Deep scan all hot paths and eliminate unnecessary sequential async calls. Parallelize independent operations with bounded concurrency.
2. Identify and eliminate N+1 database queries across the application. Use batching, joins, or prefetching where appropriate.
3. Audit database queries against indexes and execution plans. Fix expensive scans, redundant indexes, and inefficient query patterns.
4. Find repeated computation, redundant data fetching, and unnecessary serialization in critical paths. Eliminate wasted work.
5. Inspect all pagination implementations. Replace unbounded reads and expensive offset pagination where cursor-based access is appropriate.
6. Identify excessive network round trips between services. Consolidate operations without compromising isolation or correctness.
2. Concurrency & transactions
7. Audit all read-modify-write operations for race conditions and lost updates. Introduce atomic operations or appropriate concurrency controls.
8. Find multi-step database mutations that can leave partially committed state. Establish correct transactional boundaries.
9. Inspect transaction isolation assumptions. Identify and fix write skew, non-repeatable reads, and serialization anomalies where they threaten correctness.
10. Audit concurrent operations for shared mutable state, locking errors, and unsafe interleavings. Add targeted concurrency regression tests.
11. Find operations that depend on application-level uniqueness checks. Enforce critical invariants at the database level.
12. Examine external side effects performed inside transactions. Prevent duplicate effects and inconsistent commits using appropriate patterns.
3. Reliability & fault tolerance
13. Audit every retry mechanism. Ensure bounded exponential backoff, jitter, transient-error classification, and idempotent retry behaviour.
14. Trace timeout and cancellation handling across every service boundary. Eliminate requests that continue consuming resources after cancellation.
15. Identify unbounded queues, uncontrolled fan-out, and missing backpressure. Introduce explicit resource and concurrency limits.
16. Inspect all failure paths for partial writes, orphaned resources, and inconsistent state. Implement safe recovery or compensation.
17. Audit critical dependencies for cascading failure risks. Introduce isolation, load shedding, or circuit breaking where justified.
18. Inspect startup, shutdown, and deployment transitions. Ensure in-flight work completes safely or can be retried without data loss.
4. Data integrity & consistency
19. Identify business invariants enforced only in application code. Move durable integrity guarantees into database constraints where possible.
20. Trace all write paths for duplicate processing. Make operations idempotent wherever retries, concurrency, or repeated delivery can occur.
21. Audit cache consistency, invalidation, and expiration. Find stale-data bugs and eliminate caches that introduce more risk than value.
22. Inspect derived data, counters, and materialized views for drift. Establish reliable update and reconciliation mechanisms.
23. Identify assumptions of immediate consistency across asynchronous operations, replicas, and caches. Fix correctness failures caused by stale reads.
24. Audit timestamp-based ordering and coordination. Replace unsafe wall-clock assumptions with versioning, logical ordering, or stronger coordination where required.
5. Scalability & distributed systems
25. Analyze high-volume access patterns for hotspots, skewed workloads, and contention. Remove bottlenecks without premature architectural complexity.
26. Audit background jobs and event consumers for duplicate, missing, and out-of-order messages. Make processing correct under realistic delivery guarantees.
27. Identify synchronous operations that unnecessarily block user-facing requests. Move suitable work to durable asynchronous processing.
28. Inspect distributed workflows for unsafe assumptions about atomicity across services. Introduce explicit coordination or recovery semantics.
29. Review queue consumers for poison messages, retry storms, and dead-letter handling. Ensure recoverable failures cannot permanently stall processing.
30. Audit batch and stream processing for replay safety, checkpoint correctness, and late-arriving data. Fix non-deterministic or lossy processing.
6. Maintainability & evolution
31. Audit database schema migrations for backward compatibility, partial deployment safety, and recoverability. Fix unsafe migrations.
32. Inspect API and event schemas for incompatible changes. Establish safe producer-consumer evolution without requiring synchronized deployments.
33. Identify competing sources of truth and duplicated state ownership. Consolidate authoritative writes and clarify consistency boundaries.
34. Trace critical data transformations end to end. Identify silent coercion, precision loss, encoding errors, and unvalidated assumptions.
35. Audit observability across critical data flows. Add missing latency distributions, queue-depth metrics, failure classifications, and trace correlation.
36. Identify unnecessary architectural complexity in storage, caching, messaging, and synchronization. Simplify systems where guarantees can be preserved.
37. Find implicit state machines — lifecycles tracked through scattered booleans, nullable fields, and status strings — and make each one explicit: named states, allowed transitions, one guarded entry point per transition, and no state reachable by any other path.