You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(terminal): add quiet mode support for Claude Code environments (#1409)
## What
Adds quiet mode support to the CLI that automatically suppresses
info/debug/status messages when running in Claude Code environments
(detected via `CLAUDECODE`, `REPL_ID`, or `AGENT` environment
variables). Warnings and errors are still displayed to ensure critical
information remains visible.
Also enhances the `note()` function to accept Error objects directly and
automatically include stack traces for error-level messages, simplifying
error handling throughout the codebase.
## Why
When the CLI is used in automated environments like Claude Code, the
verbose output (ASCII art, status messages, spinner progress) creates
noise and makes it harder to identify actual issues. This change
provides a cleaner output while preserving visibility of warnings and
errors.
The enhanced `note()` API also reduces boilerplate code by automatically
handling error formatting (colors, stack traces) that was previously
done manually.
## How
- **Quiet mode detection**: Modified `shouldPrint()` to check for
`CLAUDECODE`, `REPL_ID`, or `AGENT` environment variables
- **Enhanced note() function**:
- Now accepts `string | Error` as the first parameter
- Automatically includes stack traces when Error objects are passed with
level `"error"`
- Automatically applies red/yellow colors for error/warning levels
- Always displays warnings and errors, even in quiet mode
- **Simplified error handling**: Updated `spinner.ts` and `index.ts` to
use the enhanced `note()` API, removing manual color formatting and
stack trace concatenation
## Files Changed
- `sdk/utils/src/terminal/should-print.ts` - Added quiet mode detection
- `sdk/utils/src/terminal/note.ts` - Enhanced to accept Error objects
and auto-include stack traces
- `sdk/utils/src/terminal/spinner.ts` - Simplified error handling
- `sdk/cli/src/commands/index.ts` - Simplified error handling
- `sdk/utils/src/environment/write-env.test.ts` - Formatting updates
## Breaking Changes
None. The changes are backward compatible - existing code using `note()`
with string messages continues to work, and the new Error object support
is additive.
## Related Linear Issues
None
## Summary by Sourcery
Add quiet mode support for automated Claude Code environments and
enhance error reporting by extending the note() API and simplifying
error handling.
New Features:
- Suppress info/debug/status messages when CLAUDECODE, REPL_ID, or AGENT
env vars are set, while still displaying warnings and errors
- Allow note() to accept Error objects directly and automatically
include colored stack traces for error-level messages
Enhancements:
- Unify error handling in spinner.ts and CLI entrypoint by delegating to
the new note() API
- Update shouldPrint() to detect quiet mode and respect
SETTLEMINT_DISABLE_TERMINAL alongside Claude Code variables
Tests:
- Clean up array and destructuring formatting in write-env tests for
consistency
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduce quiet mode across terminal utils (suppresses info noise,
shows warnings/errors) and upgrade note() to handle Error objects with
colored stacks; add tests and tune Turbo output logging.
>
> - **Terminal utils**
> - **Quiet mode**: `should-print.ts` detects
`CLAUDECODE`/`REPL_ID`/`AGENT` to suppress non-critical output.
> - **Command execution**: `execute-command.ts` suppresses output in
quiet mode, echoes buffered output on error, and honors `silent: false`
override.
> - **Notes API**: `note.ts` now accepts `string | Error`, auto-masks,
auto-includes stack for errors, and applies red/yellow coloring;
warnings/errors always print.
> - **Spinner**: `spinner.ts` routes errors through `note(error,
"error")` and simplifies handling.
> - **CLI**
> - `sdk/cli/src/commands/index.ts`: Centralize unexpected error
reporting via `note(error, "error")`.
> - **Tests**
> - `execute-command.test.ts`: Add coverage for quiet mode behavior,
error echoing, and `silent: false` override.
> - `write-env.test.ts`: Minor formatting cleanups.
> - **Build config**
> - `turbo.json`: Set `outputLogs: "new-only"` on tasks to reduce noise.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
78f1222. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments