add-setting-env

Implement server-side environment variables for default user settings.

81.4k|15.8k|Updated May 21, 2023
One-click install
npx skills add https://github.com/lobehub/lobehub --skill add-setting-env-lobehub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-setting-env
Source: https://github.com/lobehub/lobehub/tree/main/.agents/skills/add-setting-env
Command: npx skills add https://github.com/lobehub/lobehub --skill add-setting-env-lobehub

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides teams to configure default user settings via server-side environment variables, enabling dynamic defaults without hardcoding values.

Core Features & Use Cases

  • Domain-specific env configuration: Create per-domain env schemas (src/envs/<domain>.ts) to centralize default values.
  • Type-safe wiring: Update server types to reflect new env-driven settings and ensure compile-time safety.
  • Server-wide assembly: Build a centralized getServerGlobalConfig to expose domain settings to the application at runtime.
  • User-store integration: Merge deployed env-based defaults into the user's state store for consistent behavior.
  • Documentation and examples: Update .env.example and docs to reflect new env vars.

Quick Start

Create a new environment variable for a domain in src/envs/<domain>.ts. Update the server global config in src/server/globalConfig/index.ts to expose the new var. Merge the value into the user store (src/store/user/slices/common/action.ts), and update .env.example and documentation accordingly.

Frequently Asked Questions about add-setting-env

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

FAQPage Schema
How do I configure default user settings using environment variables in a TypeScript application?

You can configure default user settings by defining environment variables in domain-specific schemas, validating them with zod, and merging them into the user store at runtime to avoid hardcoding values.

How do I set up domain-specific environment variables for a multi-domain app?

Set up domain-specific environment variables by creating individual env schemas in src/envs/<domain>.ts files, then assembling them into a centralized server config to expose settings to the application.

How do I ensure type safety when adding server-side environment variables?

Ensure type safety by updating TypeScript type definitions to reflect new env-driven settings and using zod for runtime validation, guaranteeing compile-time safety for server configurations.

Do I need external tools to manage environment variables with zod and TypeScript?

No external tooling is required beyond the project's existing build and documentation workflow, as the implementation relies on standard TypeScript project patterns and zod for runtime validation.

What is the best way to wire environment variables into a user state store?

The best way to wire environment variables into a user state store is to build a centralized getServerGlobalConfig and merge the deployed env-based defaults into the user's state store for consistent behavior.

Why should I use environment variables instead of hardcoding default user settings?

Using environment variables instead of hardcoding default user settings enables dynamic defaults across multi-domain applications, allowing configuration changes without modifying the application codebase.