$ show seachicken/gh-poi
gh-poi is a GitHub CLI extension that safely cleans up local branches by identifying those with merged or closed pull requests. The application features a layered architecture separating command-line parsing (cmd/), external command execution (conn/), and shared data models (shared/). Key functionality includes fetching branch information from git, checking PR status via GitHub CLI, evaluating branch deletability based on multiple factors (lock status, worktree state, uncommitted changes), and performing safe deletion with dry-run support. The tool handles complex scenarios like worktrees, detached HEAD states, and various remote configurations.
The LLM identified 3 files worth highlighting for reuse:
Implements intelligent batching of GitHub GraphQL queries to avoid API length limits. Takes branch commit hashes and groups them into queries under 256 characters while preserving order. Demonstrates non-obvious skill in working within GitHub's API constraints through smart string building and conditional separator handling.
Contains robust Git remote URL parsing logic that handles multiple formats (scp-like, ssh://, https://, etc.) and normalizes them. The parseRemotes function correctly processes various URL schemes and includes special handling for scp-like syntax. This isolated component shows craftsmanship in dealing with Git's diverse URL formats and could be reused in any Git-related tool.
Implements GetPreferredRemotes function that intelligently selects which Git remotes to query for PR information based on scan mode (quick/deep). Prioritizes 'origin' and considers gh-resolved configuration while avoiding unnecessary API calls. Demonstrates thoughtful engineering by optimizing for common Git workflows while maintaining flexibility for complex multi-remote setups.