This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the project (via Xcode command line tools)
xcodebuild -scheme SwiftLintRuleStudio -configuration Debug build
# Run all tests (four suites, run in this order: packages first, then app unit, then UI)
swift test --package-path SwiftLintRuleStudioCore
swift test --package-path SwiftLintInProcessBackend
xcodebuild test -scheme SwiftLintRuleStudio -destination 'platform=macOS' -only-testing:SwiftLintRuleStudioTests
xcodebuild test -scheme SwiftLintRuleStudio -destination 'platform=macOS' -only-testing:SwiftLintRuleStudioUITests
# Run tests via CI script
./scripts/ci_test.sh
# Run SwiftLint on the project
swiftlint
# Run SwiftLint with autocorrect
swiftlint --fix
# Open in Xcode
open SwiftLintRuleStudio.xcodeprojNote: Two layers are local Swift packages — SwiftLintRuleStudioCore/ and SwiftLintInProcessBackend/. Their tests run via swift test; xcodebuild test on the app scheme builds them but never runs their tests, so omitting either line silently skips those suites. The app-level unit tests and UI tests run via xcodebuild.
SwiftLint Rule Studio is a native macOS desktop application that provides a GUI interface for managing SwiftLint rules, discovering violations, simulating rule impact, and facilitating team coordination around code quality standards.
Platform: macOS 14.0+ (Sonoma or later) Swift Version: Swift 6.0 with strict concurrency checking UI Framework: SwiftUI
SwiftLintRuleStudio/
├── App/ # Application entry point
│ └── SwiftLintRuleStudioApp.swift
├── Core/ # Business logic and services
│ ├── Models/ # Data models (Rule, Violation, Configuration)
│ ├── Services/ # Core application services
│ └── Utilities/ # Helper utilities
├── UI/ # User interface
│ ├── Components/ # Reusable UI components
│ ├── ViewModels/ # MVVM view models
│ └── Views/ # SwiftUI views
├── Data/ # Data layer (configurations)
├── Assets.xcassets/ # App icons and assets
├── SwiftLintRuleStudioTests/ # Unit tests
└── SwiftLintRuleStudioUITests/ # UI tests
Located in Core/Services/:
- RuleRegistry - Central manager for SwiftLint rules metadata, caches rules from CLI
- WorkspaceAnalyzer - Background analysis engine, runs SwiftLint and parses violations
- ViolationStorage - Actor-based SQLite database for violations with thread safety
- YAMLConfigurationEngine - Safe YAML editing with comment preservation, diffs, validation
- ConfigBackupStore - Backups taken before each save, kept in Application Support (never in the user's project)
- WorkspaceManager - Workspace opening, validation, and recent workspace persistence
- ImpactSimulator - Simulates violations for disabled rules, discovers zero-violation rules
- OnboardingManager - First-run experience and SwiftLint detection
- XcodeIntegrationService - Opens violations in Xcode via URL schemes
- SwiftLintCLI - Command-line interface wrapper for SwiftLint execution
Located in Core/Models/:
- Rule - SwiftLint rule with identifier, description, severity, examples, parameters
- Violation - Code violation with file path, line, column, severity, suppression tracking
- Configuration - Workspace .swiftlint.yml configuration
Located in UI/Views/:
- RuleBrowser/ - Searchable, filterable rule list with master-detail split view
- RuleDetail/ - Rule documentation, examples, configuration UI with diff preview
- ViolationInspector/ - Violation browsing, filtering, suppression management
- ImpactSimulation/ - Rule impact analysis, batch simulation, zero-violation discovery
- Configuration/ - YAML diff preview and recommendations
- Onboarding/ - First-run setup wizard
- WorkspaceSelection/ - Workspace picker with recent workspaces
Located in UI/ViewModels/:
- RuleBrowserViewModel - Rule loading, search, filtering, sort order
- RuleDetailViewModel - Configuration state, YAML diff generation, save validation
- ViolationInspectorViewModel - Violation loading, filtering, grouping, bulk operations
- Views: SwiftUI components
- ViewModels: Observable classes with @Published properties
- Models: Plain Swift structs with Codable/Sendable
DependencyContainermanages all service instances- Passed through SwiftUI environment
- Swift 6 strict concurrency checking enabled
- Actor-based thread safety for
ViolationStorage - Proper
Sendableconformance throughout
Services use protocols for testability:
RuleRegistryProtocolViolationStorageProtocolSwiftLintCLIProtocol
- Use MVVM pattern: Views observe ViewModels, ViewModels call Services
- All services should have protocol definitions for testing
- Use
@MainActorfor UI-bound code - Use actors for thread-safe mutable state
- Tests are organized to mirror the source structure
- Test files use Swift Testing framework (not XCTest)
- Framework: Swift Testing (migrated from XCTest); UI tests use XCTest
- Test Location:
SwiftLintRuleStudioCore/Tests/,SwiftLintInProcessBackend/Tests/,SwiftLintRuleStudioTests/, andSwiftLintRuleStudioUITests/ - Coverage: 1,400+ tests, organized by Core/ and UI/
- Isolation: Tests use isolated UserDefaults, file system, and workspace instances.
ConfigBackupStore.standardresolves to a temporary folder in any test run; a test that asserts on backups injects its own store (ConfigBackupStore(root:))
SwiftLintRuleExplorer is the sandboxed (App Store) target; SwiftLintRuleStudio is
not sandboxed. Cover the Explorer's distinguishing behaviour from the package
suites — SwiftLintInProcessBackend/Tests/ for the backend and capability set,
SwiftLintRuleStudioCoreTests for the bookmark store.
Do not add an Xcode test target whose TEST_HOST is the Explorer app. A test
bundle sharing package products with its host makes Xcode rebuild every product as a
dynamic framework; SwiftLint's macro plugin then loads swift-syntax via @rpath, and
the Swift compiler's macro-plugin sandbox blocks the load. The build fails with
SwiftLintCoreMacros produced malformed response plus a cascade of bogus
SwiftLintCore errors that hide the real cause. -Xfrontend -disable-sandbox gets
past the build, but the host then crashes at launch on a missing SwiftOperators
symbol.
Caveat: package tests exercise the sandbox logic, not a real sandboxed process. Entitlement-dependent behaviour — whether a security-scoped bookmark actually resolves under the App Store sandbox — still needs a manual check before submission.
Enable a Rule:
- User toggles rule in RuleDetailView
- RuleDetailViewModel tracks pending changes
- User clicks "Apply Changes"
- YAMLConfigurationEngine generates new YAML with diff
- User confirms changes in diff preview
- Engine writes to .swiftlint.yml (atomic write; the previous file is backed up into ConfigBackupStore first)
- Notification triggers re-analysis
- WorkspaceAnalyzer runs SwiftLint
- ViolationStorage updated with new violations
- UI refreshes via Combine bindings
- Yams - YAML parsing
- SwiftLint - External CLI (linting engine)