axiom-codex/skills/axiom-audit-storage/SKILL.md
Use when the user mentions file storage issues, data loss, backup bloat, or asks to audit storage usage.
npx skillsauth add charleswiltgen/axiom axiom-audit-storageInstall 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.
You are an expert at detecting file storage mistakes that cause data loss, backup bloat, and file access errors.
Run a comprehensive storage audit and report all issues with:
Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*
If >50 issues in one category:
If >100 total issues:
Pattern: Anything written to tmp/ that isn't truly temporary
Risk: iOS aggressively purges tmp/ - users lose data
Files that should NOT be in tmp/:
Pattern: Files >1MB in Documents/ or Application Support/ without isExcludedFromBackup Risk: User's iCloud quota filled unnecessarily
Should be excluded:
Should NOT be excluded:
Pattern: File writes without specifying FileProtectionType Risk: Sensitive data not encrypted at rest
All files should have explicit protection:
.complete.completeUntilFirstUserAuthentication.noneAnti-Patterns:
Pattern: Storing >1MB data in UserDefaults Risk: Performance degradation, not designed for large data
Should use files or database instead.
Use Glob tool:
**/*.swift
Run these grep searches:
Files Written to tmp/:
# Look for tmp/ path usage
tmp/|NSTemporaryDirectory
Large Files Without Backup Exclusion:
# Files written to Documents or Application Support without isExcludedFromBackup
fileSystemRepresentation.*Documents|Documents.*write|Application Support.*write
Then check if isExcludedFromBackup is set nearby.
Missing File Protection:
# File writes without protection specification
\.write\(to:|Data\(contentsOf:|FileManager.*createFile
Then check if .completeFileProtection or FileProtectionType is specified.
Wrong Storage Locations:
# Check for hardcoded paths (should use FileManager URLs)
/Documents/|/Library/|/tmp/
UserDefaults Abuse:
# Large data in UserDefaults
UserDefaults.*set.*Data\(|UserDefaults.*set.*\[
Then check file size via Read tool.
CRITICAL (Data Loss Risk):
HIGH (Major Impact):
MEDIUM (Moderate Impact):
LOW (Best Practices):
# Storage Audit Results
## Summary
- **CRITICAL Issues**: [count] (Data loss risk)
- **HIGH Issues**: [count] (Backup bloat / wrong location)
- **MEDIUM Issues**: [count] (Security / performance)
- **LOW Issues**: [count] (Best practices)
## CRITICAL Issues
### Files in tmp/ Directory (Data Loss Risk)
- `src/Managers/DownloadManager.swift:45` - Writing downloads to NSTemporaryDirectory()
- **Risk**: iOS purges tmp/ aggressively - users will lose downloads
- **Fix**: Move to Caches/ with isExcludedFromBackup:
```swift
let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let downloadURL = cacheURL.appendingPathComponent("downloads/\(filename)")
try data.write(to: downloadURL)
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true
try downloadURL.setResourceValues(resourceValues)
src/Cache/ImageCache.swift:67 - Writing images to Documents/ without backup exclusion
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true // Can re-download
try imageURL.setResourceValues(resourceValues)
src/Models/UserData.swift:89 - User documents in Application Support/
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
src/Services/AuthManager.swift:34 - Writing token without file protection
try tokenData.write(to: tokenURL, options: .completeFileProtection)
src/Settings/SettingsManager.swift:123 - Storing 2MB data in UserDefaults
let appSupportURL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
let settingsURL = appSupportURL.appendingPathComponent("settings.json")
try settingsData.write(to: settingsURL)
Use this to fix wrong location issues:
What are you storing?
User-created documents (PDF, images, text)?
→ Documents/ (user-visible in Files app, backed up)
App data (settings, cache, state)?
├─ Can regenerate/re-download? → Caches/ + isExcludedFromBackup
└─ Can't regenerate? → Application Support/ (backed up, hidden)
Truly temporary (<1 hour lifetime)?
→ tmp/ (aggressive purging)
For comprehensive storage guidance:
/skill axiom:storage for storage decision framework/skill axiom:storage-diag for debugging missing files/skill axiom:file-protection-ref for encryption details/skill axiom:storage-management-ref for purging policies
## Audit Guidelines
1. Run all searches for comprehensive coverage
2. Provide file:line references to make it easy to find issues
3. Categorize by severity to help prioritize fixes
4. Show specific fixes - don't just report problems
5. Explain impact - data loss vs backup bloat vs security
## When Issues Found
If CRITICAL issues found:
- Emphasize data loss risk
- Recommend immediate fix
- Provide exact code to add
If NO issues found:
- Report "No storage violations detected"
- Note runtime testing still recommended
- Suggest testing with low storage scenarios
## False Positives
These are acceptable (not issues):
- Truly temporary files in tmp/ (deleted within minutes)
- Small config files (<100KB) without backup exclusion
- Public cache data without file protection
## Testing Recommendations
After fixes:
```bash
# Test file persistence after reboot
# Device: Settings → General → Shut Down
# Test storage pressure (low storage scenario)
# Fill device to <500MB free, launch app
# Test backup size
# Settings → [Profile] → iCloud → Manage Storage → [App]
development
Use when building ANY watchOS app — app structure, independent apps, Watch Connectivity, Smart Stack widgets, complications, controls, RelevanceKit, background tasks, ClockKit migration.
development
Use when working with HealthKit, WorkoutKit, health data, workouts, or fitness features on iOS or watchOS. Covers permissions, queries, background delivery, custom workouts, multidevice coordination.
development
Use when building, fixing, or improving ANY SwiftUI UI — views, navigation, layout, animations, performance, architecture, gestures, debugging, iOS 26 features.
content-media
Use when working with camera, photos, audio, haptics, ShazamKit, or Now Playing. Covers AVCaptureSession, PHPicker, PhotosPicker, AVFoundation, Core Haptics, audio recognition, MediaPlayer, CarPlay, MusicKit.