Skip to main content

env-config

Environment variable access conventions. All env access goes through centralized config modules (apps/server/src/config.ts, apps/web/src/config.ts). Use when reading process.env, adding new env vars, or modifying config files.

跳到安装

来源信息

仓库
recca0120/code-quest
最近来源活动
2026年5月7日 14:06
检测到的 SKILL.md 语言
英语
星标
11
分支
2

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
env-config
description
Environment variable access conventions. All env access goes through centralized config modules (apps/server/src/config.ts, apps/web/src/config.ts). Use when reading process.env, adding new env vars, or modifying config files.
# Environment Variable Configuration ## Convention All env access MUST go through centralized config modules — never read `process.env` or `import.meta.env` directly in application code. | Package | Config file | Access method | |---------|------------|---------------| | server | `apps/server/src/config.ts` | `process.env` with defaults | | client | `apps/web/src/config.ts` | `import.meta.env` (Vite) | ## Server Config (`apps/server/src/config.ts`) ```ts export const config = { port: Number(process.env.PORT ?? 3000), databaseUrl: process.env.DATABASE_URL, rawStore: { drivers: parseRawStoreDrivers(process.env.RAW_STORE ?? ''), sqlitePath: process.env.RAW_STORE_SQLITE_PATH ?? './data/code-quest.db', fileDir: process.env.RAW_STORE_FILE_DIR ?? './data/events', }, systemPrompt: process.env.SYSTEM_PROMPT ?? '', allowDangerouslySkipPermissions: process.env.ALLOW_DANGEROUSLY_SKIP_PERMISSIONS !== 'false', }; ``` **Env loading**: Node.js 20+ native `--env-file` flag (no dotenv dependency). ```json "dev": "tsx watch --env-file=.env src/bin/server.ts" ``` ## Client Config (`apps/web/src/config.ts`) ```ts export const config = { serverUrl: (import.meta.env.VITE_SERVER_URL as string) || '', }; ``` Vite auto-loads `.env` files. Only `VITE_` prefixed vars are exposed to client. ## .env Files | File | Location | |------|----------| | Server | `apps/server/.env` | | Server example | `apps/server/.env.example` | | Client | `apps/web/.env` | | Client example | `apps/web/.env.example` | ## Adding a New Env Var 1. Add to the appropriate config module (`config.ts`) with a sensible default 2. Add to `.env.example` with a comment 3. If server-side, no prefix needed. If client-side, use `VITE_` prefix 4. No zod validation currently — just raw access with defaults 5. Import `config` in application code, never access env directly ## Notes - `parseRawStoreDrivers()` parses comma-separated driver list (e.g., `'sqlite,mysql,file'`) - `allowDangerouslySkipPermissions` defaults to `true` (only `'false'` disables it) - Dev proxy configured in `apps/web/vite.config.ts` using `process.env.PORT` - Test: `apps/server/src/__tests__/config.test.ts` (covers `parseRawStoreDrivers`)
在 GitHub 查看