add-setting-env

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

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill add-setting-env-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-setting-env
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/apps/qwk-in-lobe/.agents/skills/add-setting-env
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill add-setting-env-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @t3-oss/env-core, zod.

What problem does it solve? Self-hosting administrators need a consistent way to override default user settings via server-side environment variables, but wiring a new variable through env packages, types, server config, and the user store involves many coordinated steps that are easy to get wrong. ## Core Features & Use Cases - Guided Six-Step Workflow: Walks through defining the env variable with @t3-oss/env-core and zod, updating server config types, assembling global config, merging into the user store, and updating .env.example plus documentation. - Priority Model: Enforces the precedence chain of User Custom > Server Env Var > Hardcoded Default. - Concrete Example: Includes a complete worked example (AI_IMAGE_DEFAULT_IMAGE_NUM) showing every file touched. - Use Case: A developer wants self-hosters to configure the default number of generated images; this Skill produces the env definition, type updates, config assembly, store merge, and bilingual docs updates. ## Quick Start Add a server-side environment variable that sets the default value for the user setting named defaultImageNum.

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 in packages/env/src/<domain>.ts using createEnv from @t3-oss/env-core with a zod schema, then wire it through the server config type, global config assembly, and user store merge. Finish by documenting it in .env.example and the environment-variables docs.

What is the priority order between user settings and environment variables?

The precedence is User Custom > Server Env Var > Hardcoded Default. A value explicitly set by the user always wins; the environment variable only supplies the default when the user has not customized the setting.

Which library validates environment variables in this setup?

Validation uses @t3-oss/env-core's createEnv combined with zod schemas, for example z.coerce.number().min(1).max(20).optional(). The runtimeEnv field maps process.env values explicitly.

Do I need to update types when adding a new settings domain?

Yes, new domains require adding a field to GlobalServerConfig in packages/types/src/serverConfig.ts, preferably reusing existing types from packages/types/src/user/settings via PartialDeep. Existing domains only need the env definition and config wiring.

What documentation must be updated for a new environment variable?

Update .env.example with a commented example including range and default, plus both docs/self-hosting/environment-variables/basic.mdx (English) and basic.zh-CN.mdx (Chinese) to keep bilingual docs in sync.