Skip to content

Improve CLI Authentication UX: Auto-authenticate when credentials are available #664

@tbrandenburg

Description

@tbrandenburg

Problem

The current CLI requires users to manually run work auth login after creating a context, even when valid GitHub credentials are already available via GitHub CLI or environment variables. This creates poor user experience and contradicts the documented quick-start workflow.

Root Cause Analysis

Primary Issue: CLI architecture requires explicit work auth login but quick-start documentation didn't mention this step, creating mismatch between expected and actual workflow.

Contributing Factors:

  1. No automatic authentication in CLI commands
  2. Poor context state management (circular dependency in auth state)
  3. Tests mask the issue by explicitly calling authenticate()

Current Workaround

Added work auth login step to quick-start guide in commit fixing documentation.

Proposed Long-term Solutions

Option 1: Auto-authenticate in CLI Commands (Recommended)

  • Modify engine.listWorkItems() and other operations to call authenticate() automatically when not authenticated
  • Only auto-authenticate when credentials are available (GitHub CLI, env vars)
  • Fail with helpful error message if no credentials found

Option 2: Auto-authenticate During Context Creation

  • Modify work context add to automatically authenticate when credentials are available
  • Set authState: 'authenticated' immediately if successful

Option 3: Lazy Authentication

  • Initialize adapter with authentication on first use
  • Cache authentication state properly

Acceptance Criteria

  • Users can run work list immediately after work context add without manual work auth login
  • Authentication still works when credentials are not available (with helpful error)
  • Existing explicit work auth login workflow continues to work
  • All existing tests continue to pass
  • Integration tests verify the new auto-authentication flow

Priority

High - This significantly impacts user onboarding experience and contradicts documented workflows.

Labels

  • enhancement
  • user-experience
  • authentication
  • cli

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions