enforce-dependency-rule
Skill7 starsChanged 16 days agoMITView on GitHub
Use when laying out a service's layers or untangling cross-layer imports — dependencies point inward, hexagonal boundaries, and component cohesion and coupling hold.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/claude-skillsword for word, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
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 repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
Files
Enforce Dependency Rule
Lays out the concentric layers of a service (Clean Architecture) and keeps source dependencies pointing inward, so the high-level policy never depends on a detail. Class-level rules are in apply-solid; the canonical service layout is service-layout.md.
The rule
Source dependencies point only inward, toward higher-level policy. An inner layer never names an outer-layer entity or data format. Four layers, inward to outward:
- Entities — enterprise-wide business rules and data (plain, dependency-free).
- Use cases — application-specific rules; orchestrate entities, contain the story of one feature.
- Interface adapters — presenters, controllers, gateways, SQL mappers; translate between the use case's plain data and the framework's format.
- Frameworks & drivers — the web server, database, UI toolkit; glue only.
main(the composition root) is the one place that knows the framework and DI container.
Data crossing a boundary is plain, dependency-free and in the inner circle's format — never an entity or a DB row leaking inward, and never an inner-layer type leaking outward.
Component cohesion
- REP — the granule of reuse is the granule of release: classes reused together are released together.
- CCP — classes that change for the same reason belong together (one reason to change).
- CRP — classes reused together stay together; do not force a client to depend on what it never uses. These three are a tension triangle: pick two for the current phase and say which.
Component coupling
- ADP — no dependency cycles. A cycle makes a change ripple in both directions; break it with a seam.
- SDP — depend in the direction of stability. Stability rises as more things depend on a component (and falls as it depends on more).
- SAP — a stable component should be abstract so it can still be extended. Dependencies run toward abstraction.
1. Audit (change nothing)
cat .claude/stack-profile.md 2>/dev/null | head -20
grep -rn "import.*from\|require(" --include="*.ts" --include="*.rs" --include="*.go" --include="*.py" . 2>/dev/null | head -40Map the imports and find the violations: a use case importing a web framework, an entity importing a DB row type, a cycle between two components, a stable component that is concrete. List them before touching.
2. Apply
- Move the offending import so it points inward; if an inner layer needs an outer service, define an interface (port) in the inner layer and implement it (adapter) in the outer.
- Break a cycle at the seam that belongs to the higher-level policy.
- Confine the framework to adapters and
main; keep SQL/MVC/HTTP out of entities and use cases.
Verify
A dependency graph (or a grep of imports) shows every edge pointing inward; a cycle detector reports none; the entity/use-case files import no framework or DB type. State the layer map in the note.
When to deviate
- A single small service where four layers are ceremony — collapse to two (domain + adapters) and say so.
- The repo's own CLAUDE.md or stack-profile dictates a different layering — local convention wins.
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.

