architecture-guardian
Skill5 starsChanged 4 months agoMITView on GitHub
Prevent AI coding agents from introducing architecture drift. Use before non-trivial features, refactors, cross-module fixes, new services, repositories, validators, state stores, dependencies, schema changes, public API changes, or edits governed by a change contract. Architecture Guardian provides bounded discovery, reuse-first search, dependency rules, reviewed baselines, short-lived change contracts, scoped expiring exceptions, deterministic reports, and optional strict gates.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- kbourzayq/arch-guardtheir own version, first seen Nov 8, 2026
- imMamdouhaboammar/riqorword for word, first seen Aug 9, 2026
Other versions2 projects use a version of this.
Word for word · 1
- imMamdouhaboammar/riqor★ 4100% same
Edited · 0
None found.
Wrote their own version · 1
- kbourzayq/arch-guard★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .codex/AGENTS.mdAGENTS.md
- agent-kernelSkill
- architecture-guardianSkill
- agent-kernelSkill
- architecture-guardianSkill
- agent-kernelSkill
- agent-kernel-evolveSkill
- agent-kernel-opsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 20 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
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
- Distinctive: line 25
Do not require a full contract for a trivial typo or isolated documentation correction unless project policy explicitly requires it.
- Very specific: line 31
Read AGENTS.md, relevant agent instructions, and .agent-kernel/architecture/policy.json when present.
- Distinctive: line 40
If policy or stored architecture state is malformed, stop and repair the state before enforcing it.
- Distinctive: line 48
Use the discovered map to identify source roots, layers, internal edges, external packages, cycles, and importer evidence.
- Distinctive: line 52
Before creating a capability:
- Distinctive: line 80
Keep business rules in the reviewed domain layer.
- Distinctive: line 104
Do not hide a critical violation behind an aggregate score.
- Distinctive: line 114
Update a baseline only after reviewing existing findings.
- Distinctive: line 118
Do not create a second source of truth without evidence that responsibilities differ.
- Distinctive: line 119
Do not move business rules into transport, UI, persistence, provider, or framework layers.
- Distinctive: line 120
Do not bypass an existing public interface to access infrastructure directly.
- Distinctive: line 121
Do not add a dependency outside the reviewed layer graph or active contract.
- Distinctive: line 122
Do not broaden a contract because implementation drifted.
- Distinctive: line 123
Do not suppress findings without rule, scope, reason, owner, and expiry.
- Distinctive: line 124
Do not treat an expired exception as authorization.
- Distinctive: line 125
Do not attribute baseline findings to the current change.
- Distinctive: line 126
Do not block on low-confidence semantic guesses.
- Distinctive: line 127
Do not weaken policy to make a single PR green without user review.
- Distinctive: line 131
Create a baseline only after discovery and review:
- Distinctive: line 171
When an architecture check exposes a repeated agent mistake:
- Distinctive: line 201
Read only the focused reference needed for the task:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.
Files
Architecture Guardian
Architecture Guardian is Agent Kernel's local conformance workflow for AI-assisted code changes. It separates existing debt from new regressions, requires reuse evidence before parallel abstractions, and keeps implementation inside a reviewed task boundary.
Activate this skill when
- a feature spans more than one module or layer
- a refactor changes dependencies or public interfaces
- a new service, repository, adapter, hook, validator, state store, or utility is proposed
- a package, schema, migration, provider integration, or deployment boundary changes
- a change contract already exists
- the user asks to prevent architecture drift, cycles, duplicate sources of truth, or out-of-scope edits
- CI reports Architecture Guardian findings
Do not require a full contract for a trivial typo or isolated documentation correction unless project policy explicitly requires it.
Required workflow
1. Read project governance
Read AGENTS.md, relevant agent instructions, and .agent-kernel/architecture/policy.json when present. Do not infer policy from a roadmap or an old report.
2. Validate current state
agent-kernel architecture doctor . --json
agent-kernel architecture policy validate . --jsonIf policy or stored architecture state is malformed, stop and repair the state before enforcing it.
3. Discover the current structure
agent-kernel architecture discover . --jsonUse the discovered map to identify source roots, layers, internal edges, external packages, cycles, and importer evidence. Discovery reads bounded source files; it does not execute repository code.
4. Search reuse candidates
Before creating a capability:
agent-kernel architecture reuse "<business capability>" . --jsonReview symbols and files with adjacent responsibility. Do not create a parallel source of truth just because an existing abstraction has a different name.
5. Establish the task boundary
For non-trivial work:
agent-kernel architecture contract init . \
--task "<reviewed task>" \
--owner "<domain or team>" \
--allow "src/area/**,test/area/**" \
--expect "src/area/file.ts,test/area/file.test.ts" \
--dependencies "<new packages, if any>" \
--tests "<observable behavior>"
agent-kernel architecture contract validate . --jsonThe contract should be narrow enough to detect drift and broad enough to complete the reviewed task. Do not silently add unrelated directories.
6. Implement inside scope
Keep business rules in the reviewed domain layer. Use public interfaces rather than reaching into infrastructure internals. Preserve one source of truth for each rule.
A Claude PreToolUse hook can enforce Write, Edit, and MultiEdit scope. Review mode reports; strict mode denies.
7. Check before commit
agent-kernel architecture check . --jsonFor an intentionally enforced project:
agent-kernel architecture check . --strict --jsonClassify every finding:
- new deterministic blocker
- existing baseline debt
- covered by a valid scoped exception
- semantic review hint
- false positive that requires policy or detector correction
Do not hide a critical violation behind an aggregate score.
8. Close or update reviewed state
Close the contract after the task is complete:
agent-kernel architecture contract close . --jsonUpdate a baseline only after reviewing existing findings. A baseline is not an ignore file.
Hard rules
- Do not create a second source of truth without evidence that responsibilities differ.
- Do not move business rules into transport, UI, persistence, provider, or framework layers.
- Do not bypass an existing public interface to access infrastructure directly.
- Do not add a dependency outside the reviewed layer graph or active contract.
- Do not broaden a contract because implementation drifted.
- Do not suppress findings without rule, scope, reason, owner, and expiry.
- Do not treat an expired exception as authorization.
- Do not attribute baseline findings to the current change.
- Do not block on low-confidence semantic guesses; report them for review.
- Do not weaken policy to make a single PR green without user review.
Baselines
Create a baseline only after discovery and review:
agent-kernel architecture baseline . --json
agent-kernel architecture diff . --jsonA baseline records reviewed existing findings and package/import evidence. New blockers remain distinguishable from old debt.
Exceptions
agent-kernel architecture exception add . \
--rule no-cycles \
--files "src/legacy/**" \
--reason "Migration is split across two reviewed releases" \
--owner platform \
--expires "2026-12-31T00:00:00.000Z"
agent-kernel architecture exception list . --json
agent-kernel architecture exception revoke . <exception-id>Exceptions must be narrow, owned, and expiring. Prefer fixing the architecture or detector over creating long-lived exemptions.
Review and strict modes
Review mode is the adoption default. It reports candidate blockers without preventing work.
Strict mode returns a nonzero exit for new blocking violations. Enable it only after policy, baseline, contract, and exceptions are trustworthy.
The hook override is explicit:
AGENT_KERNEL_ARCHITECTURE_MODE=review agent-kernel architecture check . --json
AGENT_KERNEL_ARCHITECTURE_MODE=strict agent-kernel architecture check . --jsonFailure handling
When an architecture check exposes a repeated agent mistake:
agent-kernel failure capture \
--from <agent> \
--type architecture-failure \
--command "agent-kernel architecture check . --strict --json" \
--exit-code 2 \
--text "<redacted finding>" \
--root-cause "<supported cause>" \
--fix "<verified correction>"Promote a reusable lesson through the normal proposal and approval flow. Do not mutate policy automatically from one finding.
Output expectations
A complete Architecture Guardian response should state:
- policy and contract state inspected
- reuse candidates considered
- files and layers changed
- new dependencies requested or rejected
- baseline versus new findings
- tests and architecture checks run
- exceptions used, including owner and expiry
- remaining review hints or limitations
References
Read only the focused reference needed for the task:
references/workflow.mdreferences/policy-model.mdreferences/change-contracts.mdreferences/baselines.mdreferences/exceptions.mdreferences/reuse-first.mdreferences/hooks.mdreferences/false-positive-control.mdreferences/language-support.mdreferences/ci-and-gates.mdreferences/evaluation.mdreferences/threat-model.md
Canonical docs:
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
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.

