安装 manage-env,将它连接到 AI 编程工具,并在不把密钥值放进聊天的情况下配置仓库。

本页内容

从 AI 开始

只需复制一段提示词给 AI 编程工具,再在自己的终端里完成少量必须由本人执行的信任设置。

# Set up manage-env (menv) in this repository

manage-env is a zero-knowledge secrets manager for env vars. Secret VALUES must
never enter your context, the chat, or any log - and you never need them to.
Follow these steps in order.

## 1. Install the CLI yourself

Run `menv --version`. If it is missing, install the public macOS/Linux CLI in
your terminal:

`curl -fsSL https://manage-env.com/install | sh`

Then run `export PATH="$HOME/.local/bin:$PATH"` in your current shell and
verify with `menv --version`. Do not ask the human to install the CLI or change
PATH for you. If your client cannot execute the command or requires approval,
request that approval and report the exact blocker instead. Do not send them to
the private GitHub repository.

## 2. Connect the repo yourself

Run `menv connect` from the repository root. It registers the local menv MCP
server for your client and writes the full agent guide into AGENTS.md. It only
touches repo-local files and handles no secret value. Afterwards, reload MCP
servers (or ask the human to restart their AI tool) so the menv tools load.

## 3. Secure user handoff: sign in

Only account authentication requires the human's direct terminal input. Ask
them to run `menv signup` (or `menv login` if they have an account) and enter
the email code, password, and one-time recovery key outside the chat. Do not
ask for, accept, or relay any of those values. Wait until they confirm sign-in.

## 4. Agent steps (menv MCP tools)

- Start with `detect_required_keys` (scans .env.example; works before init).
- If this directory is not bound to a project, call `init_project` - and if
  the `org/project` address is not already clear, ask the human for it
  instead of inventing one.
- Call `setup_project` to mint random secrets, keypairs, and config defaults
  in one version. Treat `needs_user` as the only list of decisions to bring
  back to the human.
- Externally-issued keys (STRIPE_*, DATABASE_URL, cloud creds):
  `request_value_from_user` - the human pastes the value at their own
  terminal. NEVER ask for a secret value in chat.
- Run anything that needs secrets with the `run_with_secrets` MCP tool. If it
  fails, it returns a masked tail of the output (injected values shown as
  `[menv:masked:KEY]`) so you can debug without the secrets; if
  `output_suppressed` is set, a value was too short to mask and the output was
  dropped - ask the human to run it in their terminal.
- When a result reports `stale_sync_targets`, re-sync each one with
  `sync_to_target`.

## Hard rules

- Never `cat .env`, `printenv`, or log `process.env` - reading a value
  defeats the whole point and is treated as an incident.
- Use the `run_with_secrets` MCP tool, not the `menv run` CLI, to run things.
  `menv run` is the human's terminal path; its output isn't masked when a human
  runs it interactively, and `menv run --raw-output` disables masking entirely
  and requires a human at the terminal.
- There is no tool that returns a secret value, by design. Do not try to
  reconstruct values by any other route.
- Do not run `menv run --yes` or `menv run --raw-output` on the human's
  behalf; those confirmation prompts exist for them, not you.

Full tool discipline: AGENTS.md after `menv connect`, or
https://manage-env.com/llms.txt

一次性终端设置

这些步骤会修改本机设置或验证身份,因此由你亲自执行。无需把密码、邮件验证码或密钥值粘贴到聊天中。

  1. 安装公开 CLI

    支持 macOS 和 Linux,并会校验下载的二进制文件。

    curl -fsSL https://manage-env.com/install | sh
  2. 创建账户或登录

    新账户使用 signup,已有账户使用 login。邮件验证码和密码只在你的终端中输入。

    menv signup   # 或: menv login
  3. 在仓库根目录连接

    为 Claude Code 和 Cursor 注册本地 menv MCP 服务器,并把安全规则写入 AGENTS.md。

    menv connect

    一键安装会把 menv MCP 服务器注册到你自己的 Cursor/VS Code 设置中。请同时在仓库里运行 menv connect——团队共享的 .mcp.json 和 AGENTS.md 安全指南由它生成。

  4. 重启 AI 编程工具

    完全重启以加载新的 MCP 服务器;如果工具询问,请批准 menv 服务器。

接下来交给 AI

重启后,把页面顶部复制的提示词粘贴到新对话。AI 只报告状态和键名,不报告值。

detect_required_keys

查找所需环境变量

读取 .env.example,区分可以生成的内容和需要你决定的内容。

init_project · setup_project

创建项目和安全值

绑定仓库、生成随机密钥和密钥对,并填写非敏感默认配置。

request_value_from_user

只向你询问第三方签发的值

Stripe 密钥、数据库 URL 等在 AI 无法读取的本地终端提示中输入。

run_with_secrets · sync_to_target

运行应用并同步已批准的目标

使用值但不返回值,只报告结果、耗时、目标和键名。

密钥值会去哪里?

AI 负责协调工作,可信的本地路径负责处理值。

  • AI 聊天和工具结果

    只接收状态、键名和下一步。不要把密钥值粘贴到聊天中。

  • 你的终端和本地进程

    第三方签发的值由你在本地输入,仅在获批准的进程需要时解密并注入。

  • manage-env 服务器

    只保存加密数据和不含值的元数据,不会收到打开保险库所需的明文值。

问题排查

找不到 menv 命令

把 $HOME/.local/bin 加入 PATH,打开新终端,再次运行 menv --version。

AI 看不到 menv 工具

在仓库根目录再次运行 menv connect,重启 AI 工具,并在提示时批准 menv MCP 服务器。

AI 说某个值需要你输入

在本地终端提示中粘贴该值,绝不要在聊天中回复这个值。

准备连接第一个仓库了吗?

个人账户免费。创建账户后回到这里复制配置提示词。

创建免费账户