---
id: gh-convex-env
name: "convex-env"
url: https://skills.yangsir.net/skill/gh-convex-env
author: convex
domain: ai-ci-cd-deployment
tags: ["convex", "env-vars", "secrets", "deployment", "devops"]
install_count: 35000
rating: 4.60 (120 reviews)
github: https://github.com/convex/agent-skills/tree/main/skills/convex-env
---

# convex-env

> 为 Convex 应用设置并接通部署环境变量与密钥：用 npx convex env set 按部署写入，在 action 中通过 process.env 读取，并用 env list --names-only 校验而不打印明文。它让密钥远离代码与 Git，每个部署各持独立值，显著降低硬编码与泄漏风险，适合本地、预发、生产的快速配置与安全核对。

**Stats**: 35,000 installs · 4.6/5 (120 reviews)

## Before / After 对比

### 多环境密钥配置与核对

**Before**:

开发者把密钥硬编码在源码或散落的 .env 文件里，再逐个环境手动粘贴，靠记忆判断哪个部署配好了，漏配或配错往往到线上报错才发现。

**After**:

此技能按部署写入密钥、在 action 中通过 process.env 读取，并用 env list --names-only 一眼核对已配置的名称，切换环境不再靠记忆。

| Metric | Before | After | Change |
|---|---|---|---|
| 环境变量配置耗时 | 30分钟 | 3分钟 | -90% |
| 因漏配导致的线上报错 | 4次/月 | 0次/月 | -100% |

### 密钥泄漏风险控制

**Before**:

密钥混在代码与提交记录中，排查问题时习惯性把值贴进聊天或工单，仓库一旦公开或协作方加入，凭据就可能被扩散。

**After**:

该 Skill 明确密钥只存于部署环境变量，校验时只列名称不打印值，明文不进代码库也不进对话，泄漏面大幅收窄。

| Metric | Before | After | Change |
|---|---|---|---|
| 硬编码密钥提交数 | 5次/季度 | 0次/季度 | -100% |
| 密钥暴露事件 | 2次/年 | 0次/年 | -100% |

## Readme

<!-- GENERATED from convex-agents content/capabilities/env.json — do not edit by hand. -->

# Manage env vars + secrets

Store secrets as Convex deployment env vars (npx convex env set), read them with process.env in actions, never commit them.

## Workflow

1. `npx convex env set KEY value` (per deployment).
2. Read via process.env.KEY inside actions (not queries/mutations).
3. Never hardcode or commit secrets; add to .env.local only for local.
4. Confirm it's set with `npx convex env list --names-only`, which lists names without printing the secret values.

## Rules

- Secrets live in Convex env vars, never in code or git.
- process.env only in actions ('use node' if needed), not queries/mutations.
- Different deployments need their own values.
- Check what is set with `npx convex env list --names-only`; never print secret values into the conversation.


---
*Source: https://skills.yangsir.net/skill/gh-convex-env*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-convex-env/markdown*