safe-chains 0.35.0

Auto-allow safe, read-only bash commands in agentic coding tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# Supported Commands

Auto-generated by `safe-chains --list-commands`.

Any command with only `--version` or `--help` as its sole argument is always allowed.

## Unconditionally Safe

These commands are allowed with any arguments.

| Command | Description |
|---------|-------------|
| `arch` | Print machine architecture |
| `b2sum` | BLAKE2 checksum |
| `base64` | Base64 encode/decode |
| `basename` | Strip directory from path |
| `bat` | Syntax-highlighted cat |
| `bc` | Calculator |
| `branchdiff` | Branch diff tool |
| `cal` | Display calendar |
| `cat` | Print file contents |
| `cd` | Change directory |
| `cksum` | File checksum |
| `cloc` | Count lines of code |
| `colordiff` | Colorized diff |
| `column` | Format into columns |
| `comm` | Compare sorted files |
| `command` | Run command or check existence |
| `cucumber` | BDD test runner |
| `cut` | Extract fields from lines |
| `date` | Display date and time |
| `delta` | Syntax-highlighted diff viewer |
| `df` | Disk free space |
| `diff` | Compare files |
| `dig` | DNS lookup |
| `dirname` | Strip filename from path |
| `du` | Disk usage |
| `dust` | Disk usage viewer |
| `echo` | Print text |
| `exa` | Modern ls replacement |
| `expand` | Convert tabs to spaces |
| `expr` | Evaluate expression |
| `eza` | Modern ls replacement |
| `factor` | Print prime factors |
| `false` | Return failure exit code |
| `fd` | Find files |
| `file` | Detect file type |
| `fmt` | Reformat text |
| `fold` | Wrap lines |
| `getconf` | Get system configuration values |
| `grep` | Search file contents |
| `groups` | Print group memberships |
| `head` | Print first lines |
| `hexdump` | Display file in hex |
| `host` | DNS lookup |
| `hostname` | Print hostname |
| `htop` | Interactive process viewer |
| `iconv` | Convert character encoding |
| `id` | Print user/group IDs |
| `identify` | ImageMagick identify |
| `ifconfig` | Network interface info |
| `ioreg` | macOS I/O Registry viewer |
| `iotop` | I/O usage monitor |
| `jq` | JSON processor |
| `last` | Show login history |
| `lastlog` | Show last login for all users |
| `locale` | Print locale info |
| `ls` | List directory |
| `lsof` | List open files |
| `md5` | MD5 checksum (macOS) |
| `md5sum` | MD5 checksum |
| `mdfind` | Spotlight search (macOS) |
| `mdls` | File metadata (macOS) |
| `netstat` | Network connections and statistics |
| `nl` | Number lines |
| `nm` | List object file symbols |
| `nproc` | Print number of CPUs |
| `nroff` | Text formatter |
| `nslookup` | DNS lookup |
| `od` | Octal dump |
| `otool` | Object file tool (macOS) |
| `paste` | Merge lines of files |
| `pgrep` | Search for processes |
| `printenv` | Print environment variables |
| `printf` | Format and print text |
| `procs` | Modern process viewer |
| `ps` | List processes |
| `pwd` | Print working directory |
| `readlink` | Resolve symlink |
| `realpath` | Resolve path |
| `rev` | Reverse lines |
| `rg` | Ripgrep search |
| `route` | Routing table |
| `safe-chains` | Safe command checker |
| `seq` | Print number sequence |
| `sha1sum` | SHA-1 checksum |
| `sha256sum` | SHA-256 checksum |
| `sha512sum` | SHA-512 checksum |
| `shasum` | SHA checksum |
| `shellcheck` | Shell script linter |
| `size` | Object file section sizes |
| `sleep` | Pause execution |
| `ss` | Socket statistics |
| `stat` | File status |
| `strings` | Find printable strings in binary |
| `sum` | File checksum |
| `sw_vers` | macOS version info |
| `system_profiler` | macOS hardware/software info |
| `tac` | Print file in reverse |
| `tail` | Print last lines |
| `test` | Evaluate conditional expression |
| `tokei` | Code statistics |
| `top` | Process monitor |
| `tr` | Translate characters |
| `tree` | Directory tree |
| `true` | Return success exit code |
| `tty` | Print terminal name |
| `type` | Identify command type |
| `uname` | System information |
| `unexpand` | Convert spaces to tabs |
| `uniq` | Filter duplicate lines |
| `unset` | Unset environment variables |
| `uptime` | System uptime |
| `uuidgen` | Generate UUID |
| `vm_stat` | Virtual memory statistics |
| `w` | Show logged-in users and activity |
| `wc` | Count lines/words/bytes |
| `whereis` | Locate binary, source, and man page |
| `which` | Locate command |
| `who` | Show logged-in users |
| `whoami` | Print current user |
| `whois` | Domain registration lookup |
| `xxd` | Hex dump |

