.claude/skills/macos-best-practices/SKILL.md
macOS development best practices for code organization, data persistence, concurrency, and Swift language usage. Use when planning project structure or reviewing code patterns.
npx skillsauth add brdohman/agile-maestro macos-best-practicesInstall 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.
Reference material for macOS-specific development patterns and conventions.
| Template | When | What to Look For | |----------|------|-----------------| | Time Profiler | UI feels slow, scrolling janky | Main thread time > 16ms per frame | | Allocations | Memory growing over time | Objects not deallocated, retain cycles | | Leaks | Suspected retain cycles | Leaked objects with retain count > 0 | | Core Data | Slow fetches, high fault count | Unoptimized predicates, excessive faulting | | SwiftUI | Body recomputation storm | Views recomputing when they shouldn't | | Network | Slow API calls | Response times, connection reuse |
// Measure a block of code
let start = CFAbsoluteTimeGetCurrent()
let result = try await expensiveOperation()
let elapsed = CFAbsoluteTimeGetCurrent() - start
Logger.performance.debug("Operation took \(elapsed)s")
| Metric | Target | Investigate If | |--------|--------|---------------| | App launch | < 1s | > 2s | | List scroll | 60 fps | < 45 fps | | Search response | < 100ms | > 300ms | | Memory (idle) | < 100MB | > 200MB |
Beyond basic Task.checkCancellation():
// withTaskCancellationHandler for cleanup
func downloadFile(url: URL) async throws -> Data {
let handle = FileHandle(forWritingAtPath: tempPath)
return try await withTaskCancellationHandler {
try await performDownload(url: url)
} onCancel: {
handle?.closeFile() // Cleanup runs even on cancellation
try? FileManager.default.removeItem(atPath: tempPath)
}
}
// Cancellation-aware loops
func processAllItems(_ items: [Item]) async throws -> [Result] {
var results: [Result] = []
for item in items {
try Task.checkCancellation() // Exit early if cancelled
results.append(try await process(item))
}
return results
}
.task modifier cancels when the view disappearsasync let cancels siblings when one throwsTaskGroup cancels remaining children when one throwstask.cancel() sets the cancellation flagProduct > Profile (Cmd+I) > Choose template
# Open Instruments with Time Profiler
xcrun instruments -t "Time Profiler" -D trace.trace MyApp.app
# Open Instruments with specific PID
xcrun instruments -t "Allocations" -p $(pgrep MyApp)
testing
XCTest patterns for macOS Swift apps. Unit tests, async tests, Core Data tests, mock patterns, and assertion reference. Use when writing or reviewing tests.
tools
How to transition workflow state between review stages. Rules for setting review_stage and review_result fields on Stories and Epics.
documentation
Comment structure and rules for task workflow updates. Use when adding any comment to a task during implementation, review, or fix cycles.
testing
Validate task/story/epic/bug/techdebt metadata against schema v2.0. Run after TaskCreate or TaskUpdate to verify compliance. Returns pass/fail with actionable details.