claude-code-hexagonal-kit
CLAUDE.md1 starsChanged 36 days agoMITView on GitHub
Next.js (App Router) full-stack app with hexagonal architecture, SOLID and unit tests. No database: an in-memory adapter keeps pnpm dev zero-setup. No auth (out of scope for the demo). Example module: orders (place / cancel / list orders). Business rules live in the domain. The UI validates input (Zod) and translates; adapters store and fetch. For domain or application changes: write or adjust the test first, see it fail, then write the code, then pnpm check. Use the skills: new-module,…
- Reads credentials
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- connect-uiSkill
- new-adapterSkill
- new-moduleSkill
- new-use-caseSkill
The file
We split this CLAUDE.md into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 35
Only src/composition imports infrastructure.
- Very specific: line 45
Use the skills: new-module, new-use-case, new-adapter, connect-ui.
- Very specific: line 57
Never weaken or bypass the guardrails: do not edit .dependency-cruiser.cjs, .claude/hooks/ or .claude/settings.json, and do not use …
- Very specific: line 58
Never put business rules in src/app or in adapters.
- Very specific: line 59
Never call Date.now(), new Date() or Math.random() in domain or application code.
- Very specific: line 60
Never leave console.log or commented-out code.
- Distinctive: line 61
Never skip validation of external input.
- Very specific: line 69
Stop: if src/ changed, typecheck and tests must pass or you are sent back to fix them.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md 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
Claude Code Hexagonal Kit
Next.js (App Router) full-stack app with hexagonal architecture, SOLID and unit tests. No database: an in-memory adapter keeps pnpm dev zero-setup. No auth (out of scope for the demo).
@AGENTS.md
Commands
pnpm dev/pnpm build- run / build the apppnpm test- Vitest (domain, application, infrastructure, hooks)pnpm arch- dependency-cruiser layer rules (messages explain the fix)pnpm typecheck,pnpm lintpnpm check- lint + typecheck + test + arch. Run it before saying you are done.
Architecture map
src/app/ Next.js pages + server actions (driving adapter). Zod validation lives here.
src/modules/<name>/
domain/ entities, value objects, domain errors, ports. Pure TypeScript.
application/ use cases: make<UseCase>(deps) factories. Depend on domain only.
infrastructure/ adapters implementing ports (in-memory repo, clock, id generator)
index.ts module public API (never exports infrastructure)
src/composition/ composition root: the ONLY place adapters are wired into use cases
src/shared/ tiny shared kernel, only if truly needed (does not exist yet)Example module: orders (place / cancel / list orders).
Layer rules (enforced by .dependency-cruiser.cjs)
domainimports nothing from other layers and no npm packages. Time and ids come in through ports (Clock,IdGenerator).applicationimports onlydomain(andshared). Nonext,react,zod, adapters.infrastructuremay importdomain; neverapporcomposition.- Only
src/compositionimports infrastructure. src/appimports modules only via@/modules/<name>(index.ts) or@/composition/<name>.- A module never imports another module's internals, only its
index.ts. - No circular dependencies.
Business rules live in the domain. The UI validates input (Zod) and translates; adapters store and fetch.
Workflow
For domain or application changes: write or adjust the test first, see it fail, then write the code, then pnpm check.
Use the skills: new-module, new-use-case, new-adapter, connect-ui. Use the architecture-reviewer subagent on a finished diff and test-writer for missing tests.
Conventions
- Files kebab-case; one use case per file; tests beside the code (
order.ts->order.test.ts). - Types/classes PascalCase, functions camelCase. Ports are interfaces named for the role (
OrderRepository); adapters name the technology (InMemoryOrderRepository). - Money is integer cents. Domain objects are immutable; operations return new objects.
- Domain failures are
DomainErrorsubclasses with acode; the UI turns them into friendly messages. - Inside a module use relative imports; elsewhere use
@/.
Never
- Never weaken or bypass the guardrails: do not edit
.dependency-cruiser.cjs,.claude/hooks/**or.claude/settings.json, and do not useeslint-disable/@ts-ignoreto get around a rule. If a rule blocks you, explain to the user what you need. - Never put business rules in
src/appor in adapters. - Never call
Date.now(),new Date()orMath.random()in domain or application code. - Never leave
console.logor commented-out code. Never commit secrets or.envfiles. - Never skip validation of external input.
Hooks
Rules are enforced, not suggested (.claude/settings.json):
- PostToolUse on edits to
src/**/*.ts(x): runspnpm arch; a violation comes back to you with the rule and the fix. - PreToolUse: edits to the guardrail files above are blocked.
- Stop: if
src/changed, typecheck and tests must pass or you are sent back to fix them.
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.

