Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

ArchSpec is a Ruby and Rails tool for turning architecture boundaries and team conventions into rules that can be checked against code—including code written with AI assistance. It uses static analysis rather than an AI judgment step; the product page describes its approach as “No AI involved, just static analysis.” ArchSpec product overview

That distinction matters: ArchSpec can flag code that violates rules your team has defined, but it cannot enforce conventions that have not been captured, and static analysis cannot resolve every dynamic Ruby behavior. The tool is specifically the Ruby/Rails product at archspecrb.dev; other tools with the same name may be unrelated.

What ArchSpec checks—and what it does not

ArchSpec lets a team describe architectural constraints in Ruby configuration, then inspect source code for violations. Those constraints can cover which application components may depend on one another, which methods or constants may be used, prohibited calls, and dependency cycles. Teams can add reasons to rules and manage exceptions through documented suppression and todo mechanisms. ArchSpec configuration reference

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This makes it useful for a specific AI-coding problem: an agent can generate code that compiles or appears locally plausible while crossing a boundary the team cares about. A repeatable check can detect a defined violation after the code is written. It does not make the agent understand the team’s full intent, choose good architecture, or establish that the rules themselves are correct.

Rules reflect your application, not a universal architecture

For example, a Rails team might prohibit models from depending on controllers, or forbid services from calling rendering and redirect methods. These are examples of boundaries a team could encode, not prescriptions that every Rails application should adopt. The value comes from choosing constraints that match the application’s design and maintaining them as that design changes.

Set up ArchSpec in a Ruby project

The official getting-started guide specifies Ruby 3.2 or newer. Its basic workflow is to install ArchSpec as a development or test dependency, generate a configuration, define rules, and run the checker. ArchSpec Getting Started

  1. Add gem "archspec" to the appropriate development/test group in your Gemfile.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Install the dependency with bundle install.

  3. Generate the initial configuration with bundle exec archspec init.

  4. Edit Archspec.rb to select source and ignored file patterns, assign files to named components, and declare rules that fit your architecture.

  5. Run bundle exec archspec check to check the code against those rules.

According to the guide, the check exits with status 0 when rules pass and a nonzero status when violations are found. That gives scripts and CI a simple pass/fail signal; developers can use the accompanying diagnostic to investigate the specific finding.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you can express in the configuration

The configuration reference describes several kinds of constraints. The precise syntax belongs in the current reference, but the rule model includes:

  • Component dependencies: allow or prohibit dependencies between named parts of an application, or restrict which components may depend on a given component.

  • Methods and calls: require or forbid methods, prohibit calls, and express constraints such as preventing services from calling rendering or redirect methods.

  • Constants: restrict references to constants, helping keep dependencies within defined boundaries.

    Free tools Windows power users keep installed

    One-click scans. No signup required.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Cycles: check for dependency cycles between components.

  • Exceptions and follow-up: attach reasons to rule declarations and use inline suppressions or todo handling for documented exceptions.

Rules are only as useful as their scope and rationale. Start with boundaries that are important enough to keep consistent, and make exceptions visible rather than silently treating every finding as noise. Configuration details

Read findings and connect checks to development

A violation diagnostic can identify the rule and its ID, show the offending code span, and provide a note with the evidence found. The CLI also supports command help, alternate configuration paths, and JSON output. ArchSpec CLI reference

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because the command returns a nonzero status for failed rules, it can serve as a gate in CI or a git hook, or be run locally after a change—including an AI-assisted change. A practical workflow is to review the diagnostic evidence, decide whether the code should change or the rule needs a justified exception, and then rerun the check. JSON output may also help automation consume findings, depending on how a team integrates the CLI.

The project documentation says checks index code without loading the application, so they do not require a Rails boot or database and have no side effects. Treat that as vendor-documented behavior rather than an independently established guarantee for every project setup. ArchSpec: How It Works

Understand the limits of static analysis in Ruby

Ruby permits behavior that can be difficult to determine from source alone. ArchSpec’s configuration reference says dynamic receivers remain unknown rather than guessed; the implementation documentation identifies features such as send, const_get, and method_missing as analysis gaps. Configuration reference How It Works

As a result, a clean check means no violation was reported for the configured rules and analyzed evidence. It is not proof that every runtime behavior was resolved, that all architectural concerns have been captured, or that the application will behave correctly. When a finding involves dynamic behavior, inspect the evidence and decide whether the rule remains appropriate, needs a documented exception, or should be enforced another way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When ArchSpec is a good fit

ArchSpec is worth evaluating if a Ruby or Rails team wants explicit, repeatable checks for its own architecture boundaries and can maintain the rules as the codebase evolves. It is particularly relevant where AI-assisted changes need to be checked against conventions that are otherwise easy to overlook.

Before adopting it, consider the following:

If comparing it with another architecture checker, assess language and framework support, analysis method, rule types, diagnostic evidence, integration options, configuration effort, dynamic-language handling, and licensing or hosting terms. The available product documentation does not establish comparative benchmarks or a tested winner.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.