The sugarfree CLI is a plain stdin → stdout filter (see ../cli/README.md):
deterministic, no network, exits 0 on success. That makes it easy to drop into
agent hooks, editor commands, and CI/build steps.
The CLI contract in one line:
cat input | sugarfree [flags] > output # or: sugarfree FILE, or: sugarfree --clipboardExit codes: 0 success, 3 when run with --check and the content would change,
non-zero otherwise (bad flags, unreadable input).
See claude-code-settings.example.json for copy-paste
snippets. Two patterns:
Stophook — after each turn, runsugarfree --clipboard --allso whatever is on the clipboard pastes clean. Pair it withstrip-clipboard.sh.UserPromptSubmithook — pipe the submitted prompt throughsugarfree --allto strip bold/italic/header noise before Claude reads it.
Point the command at an absolute path to the built binary (e.g. /usr/local/bin/sugarfree)
or to strip-clipboard.sh.
Any harness that can shell out can call the filter. Strip emphasis from a model's markdown output before handing it to a plain-text sink:
agent --print | sugarfree --allOr normalize tables into structured lists for downstream parsing:
agent --print | sugarfree --none --tables --table-format yamlUse --check to gate a build on whether tracked content still carries sugar
(exit 3 = would change):
# Fail the job if any committed Markdown still has emphasis markers.
for f in $(git ls-files '*.md'); do
sugarfree --check "$f" && continue
echo "::error file=$f::contains formatting sugar — run 'sugarfree --all' on it"
fail=1
done
[ -z "${fail:-}" ]Or normalize in place as a pre-commit step:
tmp=$(mktemp); sugarfree --all "$file" > "$tmp" && mv "$tmp" "$file"The CLI never touches the network and is fully deterministic, so it's safe to run in sandboxed CI and agent environments.