ad-enforcement-tool

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: Apache-2.0

README

ADE

Go Reference Go Version Go Report Card Latest Release

ADE (Architectural Decision Enforcement) is a command-line tool for enforcing architectural decisions. Rules are written in a small DSL and stored in .rule files. ADE either compiles each rule into an executable architecture test or verifies it directly against the codebase, delegating language-specific work to plugins.

ADE is part of the ADG ecosystem. The adg enforce command tree is powered by this module.

Quick start

go install github.com/phi42/ad-enforcement-tool/ade@latest
ade plugin install fscheck --repo github.com/phi42/ad-plugin-fscheck
ade validate -i my-adr.rule
ade verify   -i my-adr.rule -p fscheck

If you are using the ADG tool, replace ade with adg enforce throughout (e.g. adg enforce validate -i my-adr.rule).

A typical rule file:

adr "0001" "Use Clean Architecture"

component "Domain" = "MyApp.Domain"
component "Infra"  = "MyApp.Infrastructure"

code "domain_isolated" {
  Domain must not depend on Infra
  severity error
}

file "tests_exist" {
  path "tests/ArchTests/" must exist
  severity error
}

A syntax-highlighting extension for .rule files is available for VS Code; install ade.vsix from the latest release or see extras/vscode/.

For a step-by-step walkthrough (install, plugins, writing a rule, compiling, running in CI) see the user guide.

Plugins

Enforcement is delegated to plugins, separate executables that receive the parsed rule IR (rule.Spec protobuf) and either generate tests (compile mode) or perform checks directly (verify mode).

Plugin Target Description
ad-plugin-archgo Go Compiles code rules into arch-go tests.
ad-plugin-netarchtest .NET / C# Compiles code rules into NetArchTest + NUnit tests.
ad-plugin-archunit Java Compiles code rules into ArchUnit tests.
ad-plugin-fscheck Any Executes file rules directly against the filesystem.

To author your own plugin, copy one of the starter templates in extras/plugin-templates/ (Go, C#, or Java) and follow the plugin developer guide.

If you have developed a plugin that you'd like to share, feel free to open a PR adding it to the list above.

Import ADE as a go module

The cmd package exposes the full enforcement command tree as a single *cobra.Command. Other tools can register it directly:

import adecmd "github.com/phi42/ad-enforcement-tool/cmd"

rootCmd.AddCommand(adecmd.NewEnforceCommand())

This is how ad-guidance-tool integrates the enforcement commands under adg enforce. The protobuf types used for plugin communication are also exposed as a public Go package at rule, and the DSL reference is exposed by the dsl package.

Documentation

Examples

License

Licensed under the Apache License, Version 2.0.

Directories

Path Synopsis
cmd
Package cmd assembles the `ade` (Architectural Decision Enforcement) command-line tool as a single cobra command tree.
Package cmd assembles the `ade` (Architectural Decision Enforcement) command-line tool as a single cobra command tree.
config
Package config implements the `ade config` subcommand group.
Package config implements the `ade config` subcommand group.
plugin
Package plugin implements the `ade plugin` subcommand group.
Package plugin implements the `ade plugin` subcommand group.
Package dsl exposes the ADE rule DSL language reference as an embedded string and provides a lightweight Validate helper.
Package dsl exposes the ADE rule DSL language reference as an embedded string and provides a lightweight Validate helper.
internal
dsl

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL