Skip to content

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

@github-actions

Description

@github-actions

Description

Apply console.FormatErrorMessage() formatting to the top 5 CLI files with the highest unformatted error counts. These 5 files contain 388 unformatted 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.

Suggested Changes

Replace raw error outputs with console-formatted errors in:

  1. pkg/cli/add_interactive.go - 107 unformatted errors (interactive wizard - critical UX)
  2. pkg/cli/init.go - 100 unformatted errors (first-time setup - critical onboarding)
  3. pkg/cli/add_command.go - 72 unformatted errors (workflow creation - common operation)
  4. pkg/cli/audit_report_render.go - 61 unformatted errors (audit reports - troubleshooting)
  5. pkg/cli/trial_command.go - 48 unformatted errors (workflow testing - developer workflow)

Pattern to apply:

// ❌ 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
}

Files Affected

  • pkg/cli/add_interactive.go
  • pkg/cli/init.go
  • pkg/cli/add_command.go
  • pkg/cli/audit_report_render.go
  • pkg/cli/trial_command.go

Success Criteria

  • All 388 errors updated to use console.FormatErrorMessage()
  • No stdout error outputs remain (all errors go to stderr)
  • Import \"github.com/github/gh-aw/pkg/console\" added where needed
  • Manual testing confirms formatting appears correctly:
    • ./gh-aw init /nonexistent/path
    • ./gh-aw add /invalid/workflow.md
    • ./gh-aw trial nonexistent-workflow
    • ./gh-aw audit 99999999
  • All tests pass: make agent-finish

Source

Extracted from Error Experience Engineering discussion #12265

Priority

High - Maximum user-facing impact, improves error visibility and readability

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 6, 2026, 1:27 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions