Spec Driven Development Kit w/HexaLayered Architecture
Spec Driven Development Kit w/HexaLayered Architecture
Something has bothered me ever since I wrote HexaLayered Architecture. The documentation was good, the examples were good, the rules were clear. But the rules only worked if someone read them.
A new developer would join a project and use TicketEntity in the service layer. I would see it in the pull request. Sometimes I did not see it, and it was merged.
Turning the Architecture into Claude Code
Some time ago I sat down and turned the architecture into something Claude Code can read and apply. There is a .claude directory in the repo now. Inside it there is a file called constitution.md. It keeps the rules of the architecture, not as advice like "you should do it this way", but as rules you can test.
- Which classes are public
- Which ones are package-private
- How far an entity can go up through the layers
There is also a Spec Driven Development flow.
Spec Driven Development Flow
/hexa:specifywrites down what will be built/hexa:planwrites down which class goes into which package- The code comes after that
Nobody has to ask "where does this class go?" when the file is already open.
Automated Code Enforcement
I also added a shell script that runs on every file write. If a service imports an entity, if a Controller is still public, if a class reaches into another module's repository, the script exits with code 2 and the error goes straight back to the model. It does not wait for the code review.
Moving the Kit to Another Project
You only need two commands to move it to another project:
cp -r .claude ./hexa:bootstrap
bootstrap finds the base package, the build tool (Maven or Gradle) and the test command by itself. When you start a Spring Boot project from zero, the architecture is correct from the first commit.
I took the rules from the README, then checked them on ays-be. It is a real project that uses the architecture, so it was a good test.
🔗 https://github.com/agitrubard/hexalayered-architecture/pull/1
Comments
No comments yet. Start the discussion.