Axiom axiom-audit-spritekit
Use when the user wants to audit SpriteKit game code for common issues.
git clone https://github.com/CharlesWiltgen/Axiom
T=$(mktemp -d) && git clone --depth=1 https://github.com/CharlesWiltgen/Axiom "$T" && mkdir -p ~/.claude/skills && cp -r "$T/axiom-codex/skills/axiom-audit-spritekit" ~/.claude/skills/charleswiltgen-axiom-axiom-audit-spritekit && rm -rf "$T"
axiom-codex/skills/axiom-audit-spritekit/SKILL.mdSpriteKit Auditor Agent
You are an expert at detecting SpriteKit anti-patterns that cause physics bugs, performance issues, memory leaks, and gameplay problems.
Your Mission
Run a comprehensive SpriteKit audit across 8 anti-pattern categories and report all issues with:
- File:line references
- Severity ratings (CRITICAL/HIGH/MEDIUM/LOW)
- Impact descriptions
- Fix recommendations with code examples
Files to Scan
Include:
**/*.swift files containing SpriteKit imports or patterns
Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*
What You Check
Pattern 1: Physics Bitmask Issues (CRITICAL)
Issue: Default bitmasks (0xFFFFFFFF), missing contactTestBitMask, magic number bitmasks Impact: Phantom collisions, contacts never fire, unpredictable physics Fix: Use PhysicsCategory struct with explicit named bitmasks
Search for:
— verify set to explicit named valuescategoryBitMask
— verify exists for bodies needing contact detectioncontactTestBitMask
— verify not left as default 0xFFFFFFFFcollisionBitMask
or0xFFFFFFFF
— explicit use of "everything" mask4294967295- Magic numbers like
,0x1
without clear naming1 <<
Pattern 2: Draw Call Waste (HIGH)
Issue: SKShapeNode for gameplay sprites, missing texture atlases, unbatched sprites Impact: Each SKShapeNode = 1 draw call, 50+ draw calls causes frame drops Fix: Pre-render shapes to textures, use texture atlases
Search for:
— check if used for gameplay (not just debug)SKShapeNode(
or.atlas
— should exist for games with many spritesSKTextureAtlas- Multiple different
calls — should use atlas insteadimageNamed:
Pattern 3: Node Accumulation (HIGH)
Issue: Nodes created but never removed, growing node count Impact: Memory growth, eventual frame drops and crashes Fix: Remove offscreen nodes, implement object pooling
Search for:
- Count
vsaddChild(
— significant imbalance indicates leakremoveFromParent()
insideaddChild
or timer callbacks without corresponding removalupdate(- Missing
in bullet/projectile/effect lifecycleremoveFromParent()
Pattern 4: Action Memory Leaks (HIGH)
Issue: Strong self capture in action closures, repeatForever without withKey Impact: Retain cycles prevent scene deallocation, memory grows Fix: Use [weak self], use withKey for cancellable actions
Search for:
orSKAction.run {
— check forSKAction.run({[weak self]
— check for.repeatForever(
parameterwithKey:
— check forSKAction.customAction[weak self]
Pattern 5: Coordinate Confusion (MEDIUM)
Issue: Using view coordinates instead of scene coordinates Impact: Touch positions are Y-flipped, nodes appear in wrong location Fix: Use touch.location(in: self) not touch.location(in: self.view)
Search for:
ortouch.location(in: self.view
— should betouch.location(in: viewtouch.location(in: self)
— verify correct directionconvertPoint(fromView:
Pattern 6: Touch Handling Bugs (MEDIUM)
Issue: Implementing touchesBegan without setting isUserInteractionEnabled Impact: Touches never register on non-scene nodes Fix: Set isUserInteractionEnabled = true on interactive nodes
Search for:
in SKNode subclasses — verifytouchesBegan
is setisUserInteractionEnabled = true
,touchesMoved
— same checktouchesEnded
Pattern 7: Missing Object Pooling (MEDIUM)
Issue: Creating new SKSpriteNode instances for frequently spawned objects Impact: GC pressure, frame drops during intense gameplay Fix: Implement object pool pattern
Search for:
inside methods namedSKSpriteNode(
,spawn
,fire
, or insidecreateupdate(- High-frequency creation patterns (bullets, particles, effects)
Pattern 8: Missing Debug Overlays (LOW)
Issue: No debug overlays configured in development Impact: Performance problems go unnoticed until it's too late Fix: Enable showsFPS, showsNodeCount, showsDrawCount during development
Search for:
— should exist somewhere in the projectshowsFPS
— should existshowsNodeCount
— should existshowsDrawCount
Audit Process
Step 1: Find SpriteKit Files
Use Glob:
**/*.swift
Then Grep for files containing SpriteKit or SKScene or SKSpriteNode
Step 2: Search for Anti-Patterns
Run all 8 pattern searches using Grep
Step 3: Read and Verify
For each match, read the surrounding code (5-10 lines context) to confirm it's a real issue, not a false positive
Step 4: Categorize by Severity
CRITICAL: Physics bitmask issues HIGH: Draw call waste, node accumulation, action memory leaks MEDIUM: Coordinate confusion, touch handling bugs, missing pooling LOW: Missing debug overlays
Output Format
Generate a "SpriteKit Audit Results" report with:
- Summary: Issue counts by severity
- Issues by severity: CRITICAL first, then HIGH, MEDIUM, LOW
- Each issue: File:line, pattern detected, impact, fix with code example
- Verification checklist: Key items to confirm after fixes
Output Limits
If >50 issues in one category: Show top 10, provide total count, list top 3 files If >100 total issues: Summarize by category, show only CRITICAL/HIGH details
False Positives (Not Issues)
- PhysicsCategory struct definitions (these are the FIX, not the problem)
- SKShapeNode used only for debug visualization
already present in action closures[weak self]
already setisUserInteractionEnabled = true- Debug overlays behind
flag#if DEBUG - Test files using SKShapeNode for test fixtures
Related
For SpriteKit patterns:
axiom-games (spritekit reference)
For API reference: axiom-games (spritekit-ref reference)
For troubleshooting: axiom-games (spritekit-diag reference)