Keep your access keys in one place with csec
In short
An access key is a long password that lets software use an online service, such as email or an AI model. Your AI agent and the hands of ahh need them. Keys often end up pasted into chats, notes or files. csec keeps them in one encrypted file on your computer. A tool asks csec for a key when it needs one.
You do not have to type the install commands. Paste the setup instructions to an AI agent that can work on your computer, such as Claude Code or Claude Cowork. They ask the agent to show you each command and wait for your OK. You do one thing yourself: type each key into a terminal window with csec set. Nothing appears on screen while you type. Never paste a key into the chat.
Limits: any program running under your account, including your agent, can ask csec for a key. csec protects stored keys; it does not decide who may use them. The setup instructions tell your agent not to fetch keys itself, because a fetched key can show up in its chat. ahh takes its keys from csec directly. Deleting a key from csec does not switch it off. To stop a leaked key, cancel it with the service that issued it.
You are done when csec version shows a version and csec ls lists your key's name.
1. Install
The installer downloads csec from csec.limbs.dev and runs it on your computer. This first installation is the one step where you rely on the download source. Later updates are accepted only if they carry a digital signature that matches the installed tool.
macOS or Linux
curl -fsSL https://csec.limbs.dev/install | bash
Windows PowerShell
irm https://csec.limbs.dev/install.ps1 | iex
On macOS and Linux, if needed, the installer adds a few marked lines to your shell profile (~/.zshrc on a Mac, ~/.profile on Linux) so the terminal can find csec; open a new terminal window afterwards. To undo it, delete the marked block, from # >>> csec >>> to # <<< csec <<<, including those two lines. Then check that it works:
csec version
2. Save a key
First get a key from the service you want to use. The tool that needs it tells you which name to save it under. Then type, replacing SERVICE_API_KEY with that name:
csec set SERVICE_API_KEY
csec asks for the value. Paste or type it and press Enter. Nothing appears on screen while you type; that is normal. Keep the value out of chats, project files and the command itself.
To see which names are saved, without showing the values:
csec ls
3. Connect the tool that needs it
Follow that tool's setup. ahh, for example, takes the keys it needs from csec by name. A tool that does not know csec needs an extra step to fetch the key.
csec get NAME shows the key itself. Use it only where you mean the value to be visible, and do not paste its output into a chat or a shared report.
4. Replace or remove a key
Run csec set SERVICE_API_KEY again to replace a saved value. To remove it from this computer:
csec rm SERVICE_API_KEY
Removing a key from csec does not cancel it. If a key leaked or is no longer needed, cancel it with the service that issued it. If you use sync, a later sync can bring a removed key back; see the reference below.
Before you rely on it
- Encryption protects stored keys. Programs running under your account can still ask for them. If someone else controls your computer, csec cannot keep your keys safe.
- When csec checks for updates, it sends the publisher your computer name, user name, system type and csec version, and the server sees your IP address. To turn automatic checks off, set
CSEC_UPDATE_DISABLE=1. - If something fails, read the error before changing anything. A missing or unreadable key does not mean the encrypted store should be deleted. Keep the store and any recovery material while you look into it.
You are done. Next: install ahh. Its hands take their keys from csec.
For developers: sync, conflicts and reference
You can stop here if you only need the basics. The installed tool's help, csec --help, describes the commands in your version.
Save a multiline value
For a PEM key, JSON configuration or another multiline value, read a private local file instead of putting its contents in an argument:
csec set SERVICE_CONFIG < config.json
This preserves internal line endings and removes exactly one final LF or CRLF. The local input limit is 1 MiB after that removal. An oversized value or a read failure is refused without saving partial input. Keep the source file private; storing its contents does not remove it. Local input capacity is separate from the shared 640 KiB repository publication limit described below. Check installed help for this input mode.
Use the same keys on another computer
This optional setup uses a dedicated private GitHub repository containing encrypted, signed snapshots. Install Git and GitHub CLI on each computer, then authenticate with gh auth login. On the first computer:
csec sync setup
Save the repository name and the generated 24-word recovery phrase somewhere private and separate from the computer. The phrase is shown during setup; do not put it in chat or a shared log. On another computer, use the repository name printed by setup:
csec sync join OWNER/REPOSITORY
Enter the recovery phrase when prompted. Run csec sync on each computer when you want to publish or retrieve changes; synchronisation is explicit. For conflicts, history, restore, rotation and encrypted offline export/import, read csec sync help.
Ordinary changes made on only one side sync automatically. Different edits to the same key need a choice between this machine and the repository. The prompt describes changes since the last sync and the available remote block time, without showing value fragments. Older snapshots do not record a writer name, and the local store does not record a separate edit time for each key. A checkpoint time may be later than the original edit. Skipping a conflict keeps each side's value while unrelated changes continue.
Removal affects this computer only. With synchronisation enabled, a later sync can restore the value from another snapshot. Replace revoked keys with their new values and synchronise every client.
Choose a side for each conflict
For an intentional scripted resolution, select the local value of one key and the repository value of another:
csec sync --resolve-key API_KEY=local --resolve-key DATABASE_URL=remote
The arguments contain names and choices, not secret values. --resolve local|remote|skip supplies a policy for remaining conflicts. Skipped conflicts remain open and return exit 1 while unrelated changes can still synchronise. Check csec sync status and the reported pulled, published, conflicted and restored counts before treating reconciliation as complete. Use the current binary on every client; an upgraded client without a recorded merge base may need an initial choice.
Keep all clients updated. Older clients cannot read the current repository metadata format. SSH/SFTP synchronisation and the old --migrate setup flag are no longer supported; their old files are left untouched.
A legacy client may have published a name that current clients cannot store. Current sync skips such names with a warning and keeps reading the valid entries. Use csec sync repair-names --dry-run to preview a clean checkpoint, then csec sync repair-names to publish it. This keeps the local store, recovery phrase and retained history. Upgrade every writer so an old client does not reintroduce those names.
Repository capacity applies to the whole signed snapshot: 640 KiB including JSON encoding, signature and metadata. There is no fixed per-key allowance. A larger value can be kept locally; set and import warn when the cached sync configuration shows it cannot publish. csec sync status shows current publication usage, and an oversized outgoing snapshot still permits incoming changes. Reduce the named largest entries before retrying publication.
Keep an encrypted offline copy
After repository sync is configured, export a snapshot to a new file:
csec sync export backup.age
Keep the archive and recovery material in separate safe places. On a computer that has joined the same repository, merge an archive back with:
csec sync import backup.age
The archive contains encrypted values, but cannot recover them without the matching identity. Keep the repository and recovery phrase available, and retain the recovery material needed by older archives when rotating keys. Import merges values rather than deleting names absent from the archive.
Storage and diagnostics details
- On Linux without a desktop keyring, a file restricted to your account holds the master key. Disk encryption remains useful.
- Do not copy
store.encalone to another computer: its master key stays on the original machine. A copy ofstore.encby itself is not a portable backup. - Current repository conflict prompts show names and change metadata, not value suffixes or lengths. Legacy archive conflict diagnostics and older clients can still reveal the final four characters and length of longer values. Some history fingerprints can help test guesses for weak values if the rest of a snapshot is known. Keep diagnostics private and review them before sharing.
- If repository sync was configured, an intact repository and its recovery phrase let a new computer join. Without a working local key or a usable backup and its recovery material, csec cannot reconstruct lost secrets.