This file provides guidance for Claude when working with the JKiller codebase.
JKiller is a macOS menu bar application for managing system resources. It allows users to kill resource-hungry processes and clean up disk space.
- Language: Swift 5
- UI Framework: SwiftUI
- Platform: macOS 13.0+
- Architecture: MVVM-like with ObservableObject monitors
JKiller/
├── JKiller/
│ ├── JKillerApp.swift # App entry point, creates monitors
│ ├── Info.plist # App configuration
│ ├── Services/
│ │ ├── MemoryMonitor.swift # System memory tracking
│ │ ├── ProcessMemoryMonitor.swift # Per-process memory tracking
│ │ ├── DiskMonitor.swift # Disk usage monitoring
│ │ ├── DiskCleaner.swift # Disk cleanup operations
│ │ └── ProcessKiller.swift # Process termination
│ └── Views/
│ └── MenuBarView.swift # Main UI
├── JKillerTests/ # Unit tests
└── JKiller.xcodeproj/
# Build the app
xcodebuild -scheme JKiller -configuration Debug build
# Run tests
xcodebuild -scheme JKillerTests -destination 'platform=macOS' testAll monitors follow the same pattern:
- Initialize with current values
- Start a Timer for periodic updates
- Use
@Publishedproperties for SwiftUI binding - Heavy work runs on background queue, UI updates on main queue
When running shell commands (ps, du, pkill):
- Always read pipe data BEFORE calling
waitUntilExit()to avoid deadlocks - Use
DispatchQueue.global(qos:)for background work
let process = Process()
let pipe = Pipe()
process.standardOutput = pipe
try process.run()
let data = pipe.fileHandleForReading.readDataToEndOfFile() // Read first!
process.waitUntilExit() // Then waitTests are in JKillerTests/. Each monitor/service has corresponding tests:
MemoryMonitorTests.swiftProcessMemoryMonitorTests.swiftDiskMonitorTests.swiftDiskCleanerTests.swift
Tests verify:
- Initial values are valid
- Formatted output contains expected units (KB/MB/GB)
- Async updates work correctly
- Add pattern to
ProcessKiller.swift - Add memory tracking in
ProcessMemoryMonitor.swift - Add button in
MenuBarView.swift - Add tests
- Add path and methods to
DiskCleaner.swift - Add tracking to
DiskMonitor.swift - Add button in
MenuBarView.swift - Add tests