add-setting-env

Add Zod-validated environment variables for server-side user setting defaults.

1|Updated May 9, 2026
One-click install
npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill add-setting-env-duwenji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-setting-env
Source: https://github.com/duwenji/generative-ai-oss-tutorials/tree/main/sandbox/lobe-chat/.agents/skills/add-setting-env
Command: npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill add-setting-env-duwenji

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the need to configure default user settings in a self-hosted app without hardcoding values in the codebase, enabling safer and environment-specific defaults.

Core Features & Use Cases

  • Environment-variable-backed defaults: Reads server-side environment variables and maps them into user settings with a clear priority: User Custom > Server Env Var > Hardcoded Default.
  • Typed configuration by domain: Adds per-domain environment parsing (e.g., in src/envs/<domain>.ts) using Zod validation and typed config helpers.
  • End-to-end wiring: Updates shared server config types, assembles global server config, merges values into the user store slice, and documents the variables in .env.example and docs.

Use case: You want image-related defaults (like the maximum number of images generated) to differ between staging and production while keeping the UI behavior consistent and allowing users to override their own preferences.

Quick Start

Ask the system to add a new server-side setting by creating src/envs/<domain>.ts with Zod-validated env parsing, wiring it into the global server config and user store, then documenting it in .env.example and the self-hosting environment variable docs.

Frequently Asked Questions about add-setting-env

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

FAQPage Schema
How do I set default user settings via server environment variables in a self-hosted app?

Environment variable defaults follow a strict priority order: User Custom overrides Server Env Var, which overrides the Hardcoded Default. This ensures user preferences always win while server-level defaults apply when no user setting exists.

How to validate environment variables for server configuration using Zod?

Yes, Zod validation works for self-hosted server configuration by parsing raw environment variables into typed objects per domain. This fits self-hosting scenarios where defaults must vary by deployment domain while maintaining type safety.

What is the best way to configure environment-specific defaults without hardcoding values?

Wiring environment variables into user settings requires updating shared server config types, assembling the global server config, merging values into the user store slice, and documenting the variables in .env.example and self-hosting docs.

Why use environment variables instead of hardcoded defaults for user settings?

When wiring environment variables into user settings, avoid skipping the Zod validation step or omitting .env.example documentation. Failing to document the priority behavior or update shared server config types leads to unpredictable default resolution.