skills/backend-authoritative-runtime-refactor/SKILL.md
Refactor apps so backend owns runtime truth and UI only projects snapshots. Use when tools have split authority. NOT for cosmetic UI work or new features before drift is removed.
npx skillsauth add curiositech/windags-skills backend-authoritative-runtime-refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Refactor only after you can say exactly where execution truth lives and how the UI reads it.
flowchart TD
A[Workflow refactor request] --> B{Can the UI still invent runtime truth?}
B -->|No| C[Use a narrower domain or UI skill]
B -->|Yes| D[Inventory command, query, and event seams]
D --> E{Can every user action map to command, query, or event?}
E -->|No| F[Freeze the contract before feature work]
E -->|Yes| G[Split projection state from backend-owned state]
G --> H{Are legacy compat paths still active?}
H -->|Yes| I[Move them to migration edges or delete them]
H -->|No| J[Add evaluators, replay-safe startup queries, and event subscriptions]
I --> J
J --> K[Validate reconnection, approval, and downstream readiness]
Use this routing model first:
command -> backend transition -> query or event projection, the seam is still wrong.Find all places where the UI:
Define three classes only:
If a UI action cannot be expressed as one of these, the architecture is still muddy.
Split stores into:
Do not let any store own both runtime truth and layout concerns.
Prefer deletion over "supporting both for now."
Typical deletions:
Every implementation node should have:
Symptom: the UI looks "read only" but quietly assembles phase, graph, or provider truth locally.
Fix: move that logic into backend commands or queries and treat the frontend as a projector.
Symptom: "support both for now" remains in the hot path for weeks and becomes the real architecture.
Fix: push compatibility to one-way migration edges with an explicit deletion date or remove it now.
Symptom: a human can approve work they cannot inspect because the review payload is partial or frontend synthesized.
Fix: backend must emit the exact review payload; the UI only renders it.
Symptom: relaunching the app changes visible state or loses gate position because the frontend cached authority.
Fix: startup must be a query against backend truth plus event replay, not store reconstruction.
If relaunching the app changes visible runtime state without any new backend event, authority is still split.
Problem:
Refactor path:
Success condition:
Fork when the work separates cleanly:
Keep final ownership decisions in the parent lane so one actor decides what the backend truly owns.
references/architecture-patterns.md — backend-owned workflow contract patterns and state-ownership splits.references/windags-lessons.md — concrete lessons from a real split-authority runtime migration.tools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.