git-clone-rules is a small zsh wrapper for the one git clone case that should not require thought:
git clone git@github.com:someowner/somerepo.gitWhen the command is exactly git clone <github-url> and no destination path is provided, the wrapper maps the repository into:
~/Development/github.com/{owner}/{repo}
It prints the target path, asks for confirmation, creates the parent directory, and then hands the clone to the real git executable.
Cloning a repository often includes a tiny but repeated context switch: checking the current directory, remembering where repositories belong, and avoiding accidental clones into unrelated worktrees or throwaway folders.
This tool encodes one filesystem rule once. GitHub repository provenance stays in the path, owner/name collisions stop being ambiguous, and everyday clones land in a predictable place.
The wrapper is intentionally narrow. It only intercepts the plain GitHub clone case. If you pass an explicit destination, use clone options, clone from another host, or run any non-clone Git command, normal Git behavior wins.
git clone git@github.com:owner/repo.git
git clone https://github.com/owner/repo.git
git clone https://github.com/owner/repo
git clone ssh://git@github.com/owner/repo.gitMake the script executable:
chmod +x bin/git-clone-rulesThen choose one deployment style.
This is the least invasive option. Add this to ~/.zshrc:
git() {
/path/to/git-clone-rules/bin/git-clone-rules "$@"
}Reload your shell:
source ~/.zshrcCreate a directory that appears before the real Git executable on PATH, then symlink this script as git:
mkdir -p ~/.local/git-clone-rules/bin
ln -sf /path/to/git-clone-rules/bin/git-clone-rules ~/.local/git-clone-rules/bin/gitAdd this before the system Git path in ~/.zshrc:
export PATH="$HOME/.local/git-clone-rules/bin:$PATH"The wrapper searches PATH for the next git executable that is not itself. If your setup is unusual, pin the real binary explicitly:
export GIT_CLONE_RULES_REAL_GIT=/usr/bin/gitSet a different clone root with:
export GIT_CLONE_RULES_BASE="$HOME/Code"That changes the target layout to:
$GIT_CLONE_RULES_BASE/github.com/{owner}/{repo}
For non-interactive use, skip the prompt with:
GIT_CLONE_RULES_YES=1 git clone git@github.com:owner/repo.gitFor a dry run:
GIT_CLONE_RULES_DRY_RUN=1 GIT_CLONE_RULES_YES=1 git clone git@github.com:owner/repo.git$ git clone git@github.com:someowner/somerepo.git
About to clone into:
~/Development/github.com/someowner/somerepo
Proceed? [y/N] y
This repository packages the shell-wrapper idea from Teach git clone where repos belong: keep the boring clone path canonical, show the destination before doing work, and leave explicit overrides under the user's control.