Expand description
safe-chains config: read and change ~/.config/safe-chains.toml without opening it.
The file decides what safe-chains approves, so changing it by hand is where things go wrong: a
hand-written grant has let head ~/.ssh/id_rsa through. These operations change
one rule at a time, keep the rest of the file exactly as it was, refuse anything a built-in rule
protects, and refuse to write a file safe-chains could not load.
Nothing here approves itself. The classifier treats safe-chains config add, remove and
grant like any other write (see commands/tools/safe-chains.toml), so a person approves each
one, and the MCP server marks the same operations destructive.
Each operation reads the file afresh. The hook’s registry and grants are loaded once per process, which is right for a process that classifies one command and exits, and wrong for a long-lived MCP server, so the server runs these through the CLI rather than calling them in-process.
Enums§
- Access
- Which faces a grant opens.
- Edit
Error - What a
configoperation could not do. Every message says what was wrong, what would work instead, and that nothing changed. - Protected
- Why a path cannot be granted from a command.
- Step
- Something the reader can do next, named the way the surface they are using spells it.
Constants§
- SHOWN_
PATH - Where the user config lives, written the way every message shows it.
Functions§
- add_
entry - Add an entry that approves
commandas it was written, atlevel(inert,safe-read,safe-write). Returns what to tell the person. - agent_
commands - The commands that run an AI coding agent.
- entry_
level - The level an added entry gets, as the CLI spells it and as the file spells it.
- grant
- Grant
accesstopath, merging with a grant already on that path. - grantable_
path pathassafe-chains config grantwould write it, or why that command would refuse it.- list
- The listing, ready to print. Reads the files afresh every call.
- remove_
command - Remove the command entry named
name. - remove_
grant - Remove the grant on
path. - runs_
an_ agent - Whether
nameruns an AI coding agent, which no entry may approve. - step
- user_
config_ path ~/.config/safe-chains.tomlunder$HOME. The same rule as the loader: neverXDG_CONFIG_HOME.