## Handled Commands

These commands are allowed with specific subcommands or flags.

### `asdf`

Subcommands: current, help, info, list, plugin list, plugin-list, plugin-list-all, version, which. Flags: --version.

### `awk / gawk / mawk / nawk`

Safe unless program contains system, getline, |, >, >>, or -f flag (file-based program).

### `bash / sh`

Allowed: --version, --help. Only `bash -c` / `sh -c` with a safe inner command. Scripts denied.

### `brew`

Subcommands: casks, cat, config, deps, desc, doctor, formulae, home, info, leaves, list, log, outdated, search, shellenv, tap, uses. Flags: --prefix, --version.

### `bun`

Subcommands: outdated, pm bin, pm cache, pm hash, pm ls, test.

Flags: --version.

x delegates to bunx logic.

### `bundle`

Subcommands: check, info, list, show.

Flags: --version.

Guarded: exec (brakeman, cucumber, erb_lint, herb, rspec, standardrb only).

### `bunx`

Allowed packages: @herb-tools/linter, eslint, karma.

Guarded: tsc (requires --noEmit).

Skips flags: --bun/--no-install/--package/-p.

### `cargo`

Subcommands: audit, bench, build, check, clippy, deny, doc, license, locate-project, metadata, pkgid, read-manifest, search, test, tree, verify-project.

Flags: --version.

Guarded: fmt (Requires: --check), package (Requires: --list), publish (Requires: --dry-run. Denied: --force, --no-verify).
+toolchain selectors (e.g. +nightly, +stable) are skipped.
Any subcommand with --help is safe (unless -- separator is present).

### `cmake`

Allowed: --version, --system-information (single argument only).

### `codesign`

Requires: --display, --verify, -d, -v. Denied: --force, --remove-signature, --sign, -f, -s.

### `composer`

Subcommands: about, audit, check-platform-reqs, diagnose, fund, help, info, licenses, outdated, show, suggests. Flags: --version.

### `conda`

Subcommands: info, list.

Flags: --version.

Guarded: config (--show, --show-sources only).

### `csrutil`

Subcommands: authenticated-root, report, status.

### `defaults`

Subcommands: domains, export, find, read, read-type.

### `deno`

Subcommands: check, doc, info, lint, test.

Flags: --version.

Guarded: fmt (requires --check).

### `diskutil`

Subcommands: activity, apfs list, apfs listCryptoUsers, apfs listSnapshots, apfs listVolumeGroups, info, list, listFilesystems.

### `docker / podman`

Subcommands: buildx --version, buildx inspect, buildx ls, buildx version, compose --version, compose config, compose images, compose ls, compose ps, compose top, compose version, container diff, container inspect, container list, container logs, container ls, container port, container stats, container top, context inspect, context ls, context show, diff, history, image history, image inspect, image list, image ls, images, info, inspect, logs, manifest inspect, network inspect, network ls, port, ps, stats, system df, system info, top, version, volume inspect, volume ls. Flags: --version.

### `dotnet`

Subcommands: build, list, test. Flags: --info, --list-runtimes, --list-sdks, --version.

### `env`

