zenstack-authenticated-db-params

Derive an AuthenticatedDB type from ZenStack's base db client to resolve TypeScript circular reference errors.

1|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/Hankanman/claude-config --skill zenstack-authenticated-db-params
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zenstack-authenticated-db-params
Source: https://github.com/Hankanman/claude-config/tree/main/config/skills/zenstack-authenticated-db-params
Command: npx skills add https://github.com/Hankanman/claude-config --skill zenstack-authenticated-db-params

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves TypeScript circular reference errors that occur when passing an authenticated ZenStack database client to utilities. By introducing a local type alias and a consistent pattern, utilities can safely receive an authenticated db instance without breaking type safety.

Core Features & Use Cases

  • Local type aliasing to break circular dependencies by deriving a callable authenticated DB type from the base client.
  • Updated function signatures and call sites to accept an AuthenticatedDB parameter, ensuring ZenStack access control remains enforced.
  • Clear guidance for server actions to propagate the authenticated db context (auth.db) through utilities and transactions.

Quick Start

Apply the pattern by importing the base db client, creating an AuthenticatedDB type, and refactoring utilities and server actions to pass the authenticated database through each call.

Frequently Asked Questions about zenstack-authenticated-db-params

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix TypeScript circular reference errors when passing an authenticated ZenStack db client to utilities?

To fix TypeScript circular reference errors with an authenticated ZenStack db client, introduce a local AuthenticatedDB type alias derived from the base client's ReturnType<typeof db.$setAuth> and apply it consistently across utility function signatures and callers.

How do I propagate the authenticated ZenStack database context through Next.js server actions?

To propagate the authenticated ZenStack database context through server actions, import the base db client, derive the AuthenticatedDB type, and pass the auth.db instance through utility functions and transactions to maintain access control enforcement.

What is the AuthenticatedDB type in ZenStack and when do I need it?

The AuthenticatedDB type in ZenStack is a local type alias derived from the base db client using ReturnType<typeof db.$setAuth>. You need it when utilities require access-controlled database instances and server actions must pass the authenticated db context.

Can I use ZenStack access control with Better Auth in utility functions?

Yes, you can use ZenStack access control with Better Auth in utility functions by deriving a callable AuthenticatedDB type from the base ZenStack client and updating function signatures to accept the authenticated database instance as a parameter.

Why does my ZenStack db client break type safety when passed to server actions?

Your ZenStack db client breaks type safety due to circular dependencies when passing the authenticated instance directly. Resolve this by creating a local AuthenticatedDB type alias and consistently applying it to function signatures and call sites.

What is the best way to type an authenticated ZenStack database parameter for server actions?

The best way to type an authenticated ZenStack database parameter for server actions is to derive a local AuthenticatedDB type using ReturnType<typeof db.$setAuth> from the base client, breaking circular references while preserving access control enforcement.