lifecycle-and-side-effects-correctness
Skill20 starsChanged 2 months agoMITView on GitHub
Audit and design lifecycle side-effect correctness for async UI, purchase, analytics, retry, cancellation, presentation, and session flows. Use when reviewing SwiftUI or other UI lifecycle code, paywalls, subscription or purchase flows, analytics emission, async tasks, retries, reloads, sheet dismissal, remount behavior, or any change where user-visible state and side effects must stay consistent across lifecycle transitions.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- code-reviewSkill
- gemini-files-apiSkill
- harness-engineeringSkill
- hint-overlay-visual-verificationSkill
- ios-xcodegenSkill
- local-model-servingSkill
- mechanism-auditSkill
- meeting-transcriptionSkill
- public-source-release-auditSkill
- silent-pushes-setupSkill
- spec-creation-updatingSkill
- swift-testingSkill
- swiftui-view-refactorSkill
- xcode-buildSkill
- xcode-cloudSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 8 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill to prevent duplicate, stale, missing, or misattributed side effects across lifecycle transitions.
- Very specific: line 17
Keep one-shot effects out of view identity when remounts, .id(...), previews, or sheet recreation can run the code again.
- Very specific: line 33
No duplicate side effects from view remount, .task restart, .onAppear, .id(...), or sheet recreation.
- Distinctive: line 34
No stale completion side effects after cancellation, dismissal, navigation away, or superseded input.
- Distinctive: line 35
No false dismiss/present, impression, purchase, or retry analytics caused by view identity churn.
- Distinctive: line 45
Do not derive experiment, package, offering, campaign, or branch attribution from display text when a canonical ID exists.
- Very specific: line 50
Prefer lifecycle-bound tasks such as .task(id:) when the effect should cancel with the view.
- Very specific: line 52
After await, check cancellation, current identity, or generation token before emitting effects.
- Distinctive: line 54
Treat silent discard as invalid unless the spec names it and defines observability.
- Distinctive: line 58
Use focused tests around lifecycle edges:
- Distinctive: line 67
Use exact event sequences when order is contractual.
- Distinctive: line 71
When reviewing a lifecycle-sensitive change, report:
≈ “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
Lifecycle And Side Effects Correctness
Overview
Use this skill to prevent duplicate, stale, missing, or misattributed side effects across lifecycle transitions. Treat analytics, purchases, network retries, persistence, and callbacks as contract-bearing effects, not incidental code inside a view or async closure.
Workflow
1. Identify the owner
- Name the durable owner for each effect: service, coordinator, store, view model, view task, or external SDK.
- Keep one-shot effects out of view identity when remounts,
.id(...), previews, or sheet recreation can run the code again. - Separate view-local state from session, purchase, analytics, or persisted state.
2. Map lifecycle transitions
List the transitions that can start, repeat, cancel, or complete work:
- appear, disappear, dismiss, remount, reload, retry, background, foreground;
- task start, cancellation, timeout, success, failure, fallback;
- purchase start, product/offering reload, checkout, restore, completion;
- analytics impression, dismiss, branch, conversion, error, and retry.
For each transition, write the expected state and allowed side effects.
3. Enforce side-effect invariants
- No duplicate side effects from view remount,
.taskrestart,.onAppear,.id(...), or sheet recreation. - No stale completion side effects after cancellation, dismissal, navigation away, or superseded input.
- No false dismiss/present, impression, purchase, or retry analytics caused by view identity churn.
- In-flight purchase or mutation actions are idempotent, disabled, or otherwise guarded.
- Retry paths emit required lifecycle events exactly as specified and preserve session attribution.
- Failure paths either emit the required failure effect or explicitly suppress it under a documented rule.
- Persisted state, analytics properties, and user-visible copy derive from the same canonical source when they describe the same decision.
4. Check identity and attribution
- Define the stable session, impression, request, purchase, or operation ID before work starts.
- Preserve attribution through retries, slow loads, fallback, and personalized copy refresh.
- Do not derive experiment, package, offering, campaign, or branch attribution from display text when a canonical ID exists.
- Normalize stale IDs only at the boundary that owns the crosswalk; do not let tests erase identity bugs through broad normalization.
5. Verify cancellation and retry
- Prefer lifecycle-bound tasks such as
.task(id:)when the effect should cancel with the view. - Move effects to a longer-lived owner when they must survive view dismissal.
- After
await, check cancellation, current identity, or generation token before emitting effects. - Bound retries and state what happens to analytics, user-visible errors, and persisted state on each retry.
- Treat silent discard as invalid unless the spec names it and defines observability.
6. Design tests
Use focused tests around lifecycle edges:
- remount does not duplicate impression or purchase effects;
- dismissal cancels or suppresses stale completion effects;
- retry preserves the same session attribution when required;
- checkout disables plan changes or makes plan changes explicitly safe;
- failure, fallback, and cancellation emit the required event sequence;
- stale async completion cannot overwrite newer state.
Use exact event sequences when order is contractual. Use multiset checks only when order is intentionally irrelevant.
Review output
When reviewing a lifecycle-sensitive change, report:
Effect owners: which component owns each side effect.Lifecycle transitions: starts, repeats, cancellations, completions, and retries.Risk findings: duplicate, stale, missing, or misattributed effects.Required tests: the smallest tests that prove the lifecycle boundary.Residual risk: any behavior that still depends on manual QA, live SDK behavior, or product policy.
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.

