.aislop/rules.yml and aislop enforces them on every scan — and in CI. Violations appear in the report with the same severity and scoring impact as any other finding.
Enabling the architecture engine
The architecture engine is disabled by default because it requires a project-specific rules file. Enable it in.aislop/config.yml:
.aislop/rules.yml in the same directory. aislop reports an error at startup if architecture: true is set but the rules file is missing.
Creating .aislop/rules.yml
The rules file is a YAML document with a single top-levelrules: array. Each entry defines one constraint.
Rule types
forbid_import
Bans a module from being imported anywhere in the project. Use this to enforce that a particular package or internal module is never referenced directly — for example, to funnel all HTTP calls through a shared client.Must be
"forbid_import".The exact module specifier to ban. Matched against the import path in source files.
Human-readable explanation shown in the diagnostic. Explain what to use instead.
forbid_import_from_path
Prevents files matching a source glob from importing a module that matches a destination glob. Use this to enforce layer boundaries — for example, preventing controllers from bypassing the service layer and accessing the database directly.Must be
"forbid_import_from_path".A glob pattern matching the importing files. Files that match this pattern are not allowed to import from
module.A glob pattern matching the imported path. Imports that resolve to a path matching this pattern are flagged.
Human-readable explanation shown in the diagnostic.
require_pattern
Asserts that every file matching a path glob contains at least one occurrence of a string pattern. Use this to enforce cross-cutting conventions — for example, requiring all API route handlers to include error handling.Must be
"require_pattern".A glob pattern matching the files to check.
A string that must appear somewhere in each matching file.
Human-readable explanation shown when the pattern is absent.
pattern is matched as a literal string, not a regular expression. Keep patterns short and unambiguous so they don’t produce false positives in comments or strings.Full example
The following rules file mirrors theexamples/architecture-rules.yml config and demonstrates all three rule types together:
Tips for writing effective rules
Start with your most-violated conventions
Start with your most-violated conventions
Focus your first rules on the boundaries your team already discusses in code review. Architecture rules work best as a way to encode decisions you’ve already made, not to discover new ones.
Use forbid_import_from_path for layer enforcement
Use forbid_import_from_path for layer enforcement
forbid_import bans a module everywhere. forbid_import_from_path is more surgical — it only fires when the wrong layer does the importing. Prefer forbid_import_from_path for internal module boundaries so that the correct layer (e.g., a data-access layer) can still import the module freely.Keep require_pattern patterns short and distinctive
Keep require_pattern patterns short and distinctive
A pattern like
catch will match try/catch, .catch(, and catchAll. That’s usually fine for error-handling rules, but be specific enough that the pattern doesn’t match unrelated code (such as a variable named catchphrase).Pair rules with clear messages
Pair rules with clear messages
The
message field is shown directly in the diagnostic output. Make it actionable — tell the developer what to do, not just what’s wrong. For example: "Use the shared httpClient instead of importing axios directly" rather than "axios is forbidden".