Skip to content

Fix CLI messages using stdout instead of stderr with console formatting#12302

Merged
pelikhan merged 4 commits intomainfrom
copilot/fix-stdout-anti-patterns
Jan 28, 2026
Merged

Fix CLI messages using stdout instead of stderr with console formatting#12302
pelikhan merged 4 commits intomainfrom
copilot/fix-stdout-anti-patterns

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Five user-facing messages were incorrectly writing to stdout without console formatting, breaking piped output and inconsistent with the codebase standard of stderr + console helpers.

Changes

  • pkg/cli/file_tracker.go: "No files to stage" → stderr with FormatInfoMessage
  • pkg/cli/pr_command.go: PR creation message → stderr with FormatProgressMessage
  • pkg/cli/run_workflow_validation.go: Workflow validation messages (2 instances) → stderr with FormatProgressMessage
  • pkg/cli/add_workflow_pr.go: Removed unused addPRLog logger (unrelated lint blocker)

Before:

fmt.Printf("Creating PR: %s\n", title)

After:

fmt.Fprintln(os.Stderr, console.FormatProgressMessage(fmt.Sprintf("Creating PR: %s", title)))

JSON output (--json) and Mermaid graphs continue using stdout as intended.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Fix stdout anti-patterns in CLI commands</issue_title>
<issue_description>## Description

Found 5 instances of user-facing messages using stdout without console formatting. Messages should use stderr with proper console formatting for consistency and to avoid breaking piped output.

Locations to Fix

File Line Current Pattern Issue
pkg/workflow/file_tracker.go 86 fmt.Println("No files to stage") Should use stderr
pkg/cli/pr_command.go 770 fmt.Printf("Creating PR: %s\\n", title) Should use stderr + console formatting
pkg/workflow/run_workflow_validation.go 288, 315 fmt.Printf(...) Should use stderr + console formatting

Note: JSON output (--json flag) and graph output (Mermaid) correctly use stdout and don't need changes.

Proposed Fixes

Example 1: Simple message

Before:

fmt.Println("No files to stage")

After:

fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No files to stage"))

Example 2: Formatted message

Before:

fmt.Printf("Creating PR: %s\\n", title)

After:

fmt.Fprintln(os.Stderr, console.FormatProgressMessage(fmt.Sprintf("Creating PR: %s", title)))

Files Affected

  • pkg/workflow/file_tracker.go (1 instance)
  • pkg/cli/pr_command.go (1 instance)
  • pkg/workflow/run_workflow_validation.go (2 instances)

Success Criteria

  • All 5 instances updated to use stderr
  • Console formatting applied (FormatInfoMessage, FormatProgressMessage)
  • Verify JSON output still goes to stdout
  • Verify graph output still goes to stdout
  • All existing tests pass
  • Messages appear consistently styled in terminal

Impact

  • Severity: Low-Medium - Improves consistency
  • Effort: Low - Estimated 30 minutes
  • Risk: Minimal - Well-defined pattern changes
  • Benefit: Consistent message styling, proper stdout/stderr separation

Source

Extracted from Terminal Stylist Report: Console Output Analysis

Priority

Medium - Improves CLI consistency and output handling

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 11, 2026, 9:11 AM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stdout anti-patterns in CLI commands Fix CLI messages using stdout instead of stderr with console formatting Jan 28, 2026
Copilot AI requested a review from pelikhan January 28, 2026 16:24
@pelikhan pelikhan marked this pull request as ready for review January 28, 2026 17:14
@pelikhan pelikhan merged commit e45edc9 into main Jan 28, 2026
56 checks passed
@pelikhan pelikhan deleted the copilot/fix-stdout-anti-patterns branch January 28, 2026 17:21
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.

[Code Quality] Fix stdout anti-patterns in CLI commands

2 participants

Comments