param087/saas-starter-skills/data-access-layer
Claude Code and agent skill by param087/saas-starter-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when querying or mutating the database from the app — wrap Drizzle in server-only, tenant-scoped functions instead of calling the ORM from components, so every read/write is typed, testable, and isolation-safe.
Install
npx vskill@latest install param087/saas-starter-skills/data-access-layerSKILL.md
The same SKILL.md was published earlier as param087/saas-starter-skills/data-access-layer.
Data Access Layer
Overview
Don't scatter ORM calls across components and route handlers. Put every query behind a server-only data-access layer (DAL): small typed functions that take an explicit orgId and never return another tenant's rows. The rest of the app calls getProjects(orgId), not db.select(...). This centralizes tenant scoping, caching, and the place you write tests.
When to use
- Any read or write to the database.
- You catch yourself importing
dbinto a React component. - You want one place to enforce "every query is scoped to the current org".
The pattern
Callers (server components, actions, route handlers) pass the orgId resolved from the session — they never invent it.
Why a DAL
- Isolation by construction. Lookups filter on
id AND org_id, so a guessed UUID from another tenant returnsnull, not data. - Typed end-to-end.
returning()gives you the row type for free. - Testable. Mock or seed the DB and test functions directly, no HTTP needed.
- Cacheable. Wrap reads in
cache()/unstable_cachein one spot.
Pitfalls
- Calling `db` from components — couples UI to the schema and risks shipping queries to the client. Always go through the DAL.
- Lookups by `id` only —
where(eq(projects.id, id))withoutorgIdis a cross-tenant read. Scope by both. - Returning raw rows with secrets — strip sensitive columns (tokens, hashes) in the DAL.
- N+1 in loops — batch with
inArrayor a join instead of awaiting per item. - Forgetting `server-only` — without it a refactor can pull DB code into the client bundle.
Hand-off
A typed, tenant-safe query layer. api-routes-and-validation and Server Actions call it after validating input; authorization-rbac gates which functions a role may invoke.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/data-access-layer/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/param087/saas-starter-skills/data-access-layer)