key

key is a command for Claude Code from albemiglio/keyward. It costs 27 tokens per session (310 once invoked), scanned C, original, MIT.

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 for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: reads .claude/ paths.

Part of the keyward plugin — 1 skill, 4 commands, 1 hook shipped together

Good fit Use it to register keys for services such as OpenAI or Stripe, then reference the saved secret when running commands.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/albemiglio/keyward/key
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.

Clone the repo
git clone --depth 1 https://github.com/albemiglio/keyward

Made for: Claude Code.

Or install keyward, the plugin that ships this one along with the rest of its 1 skill, 4 commands, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for key

README.md
[![agentmods](https://agentmods.dev/badge/commands/albemiglio/keyward/key/github.svg)](https://agentmods.dev/commands/albemiglio/keyward/key)
Your own site
<a href="https://agentmods.dev/commands/albemiglio/keyward/key"><img src="https://agentmods.dev/badge/commands/albemiglio/keyward/key/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for key

Your own site · 80×15
<a href="https://agentmods.dev/commands/albemiglio/keyward/key"><img src="https://agentmods.dev/badge/commands/albemiglio/keyward/key.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00027 $0.00310
Opus 5.5 $0.00011 $0.00124
Sonnet 5.5 $0.00005 $0.00062
Haiku 4.5 $0.00003 $0.00031

Measured 1mo ago against content hash 5e8e27069d2d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo ago.

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. 1mo ago 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 1mo ago), licensed MIT. It adds 27 tokens to every session and 310 once invoked, about $0.0001 per session on Opus 5.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.