Changing an Architectural Rule Skilfully
Published by Manuel Rivero on 14/11/2026
In this lab we show a session in which an agent used our architecture-rules skill to modify an existing architectural rule.
The change itself was quite simple: we wanted to prevent domain classes from using javax. The interesting part is how the skill guided the agent through the process of changing the rule and checking that it still worked.
We had previously experimented with using LLM-generated counter-examples to test our architectural rules. This time, we wanted the agent to follow that approach as part of a repeatable workflow defined in a skill.
Finding the gap between current code and the rule
The agent found no javax.* imports in the domain code. However, javax was included in the dependencies allowed by the architecture test.
So, although the code was already following the constraint we wanted, the architecture test would allow someone to introduce a javax dependency into the domain without complaining.
Applying the architecture-rules skill
We asked the agent to change the rule. Since the repository has an architecture-rules skill, the agent used it to guide the work.
The skill describes how to add or modify architectural rules, including how to generate and store counter-examples that can be used to check that the rules actually work.
As we can see in the following trace, the agent started by reading the skill, the existing architecture tests, and the counter-examples already available in the project.
Before changing anything, the skill instructed the agent to run the architectural mutation tests to establish a baseline.
As we explained in our previous post, the mutation script introduces previously generated counter-examples, one at a time, and checks whether the corresponding architectural tests fail. The counter-examples are stored, so we don’t need an LLM to generate them every time we run the tests.
In this case, all eight existing mutants were killed. This meant that the architecture tests were still detecting the violations represented by those counter-examples before we started changing the rule.
Enforcing the boundary and proving it
The agent removed javax.. from the dependencies allowed for domain and validation classes. The domain could now depend only on its own classes and java.., while validations kept their existing exception for org.apache.commons.lang3.Validate.
But we also wanted to see the modified rule fail when confronted with a counter-example. Otherwise, we would only know that we had changed the test, not that it was checking what we intended.
Following the skill, the agent generated a counter-example that introduced a dependency on javax.sql.DataSource into a domain class. You can see the complete counter-example, including the expected failure and its verification, in this Gist.
It also documented the counter-example and registered it as domain-javax-dependency, so that the mutation script could use it in future runs.
After adding the new counter-example, the mutation script reported nine killed mutants and no survivors. The new mutant was killed by domain_classes_should_only_depend_on_domain_and_java_se, which was the rule we wanted to check.
The counter-example document confirmed that make arch-tests failed for the expected reason: the domain rule detected the dependency on javax.sql.DataSource.
At this point, we would have liked the agent to stop and ask us to review the counter-example and the failing architectural test. We wanted to check that the counter-example was actually violating the intended constraint and that the test was failing for the right reason.
However, in this session the agent didn’t stop. It continued with the rest of the work without asking for approval 🤷 … This is something we need to make more explicit in the skill.
The mutation script removed the temporary violating code after running the tests, but the counter-example remained stored so that it could be used again in future mutation runs.
The agent also updated ARCHITECTURE.md, AGENTS.md, and the existing dependency counter-example descriptions to reflect the change.
This was part of keeping the architectural rules and the documentation that agents use consistent.
Verification
The agent finished by running the mutation tests again. All nine mutants were killed, including the new one.
It also ran the project’s usual checks: make test executed 1,460 tests without failures, and make pmd reported no violations.
The new counter-example was now part of the architectural mutation suite. If we change the architectural rule again in the future, the script will introduce the same javax dependency and check whether the rule still detects it, without having to ask an LLM to generate the counter-example again.
Conclusion
This was a small change, but I think it illustrates quite well what we are trying to achieve with the architecture-rules skill.
Instead of just asking the agent to change an architectural test, we gave it a workflow to follow. It checked the existing mutants before making changes, generated a new counter-example for the modified rule, and stored it for future mutation runs.
The agent did skip the human review step. We need to make sure that the workflow gives us the opportunity to inspect the counter-example and the failing test before accepting a change to an architectural rule.
Apart from that, the session shows how we can combine the inferential work of an agent with deterministic tests. We use the LLM to generate the counter-example once, and then rely on the mutation script to check the rule whenever we change it.