Skip to content

[Code Quality] Apply console formatting to top 5 CLI error-heavy files #13790

@github-actions

Description

@github-actions

Description

Apply console.FormatErrorMessage() formatting to the top 5 CLI files with highest unformatted error counts (388 total errors, representing 25% of all unformatted errors in the codebase). Currently only 4.4% (69/1,581) of error output sites use proper console formatting.

Problem

Users see raw Go error messages instead of helpful, formatted guidance. The top 5 CLI files alone contain 388 unformatted errors, creating inconsistent error presentation across user-facing commands.

Suggested Changes

Files to Update (Priority Order)

  1. pkg/cli/add_interactive.go - 107 unformatted errors
  2. pkg/cli/init.go - 100 unformatted errors
  3. pkg/cli/add_command.go - 72 unformatted errors
  4. pkg/cli/audit_report_render.go - 61 unformatted errors
  5. pkg/cli/trial_command.go - 48 unformatted errors

Pattern to Replace

// ❌ BEFORE - Raw error output
if err != nil {
    fmt.Fprintln(os.Stderr, err)
    return err
}

// ✅ AFTER - Console formatted error
if err != nil {
    fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
    return err
}

Also Fix stdout Anti-patterns

// ❌ BEFORE - Error to stdout
if err != nil {
    fmt.Println(err)
    return err
}

// ✅ AFTER - Error to stderr with formatting
if err != nil {
    fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
    return err
}

Success Criteria

  • Update all error outputs in add_interactive.go (107 errors)
  • Update all error outputs in init.go (100 errors)
  • Update all error outputs in add_command.go (72 errors)
  • Update all error outputs in audit_report_render.go (61 errors)
  • Update all error outputs in trial_command.go (48 errors)
  • All fmt.Fprintln(os.Stderr, err)fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
  • Verify no stdout error outputs remain
  • Test commands manually to verify formatting

Manual Testing

# Test each command with intentional errors
./gh-aw init /nonexistent/path
./gh-aw add /invalid/workflow.md
./gh-aw trial nonexistent-workflow
./gh-aw audit 99999999

# Verify errors are colored/formatted in terminal

Impact

388 errors (25% of all unformatted errors) will have proper console formatting, providing maximum user-facing impact.

Source

Extracted from Error Experience Engineering Discussion #12265

Priority

High - Direct user experience improvement

Estimated Effort

Large (1 week)

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 18, 2026, 9:08 PM UTC

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions