Filesystem
Read-only and inspection shell commands: directory listing, file viewing, and text processing. Mutating commands (rm, mv, chmod, ...) are deliberately excluded, and the destructive flags of find and sed are guarded.
.claude/fencepost.yaml
import:
- filesystem
Full preset
presets/filesystem.yaml
# Fencepost preset: filesystem
tools:
bash:
allowChecks:
# bash/sh -n is a syntax-only check, it never executes the script. -n
# must be the first argument: once bash sees a non-flag operand it stops
# parsing options, so a trailing "-n" would just be passed to the script
# instead of switching bash into check mode.
- '^bash\s+-n\b'
- '^sh\s+-n\b'
# bash/sh -c hands fencepost's core evaluator a code string, which it
# re-parses and evaluates against the full rule set (see shellWrapperCode
# in src/bash/evaluate-ast.ts) — so this only smart-allows the wrapper
# invocation itself; the inner command still has to clear every rule on
# its own merits. -c must be the literal first argument: `sh script.sh`
# (no -c) runs an uninspected file and is deliberately NOT matched here.
- '^bash\s+-c\b'
- '^sh\s+-c\b'
checks:
- test: '\bfind\b.*\s-(delete|exec|execdir|ok|okdir)\b'
description: "find with -delete or -exec runs destructive actions across every match."
alternative: "List matches first (find ... -print), then act on the specific paths you mean."
- test: '\bsed\b.*\s(-i|--in-place)\b'
description: "sed -i edits files in place."
alternative: "Run sed without -i to preview the output, then write the result explicitly."
# Limitation: this is prefix matching, and shell output redirection (>, >>)
# is NOT parsed. `echo x > /etc/hosts` would still match the `echo` allow
# and write a file. Keep destructive-write rules in place if that matters.
allow:
# Navigation / listing
- ls
- pwd
- cd
- tree
- find
- du
- df
- realpath
- readlink
- basename
- dirname
# Viewing
- cat
- head
- tail
- less
- more
- wc
- stat
- file
- nl
# Text processing
- grep
- egrep
- fgrep
- rg
- diff
- cmp
- comm
- sort
- uniq
- cut
- tr
- tac
- rev
- column
- fold
- fmt
- jq
- yq
- awk
- sed
- base64
# Plumbing. Safe to allow: fencepost unwraps the command xargs/timeout
# runs and evaluates it against the full rule set, so `xargs rm` and
# `timeout 5 rm` still hit the rm rules, and unrecognised flags fall
# back to the onError posture.
- xargs
- timeout
# eval's arguments are always the code it executes (unlike sh/bash,
# there's no file-mode), so fencepost's core unwrap always sees and
# evaluates the real payload.
- eval
# Misc read-only info
- echo
- printf
- which
- type
- env
- printenv
- date
- hostname
- whoami
- id
- uname