saddlebag
Carry the right credentials for every ride.
saddlebag holds the secrets a QA run needs and puts each one where it is consumed, so
that an agent driving a workhorse workflow never holds a secret in its context. A
secret leaves the store in exactly three ways. fill types it into a field of a browser
over the Chrome DevTools Protocol. type types it into the focused field of an Android
device over adb. exec runs a command with it set in that command's process
environment. None of them hands the value back to whoever ran it. Around the
store, env reads a dotenv file with its secret lines masked, and guard is the
Claude Code hook that refuses the tool call which would have read a dotenv, key or
credentials file.
One daemon holds the HashiCorp Vault token, and every other command is a thin client
over a unix socket. That is what lets the same tool serve a run on the host and a run
in a container: the container sees the socket and nothing else.
Position in the ecosystem
| Tool |
Job |
| ostler |
Tends the knowledge graph: epics, stories, seeds, specs |
| farrier |
Fits the shared prompt library onto each repo |
| workhorse |
Runs the workflow graph unattended |
| saddlebag |
Carries secrets and fills them where they are consumed |
Ostler owns the spec of what a test needs and which environment it runs against.
Saddlebag owns the secret material that satisfies it. Ostler's stack bring-up asks
saddlebag for the variables a stack needs, as described under
The ostler stack.
Install
Saddlebag publishes to PyPI as stablemate-saddlebag, because the name saddlebag is
unavailable. The command and the import package stay saddlebag.
uv tool install stablemate-saddlebag
pipx install stablemate-saddlebag
The stablemate package installs it along with the other tools (uv tool install stablemate).
From a checkout of the stablemate workspace:
uv run --package stablemate-saddlebag saddlebag --help
Requires Python ≥ 3.12 and a reachable HashiCorp Vault with a KV v2 mount named
secret. For a developer machine, vault server -dev is enough.
Sixty seconds
# 1. Start the daemon. The token arrives on stdin and stays in the daemon's memory.
export VAULT_ADDR=http://127.0.0.1:8200
printf '%s' "$VAULT_TOKEN_FROM_YOUR_LOGIN" | saddlebag serve
# 2. In another shell: describe a secret, then give it its value on stdin.
saddlebag secret create normal_login \
--username gab \
--description "Log in as a normal user" \
--var LOGIN_PASSWORD \
--tag environment=local --tag role=user
printf '%s' "$PASSWORD" | saddlebag secret set normal_login
# 3. An agent finds it by tag and reads the description. No value is printed.
saddlebag list --tag environment=local
# 4. Deliver it. Into a browser field, or into a command's environment.
saddlebag fill normal_login --field username --selector "#login_field" --url-contains example.com
saddlebag fill normal_login --field password --selector "#password" --url-contains example.com
saddlebag exec --tag environment=local -- docker compose up
The browser the fourth step talks to is one you started with a debugger port:
chromium --remote-debugging-port=9222 --user-data-dir=/tmp/qa-profile
Saddlebag connects only to a DevTools endpoint on loopback and refuses any other
host. That port is unauthenticated and grants total control of the browser.
The daemon
saddlebag serve is the one process that talks to Vault. It reads the token from
stdin when piped, else from the OS keyring where saddlebag serve --keep-token stored
it, else from saddlebag/vault-token under the stablemate state dir when that file is
mode 0600. It refuses to start if VAULT_TOKEN is set in its environment, and listens
on a unix socket created with owner-only permissions. Every other verb connects to
that socket, sends one request and reads one reply.
|
|
| Backend |
$SADDLEBAG_BACKEND (keyring or daemon), else backend under [saddlebag] in the shared stablemate config.toml, else a daemon that answers on the socket, else the OS keyring |
| Socket path |
$SADDLEBAG_SOCKET, else $XDG_RUNTIME_DIR/saddlebag.sock, else the OS runtime dir |
| Vault address |
$VAULT_ADDR or --vault-addr |
| Browser |
--cdp, default http://127.0.0.1:9222 |
saddlebag never puts the token in an environment variable, because a process of the
same user can read /proc/<pid>/environ. The kept token lives in the OS keyring. The
filed token is the operator's choice, and doctor warns about it because any file the
user owns is readable by their other processes. For the same reason the operator's own
Vault login must not leave ~/.vault-token behind, and doctor warns when that file
exists.
A run in a container
Mount the socket and name it. The client inside the container talks to the daemon
on the host, which is also where the browser and its debug port live.
docker run \
-v "$SADDLEBAG_SOCKET:/run/saddlebag.sock" \
-e SADDLEBAG_SOCKET=/run/saddlebag.sock \
...
Secrets and tags
A secret has a name, an optional username, a description an agent reads to choose
between candidates, an optional var naming the environment variable exec fills it
into, a set of key=value tags, and a map of printable metadata such as a phone number
or a role, given with --meta key=value and changed later with secret meta and secret unmeta. It holds up to two values: a password and a totp enrolment seed. The
username and the metadata may print. The two values never do.
{
"name": "normal_login",
"username": "gab",
"description": "Log in as a normal user",
"var": "LOGIN_PASSWORD",
"tags": [["environment", "local"], ["role", "user"]],
"metadata": {"phone": "+15555550100"},
"fields": ["password"]
}
Tags are the whole query vocabulary. list --tag environment=local --tag role=admin
returns the secrets carrying both pairs. tags lists the distinct pairs in use. The
convention the ostler integration relies on is that a secret for a QA environment
carries environment=<slug>, the tag the stack root's secrets: saddlebag: names.
Commands
|
|
serve |
run the daemon; token from stdin, the OS keyring or a 0600 file; --keep-token stores one |
list tags |
query by tag; neither can emit a value |
secret create edit set unset remove tag untag meta unmeta |
manage a secret; edit changes its username, description or var, and an empty value clears one; set reads its value from stdin; meta K=V adds or overwrites printable metadata, unmeta KEY drops it |
fill |
type a secret's username, password or current TOTP code into a browser field |
type |
type a secret's username, password, current TOTP code or metadata value into the focused field of an Android device |
exec |
run a command with matching secrets in its environment |
env show keys classify |
read a dotenv file with its secret values masked, list its keys with the rule that marks each secret one, or print the verdicts as JSON |
env import |
store a dotenv's chosen keys as secrets, one record per key, without printing a value |
env set |
assign a value to a key in a dotenv when neither the line nor the value is secret |
export import |
write the whole store with its values to a plaintext JSON file, from a terminal only, and load such a file back |
guard --hook guard install |
the Claude Code PreToolUse hook that denies a read of a dotenv, key, credentials or export file, and its installer |
doctor |
backend and route in use, store reachable, secrets with no value, orphan keyring items, stray token file, and on the daemon route where its token came from |
saddlebag fill NAME --field username|password|totp --selector S [--url-contains X]
saddlebag type NAME [--field username|password|totp|meta.KEY] [--device SERIAL]
saddlebag exec [--tag k=v]... [--env VAR=NAME[.field|.meta.KEY]]... -- cmd args...
saddlebag env show|keys|classify FILE [--json]
saddlebag env import FILE --keys KEY[,KEY...] [--tag k=v]... [--prefix TEXT] [--json]
saddlebag env set FILE KEY VALUE
saddlebag export FILE.saddlebag.json
saddlebag import FILE [--replace] [--json]
saddlebag guard install --user|--project
exec fills each tag-matched secret's var with its password. An explicit
--env VAR=NAME.field binding may name any field, including the username, the
current TOTP code and a metadata key as NAME.meta.KEY. A secret matched by tag that has no var is an error naming it,
not a silent skip.
What each verb guarantees. fill reports a character count, a selector and a URL.
The value is typed through Input.insertText and never interpolated into an evaluated
expression. A TOTP seed leaves the store only as a computed six-digit code, and only
by being typed. type reports a character count, a device and a field id. It covers
Android only, and iOS has no such verb. docs/SECURITY.md states what the device itself
can see. exec masks what the command prints when its output goes to a pipe,
which is how an agent's tool call runs it. Saddlebag stays as the command's parent and
copies its stdout and stderr through, with each secret value replaced by [REDACTED].
It masks the value as written and in the forms tools escape it into: compose's $$,
URL encoding and JSON string escaping. It looks for no other encoding, such as base64.
A value shorter than 8 characters is not masked, and exec names its variable in a
warning on stderr. A username bound with --env is metadata and is not masked. When
stdout and stderr are both a terminal, exec becomes the command and masks nothing,
so colors, -it and progress bars keep working for a person at the keyboard.
Masking catches the leak an agent makes by mistake, such as running
docker compose config under exec. It does not stop a command written to leak, and
it does not reach what the command writes to a file. Saddlebag itself writes a value to
disk only in a file the operator asked export for. The agent's permission layer
decides which commands it may run under exec.
A dotenv file
A .env mixes literals with secrets, so reading it is the commonest way a value lands
in an agent's context. env show FILE prints the file with each secret value replaced
by [REDACTED], and ends with masked N of M values. env keys FILE prints one key
per line and marks each secret one with the rule that caught it. env classify FILE
prints KEY<TAB>literal or KEY<TAB>secret:<rule> per line, or the same as JSON with
--json. FILE may be - for stdin.
The store decides which lines are secret. A line is secret when the store already
holds its value (held-value), when its value is a URL carrying user:password@
(url-userinfo), when its value has the shape of a vendor token or a PEM block
(token-shape), or when its name says so (key-name: a part such as TOKEN,
SECRET, PASSWORD or API_KEY, with PUBLIC names exempt). The rules are
deliberately few and name-first: a literal the rules miss prints in the clear.
env import FILE --keys K[,K...] moves the chosen keys into the store, one record per
key: the key becomes the record's var, the record is named <prefix> plus the key
lowercased with _ as -, and every record carries the --tag pairs. It prints
stored KEY as NAME per key and never a value. A key the file lacks or an empty value
stops it before any write; a record name already in use stops it at that key, and the
keys before it stay stored.
env set FILE KEY VALUE changes a literal in place. It sets every assignment of KEY
and keeps each line's export, spacing, trailing comment and line ending, or appends
KEY=VALUE when the file has none. It quotes VALUE only as much as a dotenv reader
needs to read it back unchanged. It asks the store to classify the current line and the
new value first, and refuses with exit 2 when either is secret, leaving the file
untouched. A secret stays the operator's to edit, or goes into the store and reaches
its consumer through exec. It prints set KEY in FILE or added KEY in FILE and
never a value.
Moving a store