This is a submission for the GitHub Copilot CLI Challenge
What I Built ð
gh-api-graveyard - A GitHub CLI extension that automatically finds and removes unused API endpoints from your OpenAPI specifications.
ðŠĶ The tool that cleans up dead endpoints so you don't have to.
The Problem ðĪ
Over time, APIs accumulate "dead" endpoints - routes that were created but never used, deprecated features nobody calls anymore, or experimental endpoints that didn't pan out. These clutter your codebase, create maintenance burden, and confuse developers about what's actually in use.
The Solution ðĄ
gh-api-graveyard automates the entire cleanup process:
- Auto-discovers your OpenAPI spec and access logs (no configuration needed!)
- Analyzes usage patterns with intelligent confidence scoring (0-100)
- Generates detailed markdown reports with actionable insights
- Creates pull requests to remove high-confidence unused endpoints
- Handles failures gracefully with automatic rollback
Key Features âĄ
âĻ Intelligent Auto-Discovery
- Searches common locations for OpenAPI specs
- Finds log files automatically (JSONL format)
- Reads optional
.graveyard.ymlconfig file
ð§ Smart Analysis
- Path template matching (handles
/users/{id}patterns) - Multi-factor confidence scoring (frequency, recency, caller diversity)
- Generates professional markdown reports
ðĪ Automated PR Creation
- Creates git branches with unique timestamps
- Commits spec changes
- Pushes to GitHub
- Creates detailed pull requests
- Automatic rollback on failure
Simple Commands ðŧ
# Install
gh extension install adylagad/gh-api-graveyard
# Scan for unused endpoints
gh api-graveyard scan
# Preview what would be removed
gh api-graveyard prune --dry-run
# Create PR to remove unused endpoints
gh api-graveyard prune
Repository: https://github.com/adylagad/gh-api-graveyard
Demo ðŽ
Installation & Setup ðĶ

Installing the extension is as simple as one command
Scanning for Unused Endpoints ð

The scan command auto-discovers your files and analyzes usage
Generated Report ð

Professional markdown reports with confidence scores and insights
Dry Run Preview ð

Preview exactly what will be removed before making changes
Creating the PR ð

Automated branch creation, commits, and PR generation
Before & After âĻ

Clean OpenAPI specs with unused endpoints removed
Pull Request ðŊ