Strips flags (-i, -u) and KEY=VALUE pairs, then recursively validates the inner command. Bare `env` allowed.

### `find`

Safe unless dangerous flags: -delete, -ok, -okdir, -fls, -fprint, -fprint0, -fprintf. -exec/-execdir allowed when the executed command is itself safe.

### `fnm`

Subcommands: current, default, list, ls-remote. Flags: --version.

### `gem`

Subcommands: contents, dependency, environment, help, info, list, outdated, pristine, search, sources, specification, stale, which. Flags: --version.

### `gh`

Subcommands attestation, cache, codespace, extension, gpg-key, issue, label, pr, release, repo, run, ssh-key, variable, workflow are allowed with actions: checks, diff, list, status, verify, view, watch.

Always safe: --version, search, status.

Guarded: auth (status, token only), browse (requires: --no-browser), api (GET only, no body flags).

### `git`

Subcommands: blame, cat-file, check-ignore, count-objects, describe, diff, diff-tree, fetch, for-each-ref, grep, help, log, ls-files, ls-remote, ls-tree, merge-base, merge-tree, name-rev, reflog, rev-parse, shortlog, show, status, verify-commit, verify-tag.

Flags: --version.

Guarded: remote (deny add, prune, remove, rename, set-branches, set-url), branch (deny --copy, --delete, --edit-description, --move, --set-upstream-to, --unset-upstream, -C, -D, -M, -c, -d, -m, -u), stash (list, show only), tag (list only, deny --annotate, --delete, --force, --sign, -a, -d, -f, -s), config (--get, --get-all, --get-regexp, --list, -l only), worktree (list only), notes (list, show only). Supports `-C <dir>` prefix.

### `glab`

Subcommands ci, cluster, deploy-key, gpg-key, incident, issue, iteration, label, milestone, mr, release, repo, schedule, snippet, ssh-key, stack, variable are allowed with actions: diff, issues, list, status, view.

Always safe: --version, -v, check-update, version.

Guarded: auth (status only), api (GET only, no body flags).

### `go`

Subcommands: build, doc, env, list, test, version, vet. Flags: --version.

### `gradle / gradlew`

Subcommands: build, check, dependencies, properties, tasks, test. Flags: --version.

### `hyperfine`

Recursively validates each benchmarked command. Denied if --prepare, --cleanup, or --setup flags are used (arbitrary shell execution).

### `jj`

Subcommands: bookmark list, config get, config list, diff, file list, file show, git fetch, git remote list, help, log, op log, root, show, st, status, version, workspace list.

Flags: --version.

Skips global flags: standalone (--debug, --ignore-immutable, --ignore-working-copy, --no-pager, --quiet, --verbose), valued (--at-op, --at-operation, --color, --repository, -R).

### `launchctl`

Subcommands: blame, dumpstate, error, examine, help, hostinfo, list, print, print-cache, print-disabled, resolveport, version.

### `lipo`

Requires: -archs, -detailed_info, -info, -verify_arch. Denied: -output.

### `llm`

Subcommands: aliases, collections, logs, models, plugins, templates. Flags: --version.

### `log`

Subcommands: help, show, stats, stream.

### `magick`

Subcommands: identify. Flags: --help, --version.

### `mise`

Subcommands: config list, config ls, current, doctor, env, list, ls, settings get, which. Flags: --version.

### `mvn / mvnw`

Subcommands: compile, dependency:list, dependency:tree, help:describe, test, test-compile, validate, verify. Flags: --version, -v.

### `networksetup`

Allowed: subcommands starting with -list, -get, -show, -print, plus -version and -help.

### `nice / ionice`

Skips priority flags (-n/--adjustment), then recursively validates the inner command.

### `npm`

Subcommands: audit, doctor, explain, fund, info, list, ls, outdated, prefix, root, test, view, why.

Flags: --version.

Guarded: config (list/get only), run/run-script (test/test:* only).

### `npx`

Allowed packages: @herb-tools/linter, eslint, karma.

Guarded: tsc (requires --noEmit).

