Skip to content

Secrets

Never put a credential in a config file. Reference it instead:

~/.agentsync/mcp/github.toml
[server.env]
GITHUB_TOKEN = "${secret:github.token}"

${secret:…} is resolved at apply time from an age-encrypted vault and written into native config. ${env:…} pulls from the environment. The resolved value is never captured back into your source — agentsync diff even redacts it so a piped diff can’t leak it.

The vault is encrypted to a recipient (public key — safe to commit); decryption needs the identity (private key — per-machine). agentsync embeds age, but generating the key uses the age-keygen CLI.

  1. Install age (for age-keygen): brew install age, apt install age, …

  2. Generate a keypair:

    Terminal window
    mkdir -p ~/.config/agentsync
    age-keygen -o ~/.config/agentsync/age.key # prints "Public key: age1…" to stderr
    chmod 600 ~/.config/agentsync/age.key # agentsync refuses a group/other-readable identity
  3. Point agentsync.toml at itrecipient is the age1… public key that age-keygen printed:

    ~/.agentsync/agentsync.toml
    [secrets]
    backend = "age"
    recipient = "age1…"
    identity_file = "${env:HOME}/.config/agentsync/age.key"

agentsync secrets set accepts the value three ways:

Terminal window
agentsync secrets set github.token --stdin # from stdin (best for scripts / 1Password CLI)
agentsync secrets set github.token # interactive prompt, echo off
agentsync secrets set github.token=ghp_… # back-compat; warns — argv is visible to ps(1)
Terminal window
agentsync secrets edit # open the whole vault in $EDITOR
agentsync secrets get github.token # read one back (to verify)

The dangerous bug class is a resolved cleartext secret being persisted back into your canonical source — often a committed dotfiles repo. agentsync makes this hard to do by accident with several tiers of defense, including a compile-time guarantee (the resolved model is a distinct type that source writers literally cannot accept) and a fail-closed backstop in the capture path that refuses to write rather than risk persisting a credential.