Keys Manager
A skill for managing API keys and secrets locally using the keys CLI tool.
Installation
The keys CLI must be installed first:
CODEBLOCK0
Or with Go:
CODEBLOCK1
Commands
Store a key
CODEBLOCK2
If the key already exists, the user is prompted to overwrite, edit, or cancel.
Retrieve a key
CODEBLOCK3
Browse keys interactively
CODEBLOCK4
Opens a TUI with fuzzy search, checkboxes, clipboard copy, and age indicators.
- -
space — toggle selection - INLINECODE3 — copy selected as INLINECODE4
- INLINECODE5 — copy selected as INLINECODE6
- INLINECODE7 — export selected to
.env file - INLINECODE9 — add a new key (when no matches found)
- INLINECODE10 — quit
Masked view
CODEBLOCK5
Same as see but values are hidden as ***. Press r to reveal individual keys. Useful for screen-sharing.
Edit a key
CODEBLOCK6
Opens a TUI editor. tab switches fields, enter saves, esc cancels.
Delete a key
CODEBLOCK7
Export keys
CODEBLOCK8
Import from .env
CODEBLOCK9
Parses .env files — handles comments, quotes, and export prefixes. Reports new vs updated counts.
Profiles
Isolate keys by project or environment:
CODEBLOCK10
All add, get, rm, see, and other commands operate within the active profile.
Inject keys into commands
CODEBLOCK11
Outputs keys as space-separated KEY=VAL pairs (or -e KEY=VAL with --docker) for use in command substitution.
Audit key access
CODEBLOCK12
Tracks when keys are accessed via get, inject, and expose. Useful for understanding which keys agents and scripts are using.
Check required keys
CODEBLOCK13
Reads key names from a file (one per line, # comments supported) and reports which are present or missing. Exits with code 1 if any are missing — useful for CI and agent pre-flight checks.
Example .keys.required:
CODEBLOCK14
Sync keys between machines
CODEBLOCK15
Peer-to-peer sync over the local network. Auto-discovers peers via mDNS (Bonjour), encrypted with a one-time passphrase (AES-256-GCM). Works over WiFi, Tailscale, or any reachable network. Smart merge: adds new keys, updates older ones, skips newer local ones.
Delete all keys
CODEBLOCK16
Requires typing nuke to confirm. Only affects the active profile.
Version
CODEBLOCK17
Authentication
On macOS, keys prompts for Touch ID before any command that accesses keys. Authentication is cached per terminal session — the first command triggers Touch ID, subsequent commands in the same shell skip the prompt.
Commands that skip authentication: profile, completion, version, help.
On non-macOS systems or when biometrics are unavailable, access is allowed without prompting.
Examples
Typical workflow
CODEBLOCK18
Multi-project setup
CODEBLOCK19
Quick export to shell
CODEBLOCK20
Guidelines
- - Always use
keys get <name> when the user knows the exact key name - Use
keys get (no args) when the user wants to search/pick interactively - Use
keys peek instead of keys see when the user is screen-sharing or wants masked output - Use
keys profile to separate keys across different projects or environments - Use
keys import for bulk loading from existing .env files - Suggest
keys env when the user needs to generate a .env file for a specific project - Use
keys inject when the user wants to pass keys directly to a command or Docker container without creating files - Use
keys audit to review which keys are being accessed and how often - Use
keys check before running agents to verify all required keys are available - Use
keys sync serve + keys sync pull to transfer keys between machines without cloud services
Keys Manager
使用 keys CLI 工具在本地管理 API 密钥和机密的技能。
安装
必须先安装 keys CLI:
bash
brew install stym06/tap/keys
或使用 Go 安装:
bash
go install github.com/stym06/keys@latest
命令
存储密钥
bash
keys add <名称> <值>
如果密钥已存在,系统会提示用户选择覆盖、编辑或取消。
检索密钥
bash
keys get <名称> # 直接打印值
keys get # 交互式自动补全选择器
交互式浏览密钥
bash
keys see
打开一个带有模糊搜索、复选框、剪贴板复制和时效指示器的 TUI 界面。
- - space — 切换选择
- tab — 将选中的复制为 KEY=VAL
- ctrl+y — 将选中的复制为 export KEY=VAL
- ctrl+e — 将选中的导出到 .env 文件
- enter — 添加新密钥(当没有匹配结果时)
- esc — 退出
掩码视图
bash
keys peek
与 see 相同,但值被隐藏为 *。按 r 键可显示单个密钥。适用于屏幕共享场景。
编辑密钥
bash
keys edit <名称>
打开一个 TUI 编辑器。tab 切换字段,enter 保存,esc 取消。
删除密钥
bash
keys rm <名称>
导出密钥
bash
keys env # 交互式选择器,写入 .env 文件
keys expose # 将导出语句打印到标准输出
从 .env 导入
bash
keys import <文件>
解析 .env 文件 — 处理注释、引号和 export 前缀。报告新增与更新的数量。
配置文件
按项目或环境隔离密钥:
bash
keys profile use <名称> # 切换配置文件
keys profile list # 列出所有配置文件(* 表示当前激活的)
所有 add、get、rm、see 和其他命令都在当前激活的配置文件中操作。
将密钥注入命令
bash
$(keys inject APIKEY DBHOST) ./my-script.sh # 内联环境变量
docker run $(keys inject -d APIKEY DBHOST) my-image # Docker -e 标志
$(keys inject --all) ./my-script.sh # 当前配置文件中的所有密钥
$(keys inject --all --profile dev) ./my-script.sh # 指定配置文件中的所有密钥
输出密钥为空格分隔的 KEY=VAL 对(或使用 --docker 时为 -e KEY=VAL),用于命令替换。
审计密钥访问
bash
keys audit # 摘要:每个密钥的访问次数 + 最后使用时间
keys audit --log # 完整访问日志(最近的在最前)
keys audit --log -n 20 # 最近 20 条事件
keys audit --clear # 清除审计日志
跟踪通过 get、inject 和 expose 访问密钥的时间。有助于了解代理和脚本正在使用哪些密钥。
检查必需的密钥
bash
keys check # 从当前目录读取 .keys.required
keys check reqs.txt # 自定义文件
从文件中读取密钥名称(每行一个,支持 # 注释),并报告哪些存在或缺失。如果有任何缺失,则退出代码为 1 — 适用于 CI 和代理预检检查。
示例 .keys.required:
代理依赖项
OPENAI_KEY
SERP
APIKEY
DATABASE_URL
在机器间同步密钥
bash
在机器 A 上(拥有密钥)
keys sync serve
正在从配置文件 default 提供 12 个密钥
密码短语:olive-quilt-haven
等待连接...
在机器 B 上(需要密钥)
keys sync pull # 通过 mDNS 自动发现
keys sync pull 192.168.1.10:7331 # 或直接连接
通过本地网络进行点对点同步。通过 mDNS(Bonjour)自动发现对等设备,使用一次性密码短语(AES-256-GCM)加密。适用于 WiFi、Tailscale 或任何可达网络。智能合并:添加新密钥,更新旧密钥,跳过本地较新的密钥。
删除所有密钥
bash
keys nuke
需要输入 nuke 确认。仅影响当前激活的配置文件。
版本
bash
keys version
keys --version
身份验证
在 macOS 上,keys 会在任何访问密钥的命令前提示使用 Touch ID。身份验证在每个终端会话中缓存 — 第一个命令触发 Touch ID,同一 shell 中的后续命令跳过提示。
跳过身份验证的命令:profile、completion、version、help。
在非 macOS 系统或生物识别不可用时,无需提示即可访问。
示例
典型工作流程
bash
keys add OPENAI_KEY sk-proj-abc123
keys add STRIPEKEY sktest_4eC3
keys get OPENAI_KEY
keys see # 浏览和复制
keys env # 为项目生成 .env
多项目设置
bash
keys profile use projectA
keys import .env
keys profile use projectB
keys add DB_HOST prod-db.example.com
keys profile list
快速导出到 shell
bash
eval $(keys expose)
使用指南
- - 当用户知道确切的密钥名称时,始终使用 keys get <名称>
- 当用户想要交互式搜索/选择时,使用 keys get(无参数)
- 当用户正在屏幕共享或想要掩码输出时,使用 keys peek 而不是 keys see
- 使用 keys profile 在不同项目或环境间隔离密钥
- 使用 keys import 从现有的 .env 文件批量加载
- 当用户需要为特定项目生成 .env 文件时,建议使用 keys env
- 当用户想要直接将密钥传递给命令或 Docker 容器而不创建文件时,使用 keys inject
- 使用 keys audit 审查哪些密钥正在被访问以及访问频率
- 在运行代理之前使用 keys check 验证所有必需的密钥是否可用
- 使用 keys sync serve + keys sync pull 在机器之间传输密钥,无需云服务