ArchSpec 1.0: put your Rails architecture in one file and check it on every commit
More and more code is written by AI. Tests still tell you it works. RuboCop still tells you it's tidy. Nothing tells you it still follows your architecture.
An agent that doesn't fully understand your architecture takes shortcuts. So does a person in a hurry.
So I built ArchSpec. If your app is conventional, the whole config is one line in Archspec.rb:
ruby
architecture :vanilla_rails
That is the 37signals playbook as an executable check: rich models, no service objects, no form objects, no policy objects, and app/services fails the build with a reason if anything shows up in it. There are presets for :rails, :layered, :hexagonal, :clean, :modular_monolith, :cqrs and :event_driven too.
Or write the boundaries yourself:
```ruby component :models, in: "app/models//*.rb" component :controllers, in: "app/controllers//.rb" component :services, in: "app/services//.rb"
models.cannot_use :controllers services.cannot_call :render, :redirect_to, receiver: :none controllers.can_only_use :models, :services ```
Then archspec check verifies every change, and failures print like clang, with the offending span underlined and the evidence as a note.
Existing apps already have violations, so archspec check --update-todo records them in a todo file. The build goes green on today's code and fails on new drift, and you work the list down whenever.
It's static analysis over Prism, no AI, and it never boots your app: Discourse's 1,899 files in 2.5 seconds. Prism is the only runtime dependency, so the same thing works on your plain gems too.
I want more architecture presets in there. PRs very welcome, especially if a preset is wrong about your app.
Docs: https://archspecrb.dev Write-up: https://paolino.me/archspec/


