| name | git-repo-discovery |
| description | Find, cache, and refresh git repositories — both local projects and remote repos. Uses the gum CLI to discover existing checkouts under ~/*/ before cloning. Use when the user references a git repository (URL, org/repo, or local path) or when you need to locate a project on disk.
|
Librarian — Repository Finder & Cache
Find local git repositories or cache remote ones for reference. Prefers
discovering existing checkouts over cloning — your machine likely already
has what you need.
Quick Reference
| Task | Command |
|---|
| Find a local repo | gum projects --format json | jq '.[] | select(.path | test("PATTERN"))' |
| List all local repos | gum projects --format simple |
| Search by remote URL | gum projects --format json | jq '.[] | select(.remote | test("org/repo"))' |
| Clone with smart placement | gum clone org/repo |
| Suggest clone location | gum clone --suggest org/repo |
| Cache a remote repo | scripts/checkout.sh <repo> --path-only |
| Force-refresh a cached repo | scripts/checkout.sh <repo> --force-update --path-only |
Strategy: Local First
Before cloning anything, always check if the repo already exists locally:
gum projects --format json | jq -r '.[] | select(.remote | test("SEARCH_TERM")) | .path'
scripts/checkout.sh org/repo --path-only
gum clone org/repo
Finding Local Repos
The gum CLI maintains an indexed database of all git repos under ~/:
gum projects --format json
gum projects --format simple
gum projects --refresh --format simple
gum projects --format json | jq -r '.[] | select(.path | test("terraform")) | .path'
gum projects --format json | jq -r '.[] | select(.remote | test("shalomb")) | "\(.path)\t\(.remote)"'
Caching Remote Repos
For repos not already on disk, use scripts/checkout.sh to cache under
~/.cache/checkouts/<host>/<org>/<repo>:
scripts/checkout.sh mitsuhiko/minijinja --path-only
scripts/checkout.sh github.com/mitsuhiko/minijinja --path-only
scripts/checkout.sh https://github.com/mitsuhiko/minijinja --path-only
scripts/checkout.sh git@github.com:mitsuhiko/minijinja.git --path-only
Features:
- Partial clone (
--filter=blob:none) for efficiency
- Throttled refresh (every 5 minutes by default)
- Fast-forward merge when checkout is clean
- Force refresh with
--force-update
Cloning New Repos
When a repo needs to be cloned (not just cached), use gum clone which
analyses your existing project structure and suggests the right directory:
gum clone hashicorp/terraform
gum clone --suggest hashicorp/terraform
gum clone --target ~/projects/hashicorp/terraform hashicorp/terraform
Rules
- Search locally first. Don't clone what's already on disk.
- Cache for reading, clone for working. Use
checkout.sh when you
just need to read/reference; use gum clone when you need a proper
working copy.
- Don't edit cached repos. Create a worktree or copy instead.
- Prefer gum projects over find. It's indexed and fast. Only fall
back to
find if gum is unavailable.