megastep/codex-skills/axiom-assume-isolated
Claude Code and agent skill by megastep/codex-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when needing synchronous actor access in tests, legacy delegate callbacks, or performance-critical code. Covers MainActor.assumeIsolated, @preconcurrency protocol conformances, crash behavior, Task vs assumeIsolated.
Install
npx vskill@latest install megastep/codex-skills/axiom-assume-isolatedSKILL.md
The same SKILL.md was published earlier as megastep/codex-skills/axiom-assume-isolated.
assumeIsolated — Synchronous Actor Access
Synchronously access actor-isolated state when you know you're already on the correct isolation domain.
When to Use
✅ Use when:
- Testing MainActor code synchronously (avoiding Task overhead)
- Legacy delegate callbacks documented to run on main thread
- Performance-critical code avoiding async hop overhead
- Protocol conformances where callbacks are guaranteed on specific actor
❌ Don't use when:
- Uncertain about current isolation (use
awaitinstead) - Already in async context (you have isolation)
- Cross-actor calls needed (use async)
- Callback origin is unknown or untrusted
API Reference
MainActor.assumeIsolated
Behavior: Executes synchronously. Crashes if not on MainActor's serial executor.
Custom Actor assumeIsolated
Task vs assumeIsolated
| Aspect | Task { @MainActor in } | MainActor.assumeIsolated | |
|---|---|---|---|
| Timing | Deferred (next run loop) | Synchronous (inline) | |
| Async support | Yes (can await) | No (sync only) | |
| Context | From any context | Must be sync function | |
| Failure mode | Runs anyway | Crashes if wrong isolation | |
| Use case | Start async work | Verify + access isolated state |
Patterns
Pattern 1: Testing MainActor Code
Pattern 2: Legacy Delegate Callbacks
From WWDC 2024-10169 — When documentation guarantees main thread delivery:
Pattern 3: @preconcurrency Shorthand
@preconcurrency is equivalent shorthand — wraps in assumeIsolated automatically:
When protocol adds isolation: @preconcurrency becomes unnecessary and compiler warns.
Pattern 4: Thread Check Before assumeIsolated
When caller context is unknown (e.g., library code):
Pattern 5: Custom Actor Access
Common Mistakes
Mistake 1: Silencing Compiler Errors
Mistake 2: Assuming GCD Main Queue == MainActor
They're usually the same, but not guaranteed. Check documentation or use async.
Mistake 3: Using in Async Context
When @preconcurrency Becomes Unnecessary
If the protocol later adds MainActor isolation:
Crash Behavior
Per Apple documentation:
"If the current context is not running on the actor's serial executor... this method will crash with a fatal error."
Trapping is intentional: Better to crash than corrupt user data with a race condition.
Resources
WWDC: 2024-10169
Docs: /swift/mainactor/assumeisolated, /swift/actor/assumeisolated
Skills: axiom-swift-concurrency
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingaxiom-assume-isolated/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/megastep/codex-skills/axiom-assume-isolated)