Skips flags: --yes/-y/--no/--package/-p.

### `nvm`

Subcommands: current, list, ls, ls-remote, version, which. Flags: --version.

### `ollama`

Subcommands: list, ps, show. Flags: --version.

### `perl`

Allowed: -e/-E inline one-liners with safe code, --version, --help, -v, -V. Blocked: script files (no -e/-E), -i (in-place edit), s///e modifier, backticks, and code containing identifiers not in the safe built-in allowlist.

### `pip / pip3`

Subcommands: check, debug, freeze, help, index, inspect, list, show.

Flags: --version.

Guarded: config (list/get only).

### `pkgutil`

Requires: --check-signature, --export-plist, --file-info, --file-info-plist, --files, --group-pkgs, --groups, --groups-plist, --packages, --payload-files, --pkg-groups, --pkg-info, --pkg-info-plist, --pkgs, --pkgs-plist. Denied: --expand, --flatten, --forget, --learn.

### `plutil`

Flags: -help, -lint, -p, -type.

### `pmset`

Allowed: -g (get/display settings only).

### `pnpm`

Subcommands: audit, list, ls, outdated, why. Flags: --version.

### `poetry`

Subcommands: check, env info, env list, show. Flags: --version.

### `pyenv`

Subcommands: help, root, shims, version, versions, which. Flags: --version.

### `rbenv`

Subcommands: help, root, shims, version, versions, which. Flags: --version.

### `rustup`

Subcommands: component list, doc, show, target list, toolchain list, which.

Flags: --version.

run <toolchain> delegates to inner command validation.

### `security`

Subcommands: cms, dump-keychain, dump-trust-settings, find-certificate, find-generic-password, find-identity, find-internet-password, list-keychains, show-keychain-info, smartcard, verify-cert.

### `sed`

Safe unless -i/--in-place flag or 'e' modifier on substitutions (executes replacement as shell command).

### `sort`

Safe unless -o/--output or --compress-program flag.

### `spctl`

Requires: --assess, -a. Denied: --add, --disable, --enable, --master-disable, --master-enable, --remove.

### `swift`

Subcommands: build, package describe, package dump-package, package show-dependencies, test. Flags: --version.

### `sysctl`

Safe unless -w/--write flag or key=value assignment syntax.

### `tea`

Subcommands b, branch, branches, i, issue, issues, label, labels, milestone, milestones, ms, n, notification, notifications, org, organization, organizations, pr, pull, pulls, r, release, releases, repo, repos, t, time, times are allowed with actions: list, view. Bare subcommand (no action) is also safe.

Always safe: --version, -v, whoami.

Guarded: logins/login (list only).

### `time`

Skips -p flag, then recursively validates the inner command.

### `timeout`

Skips timeout flags (-s/--signal, -k/--kill-after, --preserve-status), then recursively validates the inner command.

### `uv`

Subcommands: pip check, pip freeze, pip list, pip show, python list, tool list. Flags: --version.

### `volta`

Subcommands: list, which. Flags: --version.

### `xargs`

Recursively validates the inner command. Skips xargs-specific flags (-I, -L, -n, -P, -s, -E, -d, -0, -r, -t, -p, -x).

### `xcode-select`

Allowed: -p/--print-path, -v/--version. Denied: -s/--switch, -r/--reset, --install.

### `xcodebuild`

Flags: -list, -showBuildSettings, -showdestinations, -showsdks, -version.

### `xcrun`

Subcommands: notarytool history, notarytool info, notarytool log, simctl list, stapler validate.

Flags: --find, --show-sdk-build-version, --show-sdk-path, --show-sdk-platform-path, --show-sdk-platform-version, --show-sdk-version, --show-toolchain-path.

Skips flags: --sdk/--toolchain (with arg), -v/-l/-n.

### `xmllint`

Safe unless --output flag.

### `yarn`

Subcommands: info, list, ls, why.

Flags: --version.

Also allowed: test, test:*.

### `yq`

Safe unless -i/--inplace flag.