key

A command for explicitly saving an API key as a named protected secret. It replaces the value in the prompt with a reference to the saved file.

In plain words
What is it for?
Use it to register keys for services such as OpenAI or Stripe, then reference the saved secret when running commands.
Why use it?
It keeps the key out of the model context and session transcript while still making it available to later commands. It also supports custom tokens that automatic detection may not recognize.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/albemiglio/keyward/key
Clone the repo
git clone --depth 1 https://github.com/albemiglio/keyward
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 310 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 3 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.00310
Opus 5 $0.00014 $0.00155
Sonnet 5 $0.00005 $0.00062
Haiku 4.5 $0.00003 $0.00031

Measured yesterday against content hash 5e8e27069d2d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

key scanned grade C with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

`NAME=VALUE` pair, saves the value to `~/.claude/secrets/<NAME>.txt` (chmod 600), blocks the original prompt, and re-submits a sanitized version where the

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

export OPENAI_API_KEY=$(cat ~/.claude/secrets/openai.txt) && curl ...

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

export OPENAI_API_KEY=$(cat ~/.claude/secrets/openai.txt) && curl ...
commands/key.md · 39 lines

What it actually says

/key — explicit secret registration

Syntax: /key NAME=VALUE

When you type this, the Keyward UserPromptSubmit hook detects the NAME=VALUE pair, saves the value to ~/.claude/secrets/<NAME>.txt (chmod 600), blocks the original prompt, and re-submits a sanitized version where the value is replaced with <<secret:NAME stored at ~/.claude/secrets/NAME.txt>>.

The value never reaches the model context or the session transcript.

Examples

/key openai=sk-proj-abc...   then use it to call gpt-5
/key stripe=sk_live_xyz...   then process the test charge

The auto-detection regex also catches well-known key formats (sk-ant-, ghp_, AIza..., etc.) even without the /key prefix — explicit registration is only needed for custom or internal tokens not in the regex library.

Using a saved key

Reference it by path. Claude should always source it via:

export OPENAI_API_KEY=$(cat ~/.claude/secrets/openai.txt) && curl ...

…not cat alone (which prints the value into the bash output → model context).

Arguments: $ARGUMENTS

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 39 lines · 27 tokens per session scan C 5e8e27069d2d

Subscribe to this mod's changes

key is a command published in the GitHub repository albemiglio/keyward (1 stars, last pushed 19d ago), licensed MIT. It adds 27 tokens to every session and 310 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 3 findings (asks for root, reads agent configuration directories, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.