agentleFS
willink-osswillink-oss/willink-claude-kit/skills/architecture-parity-gate/SKILL.md

architecture-parity-gate

Skill0 starsChanged 4 months agoMITView on GitHub

Detect where a code tree violates its declared architecture — config-declared allowed dependency directions plus per-layer naming rules. A language-agnostic, python-stdlib-only, detection-only gate (fixing is a human's job; wiring it into CI is a deliberate human step). Triggers: architecture violation, dependency direction check, layer boundary, naming-rule gate, architecture parity, dependency-direction gate.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    stop primitive: scripts/goal-loop.sh (exit 0 = GOAL MET / 1 = CONTINUE / 2 = CAP REACHED)

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

architecture-parity-gate (detection only)

Given a config (JSON) that declares the design intent — (1) the allowed dependency directions between layers and (2) the per-layer file naming rules — this gate mechanically detects where the code tree (--root) violates it. "parity" = compare the declared design against the implementation tree. Language-agnostic and config-driven (import detection is delegated to the config's import_markers regexes). This skill never rewrites code (no fix / delete / rename — detection only).

Scope and safety

  • Detection is read-only — it walks local files only; no gh / aws, no network, no writes.
  • Fixing a violation is a human's job — correcting a dependency direction or renaming a file happens in a PR. The gate reports; it does not repair.
  • Wiring this gate into CI is a deliberate, higher-risk step — installing it as a required status check / branch protection changes what can block merges, so do it by hand, on purpose. Running it locally or in a PR check is low-risk.

How to run

  1. Declare the architectural intent as JSON (see the example config below). Keep a config per target repo.
  2. Detect (read-only):
    python3 "${CLAUDE_PLUGIN_ROOT:-.}/scripts/arch-parity-check.py" --config <config.json> --root <dir>
    • exit 0 = no violations (parity OK).
    • exit 1 = dependency and/or naming violations. Details (file:line + type) are printed.
    • exit 2 = usage / config read / parse error (do not read empty output as "0 violations").
  3. On exit 1, a human fixes the printed violations in a PR (the gate does not fix them).
  4. To gate CI, wire it into a workflow / branch protection by hand.

Config schema (every field optional — a minimal config still runs)

A ready-to-copy example lives at examples/arch-parity.config.example.json (a classic layered / clean architecture: domain <- application <- infrastructure).

{
  "layers": {
    "domain":         {"roots": ["src/domain"],         "import_markers": ["from +domain", "import +domain"]},
    "application":    {"roots": ["src/application"],     "import_markers": ["from +application"]},
    "infrastructure": {"roots": ["src/infrastructure"], "import_markers": ["from +infrastructure"]}
  },
  "allowed_dependencies": {
    "domain": [],
    "application": ["domain"],
    "infrastructure": ["application", "domain"]
  },
  "naming": [
    {"applies_to": "domain", "must_match": "_entity\\.py$", "message": "domain files must be *_entity.py"},
    {"applies_to": "domain", "must_not_match": "Controller\\.py$", "message": "no Controller in domain"}
  ],
  "exclude": ["node_modules", "/test"]
}
  • layers[L].roots — path prefixes of files that belong to layer L (classified by longest match).
  • layers[L].import_markers — regexes that mean "some file imports layer L" (language-agnostic).
  • allowed_dependencies[L] — whitelist of who L may depend on (same layer always allowed). [] = may depend on nothing.
  • naming[] — applies_to (a layer or *), path_regex (narrow targets by relpath), must_match / must_not_match (basename regexes).
  • exclude — skip files whose relpath contains any of these substrings (.git/ is always excluded).

Deterministic --check (self-test)

python3 "${CLAUDE_PLUGIN_ROOT:-.}/scripts/arch-parity-check.py" --self-test
  • exit 0 = the comparison logic (dependency whitelist + naming must_match/must_not_match + exclude + graceful bad-regex handling) matches on all built-in fixtures. The self-test writes a compliant tree (-> 0 violations) and a violating tree (-> 2 dependency + 2 naming) to a tempdir and compares (hermetic: no external dependency, no external writes).
  • exit 1 = a mismatch in any case (logic is broken).

Related

  • backing script: scripts/arch-parity-check.py
  • stop primitive: scripts/goal-loop.sh (exit 0 = GOAL MET / 1 = CONTINUE / 2 = CAP REACHED)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.