Skip to content

feat: accept message body via --file or stdin for send/edit#11

Merged
jonathanlam merged 1 commit into
mainfrom
feat/message-body-from-file-stdin
Jun 4, 2026
Merged

feat: accept message body via --file or stdin for send/edit#11
jonathanlam merged 1 commit into
mainfrom
feat/message-body-from-file-stdin

Conversation

@jonathanlam

Copy link
Copy Markdown
Member

Claude

Problem

message send / message edit only accept the message body as a positional shell argument. For formatted Slack mrkdwn this is a footgun: in a double-quoted shell argument the shell performs backtick command substitution and $/quote expansion before slack-cli ever sees the text.

A real example that bit an agent: a body containing (`smithrx`) was sent as a double-quoted argument. The shell ran smithrx as a command (smithrx: command not found to stderr), the substitution evaluated to empty, and the message went out as SmithRx () — corrupted but with a successful ts, so the failure was silent.

Single-quoting only half-fixes it: single quotes can't contain a literal ', which Slack alerts routinely include.

Fix

Add a --file <path> flag (- means stdin) plus implicit piped-stdin support to both send and edit. Body resolution precedence:

  1. --file (- = stdin)
  2. positional text argument (unchanged — fully backward compatible)
  3. piped stdin when no text argument is given

A quoted heredoc now sends arbitrary formatted bodies with zero shell interpretation:

slack-cli message send C01234ABC - <<'EOF'
:rotating_light: *Alert* with `code`, $vars, and 'quotes' all kept literal
EOF

Interactive stdin (a TTY) with no body returns a clear error instead of hanging.

Testing

  • go build ./... + go vet ./... clean
  • Verified manually against the built binary:
    • no body + no pipe → clean no message body error (no hang)
    • heredoc body with backticks / 'quotes' / $HOME → passes body resolution untouched, only fails at the (fake) auth call
    • --file <bad path> → clear read error
    • positional arg → still works (backward compat)
    • edit --file / stdin → works

Docs

SLACK_CLI_USAGE.md updated with the hazard note and --file/stdin usage for both commands.

🤖 Generated with Claude Code

`message send`/`message edit` previously required the body as a positional
shell argument. For formatted Slack mrkdwn this is a footgun: in a
double-quoted argument the shell interprets backticks, `$`, and quotes before
slack-cli sees them, so e.g. `` `org-slug` `` is run as a command and silently
dropped from the message (and emits a "command not found" to stderr) while the
send still "succeeds" with corrupted text.

Add a `--file <path>` flag ('-' means stdin) and implicit piped-stdin support
to both commands. Body resolution precedence: --file, positional text, then
piped stdin. The positional arg stays optional and fully backward compatible.
A quoted heredoc (`- <<'EOF'`) now lets callers send arbitrary formatted bodies
with zero shell interpretation. Interactive stdin (a TTY) with no body returns
a clear error instead of hanging.

Docs updated in SLACK_CLI_USAGE.md with the hazard note and new usage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonathanlam jonathanlam added the minor Minor version updates (features) label Jun 3, 2026
@jonathanlam jonathanlam marked this pull request as ready for review June 3, 2026 23:59
@jonathanlam jonathanlam merged commit a971c64 into main Jun 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Minor version updates (features)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant