Show HN: ArchSpec – Static architecture linter for Ruby

earcar2 pts0 comments

Architecture linter for Ruby and Rails | ArchSpec

Skip to content

Appearance

Star<br>...

Star<br>...

v1.0.1

v1.0.1

Releases

Appearance

Star<br>...

Search documentation

Esc

ArchSpec

Executable architecture specifications for Ruby and Rails

Guarantee your agents and your team follow your conventions. ArchSpec turns them into static analysis checks that run in CI on every change. No AI involved, just Prism.

Get started

Check AI-written code

Configuration

Archspec.rb<br>Boundaries

controllers.can_only_use :models, :services<br>models.cannot_use :controllers<br>services.cannot_call :render, :redirect_to

[error] services must not call #render [methods.forbid]

app/services/create_user.rb:7:5

→ 7 │ render :new<br>│ ^~~~~~~~~~~

note: CreateUser calls render

architecture :rails

jobs.cannot_reference_constants "Current"

component :commands, in: "app/commands/**/*.rb"

commands.must_implement :call

component :queries, in: "app/queries/**/*.rb"

queries.cannot_call :save!, :update!, :destroy!

component :services, in: "app/services/**/*.rb"

services.must_be_empty because: "rich models"

component :billing, in: "packs/billing/**/*.rb"<br>component :catalog, in: "packs/catalog/**/*.rb"

billing.can_only_use :catalog

Check on every commit

archspec check reads your code with Prism, with no app boot and no database. Fast enough for CI, a git hook, and every change an agent makes.

🧱

Boundaries and dependencies

Allowed and forbidden references between layers and packs, dependency direction and cycles, controller APIs kept out of models, method protocols, and one-shot command objects.

📐

Architectures included

Start from one that is already written: Rails, vanilla Rails, layered, hexagonal, clean, modular monolith, CQRS, event-driven. Or compose your own rules in plain Ruby.

services archspec rails component architecture ruby

Related Articles