Agentuna Agentuna
Build an agent

Recipe · Build apps (vibe coding)

How to rotate and check the tokens your AI agents use

List the API keys and tokens your AI agents and their tools can reach, replace them with new ones that have the fewest permissions and an expiry date, and revoke the old ones, following GitHub's and OpenAI's own guidance.

Not tested yet. Vote for it to be next ⏱ ~20 min Updated: 2026-11-08

Jump to the prompt

Steps

  1. Make a list of where keys live: agent config files (MCP server entries, .env files), your shell profile, CI secrets, and any tool your agent can call. Write down the name of each key, not its value.
  2. For each key, create a replacement first. OpenAI's guidance: create the new key, update your apps to use it, check the replacement works, then revoke the old key. Give the new key an expiry date where the service supports it.
  3. Keep permissions small. GitHub says to pick the minimum scopes, set the shortest expiry you need, and prefer fine-grained personal access tokens over classic ones.
  4. Move keys out of code. GitHub and OpenAI both say never to commit keys to a repository, even a private one; use environment variables or a secret manager instead.
  5. Revoke the old key in each service's own dashboard, then run your agent once to confirm nothing still uses it.
  6. If a key may have leaked, GitHub says deleting it from the code isn't enough: generate a new one, replace it everywhere, and delete the old one. OpenAI says to rotate right away and review your usage.
  7. Put a reminder in your calendar to repeat this on a schedule you can keep.

Prompt

Replace anything in { } with your details.

Copy & paste
Help me rotate the API keys my AI agents use. Don't ask me for any key values. First, list the places on this machine where keys are usually kept (agent config and MCP entries, .env files, shell profile, CI secrets) and show me how to list key NAMES only. Then, for each service, give the replace, check, revoke order and where in that service's dashboard to set an expiry date and minimum permissions.

Expected output

A list of every key your agents use, each replaced with a scoped, expiring key, and the old keys revoked.

Gotchas

  • ⚠ Steps quote GitHub Docs and OpenAI's developer docs as checked on 2026-11-08. We cite only those vendors.
  • ⚠ Never paste a key's value into a chat with an AI agent, including this prompt. Use names like OPENAI_API_KEY instead.
  • ⚠ Revoking before the replacement works can break a running agent; replace, check, then revoke.
Where these tools break
  • The limit, from Claude Code’s page: Claude Code draws from the same pool as Claude chat: Pro ($20/mo) and Max ($100/mo, 5x Pro) each have a 5-hour session cap plus a weekly cap, while Ultra ($200/mo, 10x Pro… (support.claude.com, checked )
  • Known problem with Claude Code: Fake extension copies on Cursor's marketplace (29 Oct) (, cursor.com)
  • Watch out with Claude Code: Claude Code is not on the free Claude plan; it uses your Pro or Max usage limits, and a batch of photos burns through them faster than text. Do 30 to 50 receipts at a time. From a recipe
  • Real example with Claude Code: Burned a 5-hour Claude Max quota in 30 minutes via subagent file reads vs Spotify's 90% token-reduction harness. The catch: Self-reported developer post on X (24 Oct 2026) and architectural summary of Spotify's engineering setup; token savings depend on codebase size and subagent… (source dated )

All notes for Claude Code

Sources (3): public reports, not re-tested by us

GitHub Docs: Keeping your API credentials secure (checked 2026-11-08) GitHub Docs: Remediating a leaked secret (checked 2026-11-08) OpenAI Docs: API keys and service accounts (checked 2026-11-08)

Real examples All real examples

What people actually did with these tools or for this problem, with the source.

Build apps (vibe coding) Not tested yet

Cap Cursor on-demand spend before it surprises you

Set a monthly limit on the paid usage Cursor bills after your included usage runs out, using Cursor's own settings, so an AI agent can't run up a bill you didn't plan for.

  • Cursor

8 min · Free to start · Copy-paste prompt

Build apps (vibe coding) Not tested yet

Slow Claude Code token burn: idle compaction, resume warnings and /rate-limit-options

Cut wasted weekly and 5-hour Claude Code usage by turning on Anthropic's idle compaction, heeding the Pro/Max resume warning, starting fresh sessions instead of reprocessing a huge idle thread, and stopping unattended sessions from burning the limit after you walk away.

  • Claude Code

15 min · From $20/mo · Agent template

Build apps (vibe coding) Not tested yet

Check Claude Code's local settings file for secrets

Find whether a "Yes, and don't ask again" approval saved a command that holds a secret in .claude/settings.local.json, rotate any key first, then untrack the file and stop it being committed.

  • Claude Code

15 min · From $20/mo · Copy-paste prompt