Agent Skills
› xinity-ai/xinity-ai
› add-env-variable
add-env-variable
GitHub指导在多服务包中按规范添加环境变量,通过Zod Schema分离配置定义与运行时解析,支持秘密标记及示例文件更新。
Trigger Scenarios
需要为服务添加新的环境变量
配置环境变量的Schema定义
处理环境变量的秘密标记
Install
npx skills add xinity-ai/xinity-ai --skill add-env-variable -g -y
SKILL.md
Frontmatter
{
"name": "add-env-variable",
"description": "Add a new environment variable to any service package following the env-schema \/ parseEnv pattern with Zod schema, describe(), and meta(secret()) annotations."
}
Add Environment Variable
When adding a new environment variable to any service package, follow this pattern.
Env schema separation
Each service package has two env files:
env-schema.ts: exports a Zod object schema with.describe()and.meta(secret())annotations. No side effects, safe to import from CLI or tests.env.ts(orserverenv.tsfor dashboard): imports the schema and callsparseEnv()which readsprocess.env.
| Package | Schema file | Runtime file |
|---|---|---|
| gateway | src/env-schema.ts -> gatewayEnvSchema |
src/env.ts |
| daemon | src/env-schema.ts -> daemonEnvSchema |
src/env.ts |
| dashboard | src/lib/server/env-schema.ts -> dashboardEnvSchema |
src/lib/server/serverenv.ts |
Steps
- Add to the schema file with
.describe("Human-readable description"). - Mark secrets with
.meta(secret())(imported fromcommon-env). The CLI readsz.globalRegistry.get(field)?.secretto decide what goes into systemdLoadCredentialsecret files vs. plainEnvironmentFileentries. - The runtime file does not need changes - it parses from the schema automatically.
- Update
example.envif this variable should have a default for local dev.
Example
// In env-schema.ts
import { secret } from "common-env";
export const gatewayEnvSchema = z.object({
// ... existing vars
MY_NEW_VAR: z.string().describe("What this var controls"),
MY_SECRET_VAR: z.string().describe("A secret value").meta(secret()),
});
Version History
- 9817b2f Current 2026-07-25 05:51