Detailed PRs with all the context your team needs
Live Project: https://github.com/adylagad/gh-api-graveyard
My Experience with GitHub Copilot CLI âĻ
Building gh-api-graveyard was my first experience working entirely with GitHub Copilot CLI, and it completely changed how I think about development. Every single aspect of this project - from initial planning to final refactoring - was built through conversation with Copilot CLI.
How I Used Copilot CLI ð ïļ
Phase 1: Planning with [[PLAN]] Mode ð
I started by using plan mode to break down the project:
[[PLAN]] Build a GitHub CLI extension that finds unused API endpoints
Copilot CLI helped me:
- Design the module structure
- Identify required libraries (Click, PyYAML, GitPython)
- Plan the confidence scoring algorithm
- Create a step-by-step implementation roadmap
Phase 2: Core Development ðŧ
For each feature, I described what I needed and Copilot CLI wrote the code:
- "Parse OpenAPI YAML files and extract all endpoints"
- "Load JSONL log files and handle malformed entries gracefully"
- "Match concrete paths like /users/123 to templates like /users/{id}"
- "Calculate confidence scores based on frequency, recency, and caller diversity"
The best part? When I asked for something, Copilot CLI didn't just write the function - it added proper error handling, type hints, and docstrings automatically.
Phase 3: Git Integration ð
Building the automated PR creation was complex, but Copilot CLI guided me through:
- Branch creation with unique timestamps
- GitPython operations
- PyGithub API integration
- Error recovery and rollback strategies
Phase 4: Bug Fixing & Refinement ð
This is where Copilot CLI really shined. I'd describe issues like:
- "When branch creation fails, the openapi file is already modified"
- "The command shows 'gh graveyard' but should be 'gh api-graveyard'"
- "If the branch already exists, it should create a unique name"
Each time, Copilot CLI not only fixed the bug but suggested improvements I hadn't considered.
Phase 5: Refactoring ðĻ
When I requested "Please refactor the project and organize functions into logical modules," Copilot CLI:
- Analyzed the entire codebase
- Split the monolithic
utils.py(455 lines) into focused modules - Removed unused code (
analyzer.py) - Fixed all command references in README
- Updated imports across all files
- Tested everything still worked
What Impressed Me Most ð
1. Context Awareness ð§
Copilot CLI maintained context across multiple sessions. It remembered architectural decisions from days ago and applied them consistently.
2. Proactive Problem Solving ðŊ
It didn't just do what I asked - it anticipated issues:
- "We should check git status BEFORE modifying files, not after"
- "The function should return the actual branch name for proper cleanup"
- "Add generated reports to .gitignore"
3. End-to-End Capability ð
From planning to documentation (yes, even this submission!), Copilot CLI handled everything. I never had to switch contexts or manually write boilerplate.
4. Learning & Improving ð
When testing revealed issues, I'd paste the error and Copilot CLI would:
- Explain what went wrong
- Fix the issue
- Add safeguards to prevent similar problems
- Suggest related improvements
Impact on My Development Experience ðŦ
Speed: What would normally take days took hours. The planning phase alone saved me significant time. âĄ
Quality: The code is cleaner than I would have written manually. Copilot CLI consistently added proper error handling, type hints, and documentation. âĻ
Confidence: Having an AI pair programmer that catches mistakes and suggests improvements made me more confident in trying ambitious features. ðŠ
Learning: I learned best practices for CLI tools, Git automation, and Python project structure through Copilot CLI's suggestions. ð
Specific Examples ð
Before Copilot CLI (hypothetical manual approach):
def remove_endpoints(spec_path, endpoints):
# Load file
# Parse YAML
# Remove endpoints
# Save file
# Hope nothing breaks
With Copilot CLI:
def remove_endpoints_from_spec(
spec_path: Path,
endpoints_to_remove: List[Dict[str, str]]
) -> tuple[bool, str, int]:
"""
Remove endpoints from OpenAPI spec file.
Returns: (success, message, count_removed)
"""
# Proper error handling
# Atomic file operations
# Clear return values
# Comprehensive docstring
The "Aha!" Moment ðĄ
The biggest revelation came when debugging the git status issue. I described the problem: "The extension fails to create a branch, but I remain on main. When I run prune again, it reports the endpoints have already been removed."
Copilot CLI immediately understood the race condition, suggested checking git status BEFORE modifying files, added rollback logic, and even updated the function signature to return the actual branch name for proper cleanup. That level of understanding was mind-blowing.
Challenges Overcome ð
-
Repository naming: GitHub CLI extensions must start with
gh-. Copilot CLI helped rename the repo and update all references. -
Path matching: Needed to match
/users/123to/users/{id}. Copilot CLI implemented a segment-based algorithm. - Confidence scoring: Balancing multiple factors (frequency, recency, callers). Copilot CLI suggested a weighted approach.
- Rollback logic: Complex error recovery. Copilot CLI implemented proper git rollback with branch cleanup.
Would I Use It Again? ðĪ
Absolutely. GitHub Copilot CLI isn't just a code generator - it's a knowledgeable pair programmer that understands context, anticipates problems, and suggests improvements. It made building a production-ready CLI extension feel like a conversation rather than a coding marathon.
Even this submission document was written using GitHub Copilot CLI. ðĪ
I asked: "I need to write a submission document. Can you help me with this?" and it created a comprehensive document. When I said "I've added the required template to template.txt file. Please reformat the submission according to that template," it reformatted everything to match perfectly.
That's the magic of Copilot CLI - it adapts to your needs, learns your style, and delivers exactly what you ask for.
Technical Details ð§
Built with: ð ïļ
- Python 3.x ð
- Click (CLI framework) ðŧ
- PyYAML (OpenAPI parsing) ð
- GitPython (Git automation) ð
- PyGithub (PR creation) ð
Project Structure: ð
gh-api-graveyard/
âââ detector/
â âââ cli.py # CLI commands
â âââ parsers.py # OpenAPI & log parsing
â âââ analysis.py # Usage analysis
â âââ reports.py # Report generation
â âââ spec_modifier.py # Spec modification
â âââ git_ops.py # Git operations
â âââ discovery.py # Auto-discovery
âââ samples/ # Example files
Installation: ðĶ
gh extension install adylagad/gh-api-graveyard
Every line of code, every design decision, and this entire submission was created with GitHub Copilot CLI âĻ
Top comments (0)