Skip to content

fix(cli): skip Claude Code plugin hint when stdout is non-TTY (#5212)#5223

Merged
avallete merged 5 commits into
developfrom
claude/fix-stderr-output-xkSps
May 11, 2026
Merged

fix(cli): skip Claude Code plugin hint when stdout is non-TTY (#5212)#5223
avallete merged 5 commits into
developfrom
claude/fix-stderr-output-xkSps

Conversation

@avallete
Copy link
Copy Markdown
Member

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 types with CLAUDECODE=1 and asserts neither captured stdout nor stderr contains claude-code-hint. The testBehaviour run helper accepts optional exec options so tests can set extra env vars without duplicating harness setup.

No user-facing visual changes.

Additional context

  • The regression test lives in apps/cli-e2e and reuses the existing gen-types scenario (same test title → same fixture slug).
  • Run the focused suite with
    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:legacy if 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.

claude and others added 3 commits May 10, 2026 04:22
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.
@avallete avallete requested a review from a team as a code owner May 11, 2026 07:52
@coveralls
Copy link
Copy Markdown

coveralls commented May 11, 2026

Coverage Report for CI Build 25658328100

Coverage decreased (-0.03%) to 63.722%

Details

  • Coverage decreased (-0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 28 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

28 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
internal/utils/misc.go 23 75.34%
internal/utils/git.go 5 57.14%

Coverage Stats

Coverage Status
Relevant Lines: 15679
Covered Lines: 9991
Line Coverage: 63.72%
Coverage Strength: 7.06 hits per line

💛 - Coveralls

@avallete avallete merged commit c12a575 into develop May 11, 2026
20 checks passed
@avallete avallete deleted the claude/fix-stderr-output-xkSps branch May 11, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants