Index of every page on this site: llms.txt
All skills
demianturner avatar

/m23-model-swift-domain-state

@3031b90
Run it yourself

Refactor related Swift booleans and optionals into domain enums when their combinations represent mutually exclusive operation states. Use for state modelling and reducer transitions, not routine boolean cleanup.

Use this Skill: https://skilld.dev/gh/demianturner/swift-skills/m23-model-swift-domain-state

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈61 tokens for metadata: the name and description. ≈490 when used: this file.

Description uses 3.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈243 characters, or 3.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Model Swift domain state

Use an enum when several stored fields jointly describe one operation and permit combinations the domain cannot handle. Name the valid phases and attach data that exists only in a particular phase to that case.

Decide the boundary

  • Trace every read, write, and transition before changing the representation. Identify valid combinations, including states reached during cancellation and late responses.
  • Combine fields only when their meanings exclude one another. Loading, saving, monitoring, and file availability may overlap and need separate models. Independent settings may remain booleans; presence or absence alone may remain an optional.
  • Keep data outside the phase enum when it must survive transitions, such as cached rows shown during refresh or after failure.

For example, isLoading plus an optional error may become .idle, .loading, and .failed(Error) if loading and failure are exclusive. An active save request plus a saveAgain flag may become .saving(Request) and .savingWithFollowUp(Request) when a follow-up requires an active save.

Refactor the transitions

  • Make transitions assign one case directly. Avoid writable compatibility properties that reconstruct the old combinations.
  • Derive read-only convenience values for presentation when useful, such as isLoading or a display error.
  • Preserve request identity, cancellation, shared references, and guards against stale responses. An enum does not provide those safeguards by itself.
  • Keep case names and associated values tied to domain meaning. Do not introduce an enum merely to reduce the number of booleans.

Check behavior

Test the transitions affected by the change, especially retry after failure, edits during saving, newer external changes, and closure with work pending when those cases exist. Confirm that previously valid overlapping states still work and that invalid combinations can no longer be constructed.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo2 checks · Risk LOW
  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 3031b90. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated last month
metadata
{
  "short-description": "Model related Swift state with enums"
}

README badge

README badge for demianturner/swift-skills/m23-model-swift-domain-state