Stdin `-` support everywhere sensible; usage error for stray `-` elsewhere
Agents instinctively pass - to mean "read content from stdin" — but only comments create/update honored it. Everywhere else the hyphen landed as literal content: a todo titled -, a message body of -.
Tier 1 — - reads stdin on every content input
Content-kind positionals: comments create/update, checkins answer create/update, todos create (join-all pattern); messages create [body], cards create [body], docs create [content], chat post/update, boost create, notes set (exact-positional pattern).
Content flags: --data (api post/put), --body (messages/cards update), --content (chat, files update), --description (todos, schedule, projects, todolists, templates, gauges, cards column, uploads create, upload, files replace), --comment (todos sweep), --file (notes set).
Resolution lives in internal/commands/stdin.go. The shared vocabulary — the allow_dash annotation and pipe detection — is the new internal/stdinarg leaf package, because internal/cli needs it too: --agent help now auto-synthesizes a per-command note ("Pass - to read from stdin: [body], --description") from the annotation, so tier-1 coverage self-documents, including for future commands.
Tier 2 — stray literal - + piped stdin = usage error
A central guard covers every runnable command in the assembled tree (~380 commands, aliases and future ones included). On subcommands it wraps the Args validator: cobra runs ValidateArgs after flag parsing (so Changed and ArgsLenAtDash are live) but before the persistent pre-run chain, PreRunE, and required-flag validation — so a stray - is rejected before any lifecycle side effect and before a competing usage error can shadow it. It is not a PersistentPreRunE hook across the tree because cobra runs only the innermost one, and the agent hook already shadows the root's.
The root is the one exception: its Args must stay nil for cobra's legacyArgs unknown-subcommand check, so its guard hangs off the front of its own PersistentPreRunE, acting only when the root itself executes. That is still ahead of config loading, profile resolution and --jq validation.
When stdin is piped and an exact - appears anywhere not annotated (positional or string/stringArray flag value), the command fails with a usage error naming the offender, pointing at where it does accept stdin, and teaching the -- escape. On a TTY, a literal - stays legal everywhere. Two allowed - in one invocation can never both be satisfied, so that errors regardless of pipe state. --out - (attachments/files download) is exempted as the stdout idiom. Cobra's generated meta commands — help and the completion commands — are exempt too: they perform no Basecamp content write, and completion legitimately receives - as the word being completed (basecamp todos create -<TAB> runs basecamp __complete todos create -), so guarding it would break flag completion across the CLI.
Behavior changes
comments create 123 - extra— was a silent literal"- extra"comment, now a usage error.-with TTY stdin — was hang-until-Ctrl-D, now an immediate usage error teaching the escapes: pipe it, heredoc (… - <<'EOF'),cat | … -(type + Ctrl-D), or--editwhere it exists.- Bare-pipe auto-read removed from
comments createandnotes set— piped stdin without-now errors with a hint instead of being silently consumed. Corollary: an unclaimed pipe alongside a named source (generate | notes set --file x.md) is ignored rather than raising the old ambiguity error — pipes are only ever a source through an explicit-, uniformly. notes set -(piped) — was a bogus "two sources" error, now works;notes set --file -— was ENOENT on a file named-, now stdin.- Piped scripts passing literal
-as a title/name/path now error;--is the documented escape. TTY usage unaffected. - Stdin content gets trailing newlines trimmed — Markdown doesn't care, but titles and boost's 16-rune limit do (
printf '🎉\n' | boost create <id> -no longer burns a rune).
Flag for review
No --stdin flag. A precedent survey settled on - as the universal content-from-stdin idiom; --stdin in the wild means other things (git plumbing = list-of-items, kubectl = attach container stdin), and heredoc/cat | give interactive humans the classic TTY path with zero new surface. This was an open question during planning — veto welcome if you still want the flag.
Tests
internal/stdinarg: annotation parsing, pipe detection (char-device TTY stand-in per the establishededit_test.goseam).- Resolver semantics table +
--escape through real parses. - Guard: unlisted positional (
projects create -), unlisted flag (todos update --title -), TTY passthrough,--out -exemption, double-dash rejection,--attach -alongside an allowed body,--escape. - Per-pattern integration through mock transports: messages create body
-,api post --data -,todos create -,boost create -(+ over-limit stdin),todos update --description -, notes set both forms. - New
e2e/stdin_dash.bats: empty-pipe rejection, TTY no-hang, bare-pipe hint, tier-2 rejection with--escape,--passthrough — all pre-network, no cassette needed. (The planned "posts body against cassette" e2e isn't recordable without live credentials — the happypath cassette set is read-only — so wire-level posting is covered by the mock-transport integration tests instead.)
bin/ci green: fmt, vet, lint, unit, e2e, surface snapshot (no Use-string or flag renames, so no regen), skill drift, smoke coverage, provenance. SKILL.md's - idiom is generalized in the same PR — it previously over-promised; now it's true.
Summary by cubic
Adds uniform "-" (stdin) support across content inputs and installs a guard that errors on stray "-" when stdin is piped, preventing pipes from becoming literal content. Also fixes jq-backed output to avoid double writes on filter errors and classifies Cobra arity errors as usage.
- Coverage: accepts "-" on content positionals (comments create/update; check-ins answer create/update; todos create; messages/cards/docs create body; chat post/update; boost create; notes set) and content flags (
--data,--body,--content,--description,--comment,--file).--out -(download) keeps the stdout idiom.helpand__completeare exempt; agent--helpautolists stdin-capable inputs viastdinarg. - Guard and ordering: runs at Args-validation time, rejects two stdin consumers and empty stdin, and dedupes alias flags; the root is guarded in pre-run. Stdin is read only when "-" is present. TUIs (wizards/pickers) now require character‑device stdin and stdout. An AST backstop enforces pre-read validation, and it now catches
requireNumericIDsites. - Pre-read validations hoisted: parse/validate IDs before any read (chat line/room; boost/event; check-ins; schedules; explicitly supplied dock IDs; uploads
--folderID), reject foreign API hosts early, and validate attachment paths first. Files replace recording-type, cards update attachment validation, schedule timestamps, and todos--loosevs list are decided before reading. Messages/cards/docs create bound at MaximumNArgs(2). Chat post/update reject combining a positional message with--content. - Behavior changes:
- Bare pipes are no longer auto-read; stdin is consumed only when "-" is supplied.
- "comments create 123 - extra" — was a silent literal "- extra", now a usage error.
- "-" with TTY stdin — was hang-until-EOF, now an immediate usage error with hints.
- Stdin content trims trailing CRLF/LF.
- Required actions:
- Pass "-" wherever stdin should be consumed; the CLI never reads stdin implicitly.
- For a literal "-" positional, use "--" to escape it. For flags with a literal "-", run without piped stdin.