Agent Skillsxinity-ai/xinity-ai › add-env-variable

add-env-variable

GitHub

指导在多服务包中按规范添加环境变量,通过Zod Schema分离配置定义与运行时解析,支持秘密标记及示例文件更新。

.claude/skills/add-env-variable/SKILL.md xinity-ai/xinity-ai

Trigger Scenarios

需要为服务添加新的环境变量 配置环境变量的Schema定义 处理环境变量的秘密标记

Install

npx skills add xinity-ai/xinity-ai --skill add-env-variable -g -y
More Options

Non-standard path

npx skills add https://github.com/xinity-ai/xinity-ai/tree/main/.claude/skills/add-env-variable -g -y

Use without installing

npx skills use xinity-ai/xinity-ai@add-env-variable

指定 Agent (Claude Code)

npx skills add xinity-ai/xinity-ai --skill add-env-variable -a claude-code -g -y

安装 repo 全部 skill

npx skills add xinity-ai/xinity-ai --all -g -y

预览 repo 内 skill

npx skills add xinity-ai/xinity-ai --list

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 (or serverenv.ts for dashboard): imports the schema and calls parseEnv() which reads process.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

  1. Add to the schema file with .describe("Human-readable description").
  2. Mark secrets with .meta(secret()) (imported from common-env). The CLI reads z.globalRegistry.get(field)?.secret to decide what goes into systemd LoadCredential secret files vs. plain EnvironmentFile entries.
  3. The runtime file does not need changes - it parses from the schema automatically.
  4. Update example.env if 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

Same Skill Collection

.claude/skills/add-dashboard-orpc-procedure/SKILL.md
.claude/skills/code-quality-control/SKILL.md
.claude/skills/integrate-model/SKILL.md
.claude/skills/run-tests/SKILL.md

Metadata

Files
0
Version
7684ed0
Hash
0fae560d
Indexed
2026-07-25 05:51

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 19:07
浙ICP备14020137号-1 $Гость$