agent-rt

Local-first, agent-native developer tools.

View My GitHub Profile

Commands

secretctl ships 13 commands. Use secretctl --help for the inline summary.

Exit codes

Code Meaning
0 success
1 internal failure (oom, fs, decrypt)
2 usage error / policy reject / not found
126 exec child found but not executable
127 exec child not found
N exec child’s exit code (transparent passthrough)

init

secretctl init

Creates ~/.secretctl/{vault,master.key,config.toml} (all mode 0600). Prompts for a master password (Argon2id-derived wrapping key) and offers to enable the macOS Keychain protector.

Refuses to overwrite an existing master.key. Requires a TTY (set SECRETCTL_BATCH=1 to bypass for scripted setup).

add

secretctl add NAME [--tag X,Y] [--editor]

Adds a new secret. The value is never taken from a positional argument or stdin — only from a non-echoing TTY prompt or $EDITOR.

A trailing newline is stripped (matches editor save convention). The temp file is ftruncate(0) + unlink‘d on read-back.

edit

secretctl edit NAME

Open $EDITOR with the current plaintext. On save:

The decrypted plaintext lives in the temp file only for the editor’s lifetime. Same 0600 + ftruncate + unlink discipline as add --editor.

rm

secretctl rm NAME

Delete a secret by name (case-insensitive). Exits 2 if not found.

list

secretctl list [--json] [--tag X]

Without flags: colored table (NAME TAGS UPDATED).

With --json: stable schema for agents.

[
  {"name":"NPM_TOKEN","tags":["npm"],"created_at":1761859200,"updated_at":1761859200}
]

--tag X filters to secrets carrying tag X. No flag, ever, surfaces values.

exec

secretctl exec [--tag X] [--only N1,N2] -- COMMAND ARGS...

Decrypts the selected secrets, sets them as environment variables on the child, and forks COMMAND. The parent process zeroes every plaintext buffer before waitpid returns; the child’s exit code is passed through transparently.

Selection rules:

Policy enforcement (when .secretctl.toml is present in cwd or any ancestor):

# .secretctl.toml
[allow]
tags     = ["npm", "github"]
commands = ["npm", "yarn", "pnpm", "gh", "node"]

A line is appended to ~/Library/Logs/secretctl.log:

2026-04-30T03:35:41Z exec cmd=npm tags=npm cwd=/path/to/proj exit=0

Argv beyond argv[0] is never logged.

materialize

secretctl materialize NAME --out PATH [--mode MODE] [--mkdir]

Decrypt a single secret and write its value byte-for-byte to PATH. No trailing newline is appended (so SSH private keys round-trip cleanly). Default mode is 0600; --mkdir creates parent directories with mode 0700 if they don’t exist.

This is the primitive used by the Home Manager module to populate ~/.ssh/* and ~/.config/secretctl/env/* at activation time. See Nix integration for the declarative wrapper.

render

secretctl render TEMPLATE --out PATH

Reads TEMPLATE, replaces ${NAME} with the value of secret NAME, writes the result to PATH with mode 0600. Use $$ to emit a literal $. Refuses to overwrite an existing PATH.

Useful for .npmrc, .env, and any config tool that doesn’t read env vars at runtime.

mcp

secretctl mcp [--cwd PATH] [--allow-secret-read]

Start an MCP (Model Context Protocol) server on stdio. Three tools by default — list_secrets, check_secret_available, run_with_secrets. --allow-secret-read adds a fourth tool, get_secret, gated by per-call Touch ID; the server refuses to start without biometry hardware.

The same .secretctl.toml allowlist gates run_with_secrets as it does the CLI exec, so an agent can only execute commands you’ve explicitly trusted with the matching tags.

--cwd PATH overrides the project root used when looking up .secretctl.toml; defaults to the server’s current working directory.

key add-keychain-protector

secretctl key add-keychain-protector [--touch-id|--no-touch-id]

Append a new keychain protector to master.key for the current machine. Used when introducing a second Mac into a shared vault: clone the vault repo, run this command, then secretctl sync so the new protector entry reaches the other machines too. Each Mac ends up with its own random wrapping_key in its own local Keychain — no shared key material crosses the network. See Cross-Mac sync.

sync

secretctl sync

Run the git ceremony for ~/.secretctl/: git add -A, commit any local changes (with a vault: <hostname> <ts> message), git pull --ff-only, then git push. Audit log records the outcome.

Requires ~/.secretctl/.git to exist (you set this up once with git init + git remote add origin …). If the remote has commits you don’t have and you have local commits, the pull is aborted; resolve the conflict manually with git checkout --theirs/--ours vault.

reinstall-keychain

secretctl reinstall-keychain [--no-touch-id]

Rebuild the macOS Keychain protector. Existing keychain ACLs cannot be modified in place, so use this command after upgrading from a version of secretctl whose ACL doesn’t suit you (e.g. enabling Touch ID on a vault that was originally created with the trusted-app ACL, or vice versa).

reveal

secretctl reveal NAME

Print plaintext on the TTY. Refuses if stdout is not a TTY (so it cannot be silently captured to a file or piped to a logger). Logs op=reveal to the audit trail.

There is no --clipboard option in 0.1.x. Use secretctl reveal NAME | pbcopy if you really mean it (the TTY check rejects this; bypass via SECRETCTL_BATCH=1 only for trusted scripted setups).

Environment

Variable Effect
$VISUAL, $EDITOR Editor for add --editor and edit. Default vi.
$SECRETCTL_HOME Override ~/.secretctl (testing & multi-vault setups).
$SECRETCTL_BATCH =1 skips TTY enforcement on init, reveal, and password prompts (reads from stdin). For scripted setup; do not use on workstations.
$TMPDIR Where editor temp files live. Inherited from macOS shell.

Files

Path Mode Purpose
~/.secretctl/vault 0600 Encrypted secrets (single-file AEAD body).
~/.secretctl/master.key 0600 KDF parameters + protector container + HMAC.
~/.secretctl/config.toml 0600 Non-sensitive config (reserved for future).
~/Library/Logs/secretctl.log 0600 Append-only audit log.
$TMPDIR/secretctl-edit-* 0600 Editor temp file; lifetime = editor process.
.secretctl.toml (project) any [allow] policy block.