rotate-api-keys
Rotate API Keys
Input Parameters
| Parameter | Required | Description | Example |
|---|---|---|---|
old_api_key |
Yes | The API key to be replaced (the old or compromised key) | sk-old-abc123 |
new_api_key |
Yes | The new API key to replace the old one with | sk-new-xyz789 |
target_directories |
No | Directories to search for .env files and keystores (defaults to home directory and common project paths) | ~/Herd ~/Code |
Procedure
-
Ask for the old and new API keys if not provided
-
Identify all target files — .env files, keystore files (
keys.json), and logs containing credentials:find {{SEARCH_PATH}} -name "*.env" -o -name "keys.json" -o -name "*.log" -
Create backups and replace the key in each file:
sed -i.bak "s|{{OLD_KEY}}|{{NEW_KEY}}|g" {{FILE_PATH}} -
Verify the replacement in a sample of updated files:
grep -o "sk-[a-zA-Z0-9-]*" {{FILE_PATH}} | head -1 -
Report a summary of all updated files, backup locations, and verification results
Notes
- Backups are created automatically using the
-i.bakflag before any changes - Verify replacements before confirming completion
- Revoke the old key in the API provider's dashboard after rotation
- Large log files may take time to process
Example
rotate my API key across all my projects and config files
replace my old OpenAI key with a new one in all .env files
update this API key everywhere it appears on my system
rotate my compromised API key across all config files and keystores
refresh my API credentials across my development environment
More from dalehurley/phpbot
desktop-control
Control the mouse, keyboard, and read screen content via accessibility. Use this skill when the user asks to click somewhere on screen, type text into an app, move the mouse, press keyboard shortcuts, read what's on screen, get the accessibility tree of the current window, automate desktop interactions, or control the computer.
39summarize-unread-emails
Retrieve and summarize all unread emails from your inbox, organized by category, sender, and date. Use this skill when the user asks to summarize unread emails, get an overview of unread messages, organize inbox emails, or review pending email communications. Provides a structured summary with categorization and timeline analysis.
20open-application
Open or launch applications on your computer by name. Use this skill when the user asks to open, launch, or start an application like Mail, Finder, Safari, Chrome, or any other installed macOS application. Works with both built-in and third-party applications.
10homebrew
Install, manage, and search for software packages on macOS using Homebrew. Use this skill when the user asks to install software, apps, CLI tools, developer utilities, programming languages, databases, or any package on a Mac. Supports formulae (CLI tools) and casks (GUI apps). Can also search, update, upgrade, uninstall, and diagnose Homebrew issues.
10csv-tools
Parse, query, filter, sort, transform, and summarize CSV and JSON data files. Use this skill when the user asks to view a CSV, filter data, get statistics from a data file, convert CSV to JSON or vice versa, sort data, or analyze tabular data.
9get-weather-forecast
Retrieve current weather conditions and multi-day forecasts for any location using the wttr.in API. Use this skill when the user asks for weather information, weather forecast, current conditions, temperature, or weather updates for a specific city or location. Provides detailed weather data including temperature, wind, precipitation, and visibility.
8