> Sourced from [phalladar/MacDirStat](https://github.com/phalladar/MacDirStat) β [MIT](https://github.com/phalladar/MacDirStat/blob/225f65ab1efda7eee50d76e3a29d123ba191b960/CLAUDE.md). # CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Build & Run ```bash swift build # Debug build swift build -c release # Release build swift run MacDirStat # Run the app open Package.swift # Open in Xcode ``` No external dependencies. No test target configured yet (`swift test` will fail). No linter configured; Swift 6 strict concurrency mode is enforced via `swiftLanguageMode(.v6)` in Package.swift. ## Architecture MacDirStat is a native macOS (15.0+) SwiftUI disk space analyzer that visualizes directory usage as interactive treemaps. Swift 6, SPM-only, zero external dependencies. ### State & Data Flow **AppState** (`@Observable`) is the single source of truth. It holds the scanned file tree (`rootNode: FileNode`), the current treemap view root (`treemapRoot`), selected node, and breadcrumb navigation stack. All views react to AppState changes. Scan flow: User picks folder β **ScanCoordinator** launches **FileScanner** β FileScanner uses BSD `fts_open`/`fts_read`/`fts_close` (not FileManager, for performance) β yields `ScanEvent`s via `AsyncStream` β ScanCoordinator throttles updates (50ms) and builds the **FileNode** tree β treemap renders. ### Module Layout (Sources/MacDirStat/) - **App/** β Entry point (`MacDirStatApp`) and `AppState` central state management - **Scanning/** β `FileScanner` (BSD fts-based traversal with inode dedup, symlink handling, allocated size via blocksΓ512), `ScanCoordinator` (async orchestration, throttling, cancellation), `FileNode` (tree model with weak parent refs to avoid retain cycles, recursive aggregate computation) - **Categorization/** β `FileCategory` (10 categories with colors/SF Symbols) and `FileExtensionMap` (200+ extensionβcategory mappings) - **Treemap/** β `TreemapLayoutEngine` (Squarify algorithm, max 8 depth levels), `TreemapHitTester`, `TreemapRenderer` (Canvas-based with depth-darkened category colors), `TreemapView` (click/double-click/hover/context menu interactions) - **Views/** β `ContentView` (NavigationSplitView: sidebar tree + center treemap + inspector), `WelcomeView` (volume list with usage bars, NSOpenPanel), `ScanProgressView`, `DirectoryTreeView` (OutlineGroup), `DetailPanelView` (metadata + category breakdown) - **Utilities/** β `ByteFormatter` (human-readable sizes) ### Key Patterns - All data types crossing async boundaries are `Sendable` - FileNode uses weak parent references to break retain cycles - FileScanner deduplicates hard links by tracking seen inodes - TreemapView uses Canvas for rendering (not individual SwiftUI views) for performance - macOS APIs used: `NSWorkspace` (Reveal in Finder), `NSPasteboard` (clipboard), `NSOpenPanel` (folder picker)
Add to your project
Paste into your project's CLAUDE.md or ~/.claude/CLAUDE.md for global rules.
More for React
Next.js Expert
by @Claude Rules
Expert-level Next.js development with App Router, Server Components, and modern patterns.
Swift iOS Development
by @Claude Rules
Modern iOS development with SwiftUI, Combine, and Swift concurrency.
Mindx CLAUDE.md
by @DotNetAge
δΈδΈͺε―θͺδΈ»θΏεηζ°εεεθΊ«
Think CLAUDE.md
by @matiasvillaverde
CLAUDE.md for the Think project (Swift).
TORCH Glare CLAUDE.md
by @TORCH-Corp
An open-source React UI library featuring accessible, elegant components β seamlessly styled with Tailwind CSS and fully extensible.
Dspy Demo CLAUDE.md
by @mahm
CLAUDE.md for the Dspy Demo project (Python).
MCP servers for React
netdata/netdata#Netdata
ποΈ π βοΈ π π πͺ π§ - Discovery, exploration, reporting and root cause analysis using all observability data, including metrics, logs, systems, containers, processes, and network connections
Swift MCP SDK
The official Swift SDK for Model Context Protocol servers and clients.
mihaelamj/cupertino
π π - Apple Documentation MCP Server. Search Apple developer docs, Swift Evolution proposals, and 600+ sample code projects with full-text search.
Get the Claude Code Starter Pack
Top CLAUDE.md rules for Next.js, TypeScript, Python, Go, and React β free.
