git-repo-discovery
shalomb/agent-skills/skills/git-repo-discovery/SKILL.md
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.
Skill3 starsChanged 41 days ago
What's in it
- Librarian — Repository Finder & Cache
- Quick Reference
- Strategy: Local First
- Finding Local Repos
- Caching Remote Repos
- Cloning New Repos
- Rules
---
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**:
```bash
# Step 1: Search local projects (fast — uses gum's indexed DB)
gum projects --format json | jq -r '.[] | select(.remote | test("SEARCH_TERM")) | .path'
# Step 2: If not found locally, check the cache
scripts/checkout.sh org/repo --path-only
# Step 3: Only clone if truly missing (gum picks the right directory)
gum clone org/repo
```
## Finding Local Repos
The `gum` CLI maintains an indexed database of all git repos under `~/`:
```bash
# All repos as JSON (path, remote, branch)
gum projects --format json
# Simple list of paths
gum projects --format simple
# Force re-scan
gum projects --refresh --format simple
# Search examples
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>`:
```bash
# These all resolve to the same checkout:
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:
```bash
# Clone with intelligent directory suggestion
gum clone hashicorp/terraform
# Just see where it would go
gum clone --suggest hashicorp/terraform
# Force a specific location
gum clone --target ~/projects/hashicorp/terraform hashicorp/terraform
```
## Rules
1. **Search locally first.** Don't clone what's already on disk.
2. **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.
3. **Don't edit cached repos.** Create a worktree or copy instead.
4. **Prefer gum projects over find.** It's indexed and fast. Only fall
back to `find` if gum is unavailable.
More agent context in shalomb/agent-skills
86 other files this repository gives its agents, the first 60 shown.
AGENTS.md
Skill
- adrskills/adr/SKILL.md
- adzic-bddskills/adzic-bdd/SKILL.md
- agent-md-refactorskills/agent-md-refactor/SKILL.md
- agent-muxskills/agent-mux/SKILL.md
- agent-role-impersonatorskills/agent-role-impersonator/SKILL.md
- agilquest-reservationsskills/agilquest-reservations/SKILL.md
- ai-text-humanizerskills/ai-text-humanizer/SKILL.md
- architecture-decision-recordsskills/architecture-decision-records/SKILL.md
- ast-grepskills/ast-grep/SKILL.md
- atacskills/atac/SKILL.md
- aws-cliskills/aws-cli/SKILL.md
- bart-adversarial-reviewerskills/bart-adversarial-reviewer/SKILL.md
- bddskills/bdd/SKILL.md
- branch-doctorskills/branch-doctor/SKILL.md
- c4-architectureskills/c4-architecture/SKILL.md
- c4skills/c4/SKILL.md
- claude-sub-agentskills/claude-sub-agent/SKILL.md
- codemap-config-setupskills/codemap-config-setup/SKILL.md
- codemap-exploreskills/codemap-explore/SKILL.md
- codemap-handoffskills/codemap-handoff/SKILL.md
- codemap-hub-safetyskills/codemap-hub-safety/SKILL.md
- codemapskills/codemap/SKILL.md
- commitskills/commit/SKILL.md
- copilot-sub-agentskills/copilot-sub-agent/SKILL.md
- daily-standupskills/daily-standup/SKILL.md
- daily-statusskills/daily-status/SKILL.md
- debugskills/debug/SKILL.md
- design-thinkingskills/design-thinking/SKILL.md
- doctorskills/doctor/SKILL.md
- docx-word-processorskills/docx-word-processor/SKILL.md
- farley-tddskills/farley-tdd/SKILL.md
- forensicsskills/forensics/SKILL.md
- gemini-sub-agentskills/gemini-sub-agent/SKILL.md
- git-commit-formatterskills/git-commit-formatter/SKILL.md
- git-forensicsskills/git-forensics/SKILL.md
- github-actions-permissionsskills/github-actions-permissions/SKILL.md
- github-cliskills/github-cli/SKILL.md
- git-safety-guardrailsskills/git-safety-guardrails/SKILL.md
- harness-idpskills/harness-idp/SKILL.md
- humanizeskills/humanize/SKILL.md
- iteration-plannerskills/iteration-planner/SKILL.md
- jira-issue-managerskills/jira-issue-manager/SKILL.md
- justfile-assistantskills/justfile-assistant/SKILL.md
- kiro-sub-agentskills/kiro-sub-agent/SKILL.md
- lessons-learnedskills/lessons-learned/SKILL.md
- lessonsskills/lessons/SKILL.md
- lisa-planning-agentskills/lisa-planning-agent/SKILL.md
- lovejoy-release-agentskills/lovejoy-release-agent/SKILL.md
- lsp-code-analysisskills/lsp-code-analysis/SKILL.md
- macro-to-microskills/macro-to-micro/SKILL.md
- marge-product-agentskills/marge-product-agent/SKILL.md
- meeting-notesskills/meeting-notes/SKILL.md
- mermaid-diagram-generatorskills/mermaid-diagram-generator/SKILL.md
- modern-cli-overridesskills/modern-cli-overrides/SKILL.md
- native-web-searchskills/native-web-search/SKILL.md
- obsidian-notetakerskills/obsidian-notetaker/SKILL.md
- outlook-headlessskills/outlook-headless/SKILL.md
- pdf-document-processorskills/pdf-document-processor/SKILL.md
- pi-sub-agentskills/pi-sub-agent/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

