code-enforce-layers
CommunityPrevent architectural drift with strict layer rules
Software Engineering#architecture#server functions#drizzle#use cases#code standards#tanstack query#layered design
Authorwebdevcody
Version1.0.0
Installs0
System Documentation
What problem does it solve?
It prevents accidental coupling between UI routes/components, server functions, and database access so your TanStack Start app stays maintainable and testable as features grow.
Core Features & Use Cases
- Fixed dependency chain: Enforces that routes/components/hooks/queries call server functions in src/fn/, which only call use cases or data-access, with Drizzle/database calls confined to src/data-access/.
- Correct placement for infra I/O: Ensures third-party SDK calls (e.g., Stripe, S3/R2 presigning, email send) are wrapped and placed under src/data-access/ and invoked from fn/use cases instead of being called directly from fn/ or use-cases.
- Query correctness with TanStack Query: Requires queryOptions and query keys to live in src/queries/ and be reused by hooks and route loaders via ensureQueryData to avoid cache key drift.
- Business-rule guardrails: Routes multi-step invariants (plan limits, ownership across entities, cross-entity orchestration) into src/use-cases/, keeping data-access as a thin DB shim.
- Auth boundary clarity: Keeps authentication/ownership checks at the fn handler boundary (with authenticatedMiddleware and row ownership comparisons), not inside data-access or use cases.
Quick Start
Ask the AI to add or change a feature by following the dependency chain and placing database access only in src/data-access/, business rules only in src/use-cases/, and query/mutation behavior through src/queries/ and src/hooks/ with no cross-layer shortcutting.
Dependency Matrix
Required Modules
None requiredComponents
Standard packageđź’» Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: code-enforce-layers Download link: https://github.com/webdevcody/go-mailing-list/archive/main.zip#code-enforce-layers Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.