add-setting-env

Adds server-side environment variables that control default values for user settings.

Updated Jan 27, 2026
One-click install
npx skills add https://github.com/SmallAi-API/smaihub --skill add-setting-env-smallai-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-setting-env
Source: https://github.com/SmallAi-API/smaihub/tree/main/.agents/skills/add-setting-env
Command: npx skills add https://github.com/SmallAi-API/smaihub --skill add-setting-env-smallai-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers need a consistent way to let self-hosting administrators override default user settings via server-side environment variables, without touching hardcoded defaults or user-level configuration. ## Core Features & Use Cases - Environment Variable Definition: Creates validated env vars using @t3-oss/env-core and zod schemas in packages/env/src. - Config Wiring: Connects new env vars through server config types, global config assembly, and the user store merge layer. - Documentation Updates: Updates .env.example and bilingual self-hosting docs so the new variable is discoverable. - Use Case: Add an AI_IMAGE_DEFAULT_IMAGE_NUM variable so administrators can set the default number of generated images between 1 and 20 for all users. ## Quick Start Add a server-side environment variable that sets the default value for the image generation count setting.

Frequently Asked Questions about add-setting-env

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

FAQPage Schema
How do I add a server-side environment variable for user settings?

Define the variable with zod validation in packages/env/src using createEnv from @t3-oss/env-core, then wire it through the server config type, global config assembly, and user store merge. Finally document it in .env.example and the self-hosting docs.

What is the priority order for user setting values?

The priority is User Custom first, then Server Environment Variable, then Hardcoded Default. A user-configured value always overrides the server env var, which in turn overrides the built-in default.

How do I validate environment variable values with zod?

Use zod schemas inside createEnv, for example z.coerce.number().min(1).max(20).optional() to coerce string env values into validated numbers with range constraints. Invalid values fail validation at config load time.

Do I need to create new types for a new settings domain?

Prefer reusing existing types from packages/types/src/user/settings. Only add a new entry to GlobalServerConfig in packages/types/src/serverConfig.ts when introducing an entirely new settings domain.

Which files must be updated when adding a new settings env var?

Update the env definition in packages/env/src, GlobalServerConfig in packages/types, getServerGlobalConfig in apps/server, the user store action in src/store/user, .env.example, and both English and Chinese docs under docs/self-hosting/environment-variables.