
Add Setting Env
- 1.5k installs
- 81.3k repo stars
- Updated August 5, 2026
- lobehub/lobe-chat
This is a copy of add-setting-env by lobehub - installs and ranking accrue to the original listing.
add-setting-env is a Lobe Chat maintainer skill that adds server-side environment variables with @t3-oss/env-nextjs and Zod schemas so admin defaults override hardcoded user-setting values.
About
add-setting-env is a Lobe Chat repository skill with disable-model-invocation set true, guiding maintainers through adding server-side environment variables that control default user settings. It follows a priority chain: User Custom beats Server Env Var beats Hardcoded Default. Steps include creating src/envs/<domain>.ts with createEnv from @t3-oss/env-nextjs, Zod coercion and min/max validation, wiring env reads into setting defaults, and documenting the variable. Developers reach for add-setting-env when shipping a new configurable Lobe Chat preference without editing hardcoded defaults scattered through the codebase.
- Adds server-side env vars that control default user settings
- Follows clear priority: User Custom > Server Env Var > Hardcoded Default
- Creates new domain config files in src/envs/<domain>.ts
- Updates TypeScript interfaces in packages/types/src/serverConfig.ts
- Assembles config in src/server/globalConfig/index.ts
Add Setting Env by the numbers
- 1,541 all-time installs (skills.sh)
- +85 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lobehub/lobe-chat --skill add-setting-envAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.5k |
|---|---|
| repo stars | ★ 81.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 5, 2026 |
| Repository | lobehub/lobe-chat ↗ |
How do you add server env defaults for Lobe Chat settings?
Add new server-side environment variables that set default user preferences in Lobe Chat without changing hardcoded values.
Who is it for?
Lobe Chat contributors adding admin-configurable default user settings via server environment variables.
Skip if: Client-only UI tweaks or projects outside the lobehub/lobe-chat codebase conventions.
When should I use this skill?
The maintainer needs a new Lobe Chat server env var controlling a user setting default with Zod validation.
What you get
src/envs/<domain>.ts Zod-validated env module, wired default user setting, and documented server-side configuration variable.
- src/envs/<domain>.ts module
- Zod-validated env variable
- Wired default user setting
Files
Adding Environment Variable for User Settings
Add server-side environment variables to configure default values for user settings.
Priority: User Custom > Server Env Var > Hardcoded Default
Steps
1. Define Environment Variable
Create src/envs/<domain>.ts:
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';
export const get<Domain>Config = () => {
return createEnv({
server: {
YOUR_ENV_VAR: z.coerce.number().min(MIN).max(MAX).optional(),
},
runtimeEnv: {
YOUR_ENV_VAR: process.env.YOUR_ENV_VAR,
},
});
};
export const <domain>Env = get<Domain>Config();2. Update Type (if new domain)
Add to packages/types/src/serverConfig.ts:
import { User<Domain>Config } from './user/settings';
export interface GlobalServerConfig {
<domain>?: PartialDeep<User<Domain>Config>;
}Prefer reusing existing types from packages/types/src/user/settings.
3. Assemble Server Config (if new domain)
In apps/server/src/globalConfig/index.ts:
import { <domain>Env } from '@/envs/<domain>';
export const getServerGlobalConfig = async () => {
const config: GlobalServerConfig = {
<domain>: cleanObject({
<settingName>: <domain>Env.YOUR_ENV_VAR,
}),
};
return config;
};4. Merge to User Store (if new domain)
In src/store/user/slices/common/action.ts:
const serverSettings: PartialDeep<UserSettings> = {
<domain>: serverConfig.<domain>,
};5. Update .env.example
# <Description> (range/options, default: X)
# YOUR_ENV_VAR=<example>6. Update Documentation
docs/self-hosting/environment-variables/basic.mdx(EN)docs/self-hosting/environment-variables/basic.zh-CN.mdx(CN)
Example: AI_IMAGE_DEFAULT_IMAGE_NUM
// src/envs/image.ts
AI_IMAGE_DEFAULT_IMAGE_NUM: z.coerce.number().min(1).max(20).optional(),
// packages/types/src/serverConfig.ts
image?: PartialDeep<UserImageConfig>;
// apps/server/src/globalConfig/index.ts
image: cleanObject({ defaultImageNum: imageEnv.AI_IMAGE_DEFAULT_IMAGE_NUM }),
// src/store/user/slices/common/action.ts
image: serverConfig.image,
// .env.example
# AI_IMAGE_DEFAULT_IMAGE_NUM=4Related skills
How it compares
Use add-setting-env for Lobe Chat server defaults instead of editing hardcoded values when admins need deployment-time configuration.
FAQ
What priority order do Lobe Chat setting defaults follow?
add-setting-env documents Lobe Chat setting priority as User Custom overrides Server Env Var, which overrides Hardcoded Default when wiring new configuration variables.
What libraries does add-setting-env use for env vars?
add-setting-env creates src/envs/<domain>.ts modules using @t3-oss/env-nextjs createEnv with Zod schemas for typed, validated server-side environment variables in Lobe Chat.
Is Add Setting Env safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.