Agent Skillsevrendom/rudel › environment-variables

environment-variables

GitHub

管理环境变量,涵盖本地、CI、前端构建及Turborepo集成。提供添加新变量的检查清单及排查缺失错误的调试步骤,强调避免硬编码密钥及正确配置Docker与Turbo参数。

.claude/skills/environment-variables/SKILL.md evrendom/rudel

Trigger Scenarios

添加新的环境变量或密钥 调试变量未定义错误 解决本地通过但CI失败的测试问题 排查Turborepo环境变量传递故障

Install

npx skills add evrendom/rudel --skill environment-variables -g -y
More Options

Non-standard path

npx skills add https://github.com/evrendom/rudel/tree/main/.claude/skills/environment-variables -g -y

Use without installing

npx skills use evrendom/rudel@environment-variables

指定 Agent (Claude Code)

npx skills add evrendom/rudel --skill environment-variables -a claude-code -g -y

安装 repo 全部 skill

npx skills add evrendom/rudel --all -g -y

预览 repo 内 skill

npx skills add evrendom/rudel --list

SKILL.md

Frontmatter
{
    "name": "environment-variables",
    "description": "Environment variable management patterns. CRITICAL use when adding new environment variables (secrets, API keys, config), debugging \"X not defined\" or missing env var errors, tests passing locally but failing in CI, Turborepo not passing env vars to tasks, or troubleshooting deployment configuration errors.",
    "allowed-tools": [
        "Read",
        "Edit",
        "Grep",
        "Glob",
        "Bash"
    ]
}

Environment Variables Management

Source of Truth

.env.example documents the variables supported by the public repo. Contributors put local values in an untracked .env file or export them in the current shell. Never hardcode secrets or commit real values.

The core team injects hosted-service values through a private secrets manager. Hosted-service configuration and operations are intentionally outside this repo.

Four Integration Points

When adding a new environment variable:

1. Contributor Environment

Add the variable with a safe placeholder and description to .env.example. Contributors set the real value in .env or their shell.

2. GitHub CI Workflow

Map from GitHub Secrets in .github/workflows/ci.yml:

jobs:
  test:
    env:
      CLICKHOUSE_URL: ${{ secrets.CLICKHOUSE_URL }}
      API_KEY: ${{ secrets.API_KEY }}

Secrets must exist in repository settings → Secrets → Actions first.

3. Frontend VITE_* Variables (Dockerfile + CI Deploy)

Frontend variables prefixed with VITE_ are baked into the web app at build time by Vite. They must be declared in two places:

A) Dockerfile — Add an ARG declaration so Docker receives the value:

ARG VITE_ADMIN_ORGANIZATION_ID=""

B) .github/workflows/ci.yml deploy step — Pass the value as a --build-arg:

- name: Deploy
  run: |
    flyctl deploy --remote-only \
      --build-arg "VITE_ADMIN_ORGANIZATION_ID=${{ secrets.VITE_ADMIN_ORGANIZATION_ID }}"

If either is missing, the variable will be empty in the deployed frontend.

4. Package-Specific turbo.json

CRITICAL: Add to package-specific turbo.json, NOT root.

{
  "extends": ["//"],
  "tasks": {
    "test": {
      "passThroughEnv": ["CLICKHOUSE_URL", "API_KEY"]
    }
  }
}

Checklist: Adding New Environment Variable

  • Add a safe placeholder and description to .env.example
  • Set the local value in an untracked .env file or the current shell
  • Add to GitHub Secrets (if used in CI)
  • Add to .github/workflows/ci.yml (if used in CI)
  • If VITE_*: Add ARG in Dockerfile and --build-arg in CI deploy step
  • Add to package-specific turbo.jsonpassThroughEnv
  • Validate tests pass locally and in CI

Debugging Missing Env Vars

Check in order:

  1. Local environment: confirm the variable is exported or present in the untracked .env
  2. Package turbo.json: cat packages/your-package/turbo.json | grep -A 10 passThroughEnv
  3. GitHub Secrets: Repository settings → Secrets → Actions
  4. Hosted deployments: ask the core team to verify the private secrets manager and deployment mapping

Common Mistakes

❌ Adding to root turbo.json instead of package-specific ❌ Adding a VITE_* var to CI deploy --build-arg but not as ARG in Dockerfile (or vice versa)

Version History

  • 59fc2ed Current 2026-08-02 20:51

    将环境变量存储源从Doppler改为`.env.example`文档化管理,并补充了详细的调试指南和常见错误提示。

  • 781a16e 2026-07-24 11:32

Same Skill Collection

.claude/skills/api-testing/SKILL.md
.claude/skills/clickhouse-architecture-advisor/SKILL.md
.claude/skills/clickhouse-best-practices/SKILL.md
.claude/skills/clickhouse-js-node-coding/SKILL.md
.claude/skills/clickhouse-query/SKILL.md
.claude/skills/code-architecture/SKILL.md
.claude/skills/library-docs/SKILL.md
.claude/skills/pr-creation/SKILL.md
.claude/skills/testing-bun/SKILL.md
.claude/skills/typescript-standards/SKILL.md
.claude/skills/clickhouse-js-node-troubleshooting/SKILL.md

Metadata

Files
0
Version
59fc2ed
Hash
83bdeed8
Indexed
2026-07-24 11:32

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 10:17
浙ICP备14020137号-1 $Carte des visiteurs$