Skip to content

feat: use gh CLI as default backend with API fallback#18

Merged
konard merged 3 commits intomainfrom
issue-17-5aba117748c0
Dec 28, 2025
Merged

feat: use gh CLI as default backend with API fallback#18
konard merged 3 commits intomainfrom
issue-17-5aba117748c0

Conversation

@konard
Copy link
Member

@konard konard commented Dec 27, 2025

Summary

This PR implements issue #17 by making gh CLI the default method for fetching PR data, with automatic fallback to the GitHub REST API when gh CLI is not available or not authenticated.

Key Changes

  • New backends.mjs module: Extracted backend implementations (gh CLI and API) into a separate module for better code organization
  • gh CLI as default: By default, the tool now uses gh CLI to fetch PR data, which leverages existing GitHub authentication
  • Automatic API fallback: If gh CLI is not installed or not authenticated, the tool automatically falls back to the GitHub REST API (Octokit)
  • New CLI flags:
    • --force-api: Force using the GitHub API instead of gh CLI
    • --force-gh: Force using gh CLI (fails if not available)
  • CI/CD improvements: Added new test-modes job to test both gh CLI and API modes in CI
  • Comprehensive tests: Added tests for both backend modes

Testing

  • All 53 existing tests pass
  • Added 10 new tests specifically for backend mode functionality
  • Manual testing of both --force-api and --force-gh modes

Documentation

  • Updated README with new "Backend Modes" section
  • Added examples for using --force-api and --force-gh flags
  • Updated CLI usage documentation

Test Plan

  • Run bun test - all tests pass
  • Run npm run check - linting and formatting pass
  • Test --force-api flag manually
  • Test --force-gh flag manually
  • Verify default behavior uses gh CLI when available
  • Verify fallback to API when gh is not available/authenticated

Fixes #17

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #17
@konard konard self-assigned this Dec 27, 2025
This commit implements issue #17 by making gh CLI the default method
for fetching PR data, with automatic fallback to the GitHub REST API
when gh CLI is not available or not authenticated.

Changes:
- Added new backends.mjs module for gh CLI and API implementations
- By default, the tool now uses gh CLI to fetch PR data
- Automatically falls back to GitHub REST API (Octokit) if gh CLI
  is not installed or not authenticated
- Added --force-api flag to force using the GitHub API
- Added --force-gh flag to force using gh CLI (fails if unavailable)
- Added new CI/CD job (test-modes) to test both backends
- Added tests for both gh CLI and API modes
- Updated documentation with backend mode information

Fixes #17

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Make sure by default we use gh tool auth feat: use gh CLI as default backend with API fallback Dec 27, 2025
@konard konard marked this pull request as ready for review December 27, 2025 17:09
@konard
Copy link
Member Author

konard commented Dec 27, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $9.774319 USD
  • Calculated by Anthropic: $6.123902 USD
  • Difference: $-3.650418 (-37.35%)
    📎 Log file uploaded as GitHub Gist (1141KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 85beee7 into main Dec 28, 2025
9 checks passed
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.

Make sure by default we use gh tool auth

1 participant