solid-like-a-rock
Architecture linter for Swift — enforce Clean Architecture import rules via SwiftSyntax. A CI-ready guardrail for AI-assisted development.
A Swift command-line tool that enforces Clean Architecture layer boundaries in your iOS or macOS project, catching forbidden imports automatically on every build and in CI, especially useful for catching AI-generated violations.
SolidLikeARock is a command-line tool for Swift developers that checks whether their code respects architectural boundaries. In a pattern called Clean Architecture, a project is divided into layers, such as Domain (the core business logic), Data (talking to databases and APIs), and Presentation (the user interface). The rule is that these layers should only depend on layers closer to the center, not on outer ones. For example, a network layer should never import UI code. This tool enforces those rules automatically on every build and in continuous integration pipelines.
The motivation stated in the README is that AI-generated code can introduce architectural violations faster than human reviewers can catch them. One bad import that gets past a code review can spread into dozens more. SolidLikeARock catches these violations the moment they appear, regardless of whether a human or an AI assistant wrote the offending code.
The tool works by reading each Swift source file using SwiftSyntax, which is an official Apple library that produces a real parsed representation of Swift code rather than a text search. It identifies which architectural layer a file belongs to based on its folder path, then checks whether that file's imports match the rules you have defined. If a forbidden import appears, it prints an error message that includes the file, line, and the rule that was broken.
Configuration lives in a YAML file at your project root where you define layers, their source paths, and either an allow list (only these imports are permitted) or a deny list (these imports are forbidden). The tool includes an init command that analyzes your project's actual import graph and generates a starter configuration automatically. There is also a baseline feature: if you adopt the tool on an existing project that already has violations, you can record those as a baseline so the linter only fails on new problems going forward.
The tool installs via Homebrew and is available as a Swift package. It sits alongside SwiftLint (which checks code style) and Periphery (which finds dead code) as a complementary static analysis step focused purely on architectural rules. The project is MIT licensed.
Where it fits
- Add solid-like-a-rock to your iOS project's CI pipeline so the build fails whenever an AI-generated file imports across forbidden layer boundaries
- Run the init command on an existing project to auto-generate a YAML config that maps your folder structure to Clean Architecture layers
- Use the baseline feature to adopt the linter on a legacy codebase without breaking the build on pre-existing violations
- Catch a Data layer file accidentally importing UIKit before the violation spreads to other modules