A key that never changes is a key that is probably known to someone who left. Rotation limits how long a leaked key is useful.
When to rotate
- At once when a key may have been exposed: pasted in a chat, committed, logged.
- When someone with access leaves the team.
- On a schedule that matches the risk, for example every few months for powerful keys.
A procedure without downtime
- Create the new key next to the old one.
- Deploy the new key to every place that uses it.
- Check from logs that the old key is no longer used.
- Revoke the old key.
- Record the date and the next rotation.
Make it easier
- Keep an inventory: what the key is for, who owns it, where it is stored.
- Give each service its own key, so revoking one does not break the rest.
- Scope keys narrowly and set low limits on development keys.
- Store keys in a secret manager and read them at run time.
Personal keys for agents
In Contextingo each person connects Claude Code or Codex with their own personal key, which can be revoked on its own. Related: keeping secrets out of the agent’s context.