db-replicas-views
Skill22 starsChanged 5 months agoMITView on GitHub
Audit read-scaling correctness — read-your-writes consistency when reads are routed to replicas, and materialized-view staleness / refresh strategy. Module M17. Feeds the Performance & Scale score.
In this repository36 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- auditSkill
- checklistSkill
- db-antipatternsSkill
- db-concurrencySkill
- db-connection-poolingSkill
- db-constraintsSkill
- db-defaults-generatedSkill
- db-engine-selectionSkill
- db-index-hygieneSkill
- db-indexingSkill
- db-keysSkill
- db-migration-safetySkill
- db-multitenancySkill
- db-namingSkill
- db-normalizationSkill
- db-orchestratorSkill
- db-partitioning-shardingSkill
- db-platform-fitSkill
- db-query-patternsSkill
- db-referential-integritySkill
- db-security-accessSkill
- db-specialized-fitSkill
- db-storage-bloatSkill
- db-temporal-historySkill
- db-types-precisionSkill
- designSkill
- explainSkill
- fixSkill
- introspectSkill
- migrateSkill
- nextSkill
- scoreSkill
- seedSkill
- stack-detectSkill
- startSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Read replicas and materialized views scale reads, but both introduce staleness that silently breaks correctness if the application assumes …
- Very specific: line 69
Never quote a lag number or a stale-read probability you cannot measure.
≈ “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
<!-- Copyright (c) 2026 Enrique Rocha (@soyenriquerocha) · tododeia.com · id er-f37b7121 -->db-replicas-views (M17)
Read replicas and materialized views scale reads, but both introduce staleness that silently breaks
correctness if the application assumes fresh data. This is a Performance & Scale (axis
performance) concern; feeds relational Escala w12 (shared with M16/M2/M9).
What it checks
- Read-your-writes — a write immediately followed by a read of the same data, where the read may be routed to an async replica that has not yet caught up. User writes a comment, the next page load reads the replica and the comment is "gone." Recommend routing the immediate read to the primary, or using sync/quorum reads where required.
- Materialized-view refresh — an
MATERIALIZED VIEWqueried as if live but refreshed manually / on a slow cron / never, so it serves stale data. FlagREFRESH MATERIALIZED VIEWwithoutCONCURRENTLY(locks readers), and views with no visible refresh schedule.
Score / axis
Feeds performance only (relational Escala w12; replica/view concerns map to the Query/Escala categories in NoSQL profiles where applicable).
Tier-0 (static)
Detect replica routing config (read/write split in the ORM/driver, multiple connection URLs), write→
read sequences against the same entity, CREATE MATERIALIZED VIEW DDL, and any REFRESH calls (and
whether CONCURRENTLY). Actual replication lag and refresh recency are runtime →
needs_api at Tier-0 (never a silent pass).
Tier-1/2 (verification query, Postgres)
-- replication lag (Tier-1, on primary):
SELECT client_addr, state,
pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) AS replay_lag_bytes
FROM pg_stat_replication;
-- matview presence + populated state:
SELECT matviewname, ispopulated FROM pg_matviews;Method query_stat / schema_introspect. Measurable replay_lag_bytes confirms the read-your-writes
exposure as established; matview refresh recency needs the app's schedule or Tier-2 observation —
absent it, staleness is directional.
Findings
Emit findings per schema/finding.schema.json. Examples:
M17.comments.read_your_writes_on_replica— immediate read after write routed to a replica (severity:3,warn, axisperformance, confidencedirectionalstatic /establishedTier-1,fixable: proposed— route the read to primary).M17.dashboard.matview_no_refresh— materialized view with no visible refresh schedule (severity:2,warn,directional/needs_api,fixable: advisory).M17.dashboard.refresh_blocks_readers—REFRESH MATERIALIZED VIEWwithoutCONCURRENTLY(severity:2,warn,establishedfrom DDL,fixable: proposed).
Each finding: evidence.observed quotes the routing config / view DDL / catalog row verbatim;
verification.reproduce is the query above referencing $DATABASE_URL; expected_impact is banded +
confidence-tagged (no naked %).
Honesty
- Replica staleness is correct by design for most analytics/reporting reads — flag it only where the read path needs its own just-written data, not as a blanket "replicas are dangerous."
- Never quote a lag number or a stale-read probability you cannot measure; lag claims need Tier-1 to be
established, otherwisedirectional. REFRESH … CONCURRENTLYrequires a unique index on the matview — note that prerequisite in the fix preview. Routing/refresh changes areproposed/advisory, neverauto.
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.

