How to safely paste API keys to your agent prompt box
When an agent needs an API key, I create it on the relevant dashboard. From there, the lowest-friction move is to just paste the key into the chat. But secrets in prompts are bad practice: they’re sent to model providers’ servers and saved in session transcripts.
My flow:
- Copy the API key to the clipboard.
- Type
opadd [secret_name]into the prompt box.
What happens:
A
UserPromptSubmithook fires if any line begins withopadd.Clipboard contents are saved to a temporary file.
The secret is piped to the relevant
.envfile and a 1Password vault that my agent can access.
For the 1Password entry at step (3), the agent cleans the secret name (e.g. capitalisation) and—if the chat makes it clear—adds a note with API scope details.
The code is here.
