Created
February 11, 2026 10:25
-
-
Save mvidner/2f018beb6d44a1355188596d5de36c1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| SAFE_SUBCOMMANDS=("status" "diff") | |
| show_help() { | |
| echo "Usage: llm-git <subcommand> [options]" | |
| echo "" | |
| echo "A wrapper for git that only allows safe commands to be run by an LLM." | |
| echo "" | |
| echo "Allowed subcommands:" | |
| for cmd in "${SAFE_SUBCOMMANDS[@]}"; do | |
| echo " - $cmd" | |
| done | |
| echo "" | |
| echo "Options:" | |
| echo " -h, --help - Display this help message and exit" | |
| echo "" | |
| echo "For other git commands, please use 'git' directly." | |
| } | |
| if [[ "$1" == "-h" || "$1" == "--help" ]]; then | |
| show_help | |
| exit 0 | |
| fi | |
| SUBCOMMAND=$1 | |
| is_safe=false | |
| for safe_command in "${SAFE_SUBCOMMANDS[@]}"; do | |
| if [[ "$SUBCOMMAND" == "$safe_command" ]]; then | |
| is_safe=true | |
| break | |
| fi | |
| done | |
| # If the subcommand is safe, execute the git command with all arguments. | |
| if $is_safe; then | |
| git "$@" | |
| else | |
| if [[ -n "$SUBCOMMAND" ]]; then | |
| echo "Disallowed subcommand '$SUBCOMMAND'. Retry with the unwrapped git." | |
| else | |
| show_help # Show help if no subcommand is given | |
| fi | |
| exit 1 | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For GEMINI.md:
This lets you "Always allow
llm-git" while keeping manual control overgit commitand such.