This is a submission for the GitHub Copilot CLI Challenge
What I Built
Ahoy, matey! π΄ββ οΈ Let me tell you a tale about Captain Hook β not the villain from Neverland, but the hero of your git repository!
You see, GitHub Copilot usually sits beside you as a friendly copilot, offering helpful suggestions. But what if your copilot got promoted to captain and started giving you orders? What if it didn't just suggest β it enforced?
That's exactly what I built: an intelligent git pre-commit hook that acts like a captain, commanding your code to ship-shape quality before it sets sail into your repository!
π£ The Hook That Captains Your Code
Captain Hook is a git pre-commit hook with a personality problem (in the best way). It:
- π Linting (ruff check) - "Arr! Walk the plank, unused imports!"
- π¨ Formatting (ruff format) - "Straighten those lines, ye scurvy code!"
- π Type Checking (mypy) - "Where be yer type hints, sailor?"
- π§ͺ Tests (pytest) - "No code leaves port without passing inspection!"
β From Copilot to Captain
Here's the twist that makes this project special:
Normal Copilot: "Hey, maybe you could fix this import?" π
Captain Hook: "HALT! Unused import detected! Removing it NOW!" πͺ
Normal Copilot: "Consider adding type hints here..." π€
Captain Hook: "NO TYPE HINTS? Calling in backup! blows whistle GitHub Copilot CLI, report for duty!" πΊ
When Captain Hook encounters something it can't auto-fix (type errors, test failures), it doesn't just block your commit and walk away. Oh no! It calls in the GitHub Copilot CLI β think of it as calling in the Admiral for strategic advice!
π΄ββ οΈ Why "Captain Hook"?
Because this git hook acts like a captain:
- Hook (git pre-commit mechanism) β Technical term
- Captain (commands and enforces) β How it behaves
- Captain Hook β The perfect nautical pun! π£
Plus, just like the infamous Captain Hook, this tool:
- β Never lets Peter Pan (bad code) escape
- β Has a trusty sidekick (GitHub Copilot CLI)
- β Commands the crew (QA tools) with authority
- β Protects the ship (your repository) fiercely
π’ What It Means to Me
As developers, we often treat CI/CD and code quality tools as annoying gatekeepers β the grumpy pirates who say "NO!" to everything. But what if they were more like a wise captain who:
- Fixes what can be fixed automatically (80% of issues)
- Teaches you how to fix complex problems (using AI)
- Keeps the ship running smoothly (maintains quality)
- Actually makes your life easier, not harder
Captain Hook represents a shift from "code quality as punishment" to "code quality as a helpful mentor with a sense of humor and a pirate hat."
Demo
π Live Repository: https://github.com/thec0dewriter/captain_hook.git
πΊοΈ Project Repository Structure:
captain_hook/
βββ src/captain_hook/ # The treasure (Python library code)
βββ tests/ # Quality inspection (100% coverage)
βββ hooks/ # The Captain's quarters! β
β βββ pre-commit # Captain Hook himself
β βββ install.sh # Recruit the captain
β βββ demo.sh # Training exercises
β βββ README.md # Captain's orders
βββ submission.md # This very tale!
βββ HOOK_SUMMARY.md # The Captain's log
βββ README.md # Ship's manifest
β Captain Hook in Action:
Example 1: The Captain Takes Command πͺ
Picture this: You try to commit some messy code...
$ git commit -m "Add new feature"
π Running pre-commit QA checks...
π Step 1/4: Linting (ruff check)
β Linting failed
- Found unused imports: os, sys, json
- Missing spaces around operators
β "AVAST, YE SCURVY CODE!" - Captain Hook
Attempting auto-fix with ruff...
β Auto-fixed linting issues
β Unused imports walked the plank!
β Spaces restored to their rightful place!
Staging auto-fixed files...
π¨ Step 2/4: Format checking (ruff format)
β Format check failed
β "This code be messier than a pirate's beard!"
Auto-formatting files...
β Files formatted
β Your code now looks shipshape!
Staging formatted files...
π Step 3/4: Type checking (mypy)
β Type checking passed
β "Good! Proper type hints, as any respectable sailor knows!"
π§ͺ Step 4/4: Running tests (pytest)
β Tests passed
ββββββββββββββββββββββββββββββββββββββββ
β
All pre-commit checks PASSED
β "Permission granted! Your code may set sail!"
ββββββββββββββββββββββββββββββββββββββββ
Example 2: When the Captain Calls for Backup πΊ
Sometimes even captains need help from the admiral...
$ git commit -m "Add calculator"
π Running pre-commit QA checks...
π Step 1/4: Linting (ruff check)
β Linting passed
π¨ Step 2/4: Format checking (ruff format)
β Format check passed
π Step 3/4: Type checking (mypy)
β Type checking failed
src/calculator.py:4: error: Function is missing a type annotation
β "Blimey! Missing type hints be beyond me fixing powers!"
β "Calling in the ADMIRAL for strategic advice!"
β οΈ Attempting auto-fix with GitHub Copilot CLI...
πΊ *Admiral GitHub Copilot CLI reports for duty*
π‘ Copilot suggests:
"Add type annotations to function parameters and return type:
def calculate(a: float, b: float) -> float:
return a + b"
β "There ye have it! Follow the Admiral's orders, sailor!"
Tips:
- Apply the Admiral's wisdom (Copilot's suggestion)
- Run 'make check' to verify
- Try committing again
π΄ββ οΈ Real Voyage Testing
The Captain was battle-tested with intentionally broken code:
| Challenge | Captain's Response | Outcome |
|---|---|---|
| Unused imports (3x) | "Walk the plank!" | β Auto-removed |
Bad spacing x,y
|
"Mind yer spaces!" | β
Fixed to x, y
|
| Messy formatting | "Swab the deck!" | β Auto-formatted |
| Missing type hints | "Call the Admiral!" | β Copilot suggested fix |
| Code ready to commit | "Set sail!" | β Smooth sailing |
πΊοΈ Quick Start: Recruit Your Captain
# Clone the ship
git clone https://github.com/thec0dewriter/captain_hook.git
cd captain_hook
# Stock the supplies (install dependencies)
make install
# Recruit Captain Hook to your crew
make install-hooks
# Make a change and try to commit
echo "import os" >> src/captain_hook/calculator.py
git add .
git commit -m "Test the Captain"
# Watch Captain Hook spring into action! π£
My Experience with GitHub Copilot CLI
π The Plot Twist: From Copilot to Captain
When I started this project, I thought I was building a simple pre-commit hook. But something magical happened: the copilot became the captain.
Here's how GitHub Copilot CLI transformed this project:
1οΈβ£ The Captain's Wisdom: Intelligent Error Resolution
Before Copilot CLI:
Error: Function missing type annotation
*stares at screen*
*Googles "python type hints"*
*reads docs for 10 minutes*
*tries something*
*fails*
*repeats*
With Captain Hook + Copilot CLI:
β "Type hints be missing! Calling the Admiral!"
π‘ Copilot: "Add type hints like this: def foo(x: int) -> int:"
β
"Brilliant! Fixed in 30 seconds!"
It's like having a ship's navigator who actually knows where you're going instead of just pointing at the horizon!
2οΈβ£ Building the Captain: Meta-Development
The beautiful irony? I used GitHub Copilot CLI to build a tool that uses GitHub Copilot CLI!
Inception moment:
- Used Copilot to write the hook
- The hook calls Copilot CLI for help
- It's copilots all the way down! π
Copilot helped me:
- Scaffold the entire git hook structure
- Write robust bash error handling
- Design the captain personality (yes, the pirate puns!)
- Generate comprehensive documentation
- Create engaging demo scenarios
3οΈβ£ The Admiral's Strategy: Learning Through Collaboration
Working with Copilot CLI felt less like "using a tool" and more like pair programming with a pirate crew:
- The Captain (my hook) β Commands and enforces
- The Admiral (Copilot CLI) β Provides strategic advice
- The Crew (ruff, mypy, pytest) β Do the actual work
- Me (the developer) β Enjoys smooth sailing! β΅
Best part? When Captain Hook calls Copilot CLI, it's not just showing error messages β it's providing contextual wisdom based on the actual code and error.
4οΈβ£ Real-World Impact: The 80/20 Rule of Joy
Here's the magic formula Captain Hook delivers:
- 80% of problems: Auto-fixed instantly (bye bye, formatting fights!)
- 20% of problems: Copilot CLI teaches you the solution
- 100% of the time: You stay in flow state π
Old workflow:
Write code β Commit β CI fails β Context switch β Google β Fix β Repeat
π€ Frustration level: High
Captain Hook workflow:
Write code β Commit attempt β Captain fixes most issues β
Copilot teaches remaining fixes β Commit succeeds
π Frustration level: "What frustration?"
5οΈβ£ The Joke That Became Real
Started as: "Haha, what if git hooks had personality?"
Became: "Wait, this is actually the future of developer experience!"
The Captain Hook name started as a pun but revealed a deeper truth:
- Copilots suggest (helpful but passive)
- Captains command (authoritative but caring)
- The best tools do both! π―
π¬ Key Takeaway: It's About the Journey
GitHub Copilot CLI isn't just "AI that writes code faster." It's:
β¨ A teaching tool that explains why fixes work
π’ A workflow enhancer that keeps you sailing smoothly
π£ A captain that catches problems before they cause shipwrecks
π‘ A collaboration partner that makes coding more fun
Captain Hook proves that AI in development isn't about replacing developers β it's about promoting your helpful copilot to a wise captain who still lets you steer the ship!
π― Technologies Used:
- Python 3.9+ with UV package manager (fastest ship in the fleet!)
- Ruff (linting & formatting) (the ship's cleaning crew)
- Mypy (type checking) (the quality inspector)
- Pytest (testing with coverage) (safety drills)
- Bash scripting (the ship's machinery)
- Git hooks (the captain's perch)
- GitHub Copilot CLI (the wise admiral) ποΈ
π Current Status & Future Voyages
β What's Shipshape:
- Intelligent pre-commit hook with auto-fix
- GitHub Copilot CLI integration
- 100% test coverage (8 passing tests)
- Comprehensive documentation
- Real-world testing completed
π§ Potential Future Adventures (TODOs):
- [ ] Add more "captain personality" responses for different error types
- [ ] Support for commit-msg hook (Captain checks your commit messages!)
- [ ] Integration with more language ecosystems (TypeScript, Go, Rust)
- [ ] "Parrot mode" - hook verbosity level (quiet parrot vs. chatty parrot π¦)
- [ ] Collectible "achievements" when you fix issues
- [ ] Ship's log (detailed commit history with captain's commentary)
Try it yourself:
git clone https://github.com/thec0dewriter/captain_hook.git
cd captain_hook
make install
make install-hooks
# Let Captain Hook command your code to quality! β
Built with β€οΈ (and lots of pirate puns) for the GitHub Copilot CLI Challenge
"Not all those who wander are lost, but all code that wanders needs a captain!" π£β

Top comments (0)