fix(cli): skip Claude Code plugin hint when stdout is non-TTY (#5212)#5223
Merged
Conversation
The hint is already written to stderr, but redirecting stdout to a file (e.g. `supabase gen types ... > database.types.ts`) is the only scenario where this trailer matters — in interactive terminals it is either visible only to the user or stripped by Claude Code. Skipping emission when stdout is not a TTY guarantees that captured/redirected output cannot be contaminated, regardless of which stream the hint ends up on, and keeps the install-prompt UX intact for interactive shells where it is actually useful. Fixes #5212
…s Claude Code hint in output The `run` method in the test context now accepts an optional second argument for execution options, allowing for additional environment variables to be passed. This change ensures that when `CLAUDECODE=1` is set, the output does not include the Claude Code plugin hint, preventing issues with redirected output. This addresses the need for cleaner output when generating TypeScript types from projects. Fixes #5212
…st.go The TestSuggestClaudePlugin function has been removed from the misc_test.go file as it is no longer needed (covered by e2e test). This cleanup helps streamline the test suite and maintain focus on relevant tests. No changes to functionality were made.
Coverage Report for CI Build 25658328100Coverage decreased (-0.03%) to 63.722%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions28 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
Coly010
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (plus e2e regression coverage).
What is the current behavior?
When
CLAUDECODE=1(e.g. Claude Code / agent harness), the CLI can emit a<claude-code-hint … />trailer intended for the Claude Code UI. That is inappropriate when the user is capturing primary output (redirects, pipes, or tools that merge streams), because it can end up in generated files or other machine-readable output and break consumers such as TypeScript parsing.Tracked in #5212.
What is the new behavior?
SuggestClaudePlugin()only returns the hint when running inside Claude Code and standard output is a terminal (interactive). If stdout is redirected or piped, the hint is not suggested, so it is not printed after commands and captured output stays clean.An e2e case exercises
gen typeswithCLAUDECODE=1and asserts neither captured stdout nor stderr containsclaude-code-hint. ThetestBehaviourrunhelper accepts optionalexecoptions so tests can set extra env vars without duplicating harness setup.No user-facing visual changes.
Additional context
apps/cli-e2eand reuses the existing gen-types scenario (same test title → same fixture slug).SUPABASE_GO_BINARY="$PWD/apps/cli-go/supabase-go" pnpm nx run @supabase/cli-e2e:test:go -- src/tests/gen.e2e.test.ts(and
test:legacyif you want parity on the legacy harness).Testing method
Use RED/GREEN testing with the e2e test to ensure this properly fix an existing regression.