Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

git-repo-detection

БесплатноБез исполняемых скриптовНе проверен

Detect GitHub repo owner/name from git remotes. Use when needing the owner/repo identifier for GitHub CLI or API calls, especially across multiple repos.

laurigatesот laurigates★ 61 звезда на GitHub6 установок в других каталогах

Об этом скилле

Git Repository Detection

When to Use This Skill

Use this skill when... Use the alternative when...
Extracting owner/repo from a git remote (HTTPS or SSH URL) for gh calls Use gh-cli-agentic once you already have the owner/repo identifier
Handling GitHub Enterprise host URLs alongside github.com Use git-fork-workflow when the question is fork vs upstream identification
Resolving the repo identifier to pass with gh -R to avoid remote-required errors Use git-cli-agentic for raw git remote -v parsing if you need URL details
Detecting which repo a script is running inside before issuing API calls Use git-coworker-check to detect concurrent agents in the same checkout

Expert knowledge for detecting and extracting GitHub repository information from git remotes, including repository name, owner, and full identifiers.

Core Expertise

Repository Identification

  • Extract owner and repository name from git remotes
  • Parse GitHub URLs (HTTPS and SSH)
  • Handle GitHub Enterprise URLs
  • Format as owner/repo for CLI/API usage

URL Parsing

  • Parse HTTPS URLs: https://github.com/owner/repo.git
  • Parse SSH URLs: [email protected]:owner/repo.git
  • Handle custom domains: https://github.enterprise.com/owner/repo.git
  • Clean .git suffix and extra paths

Essential Commands

Get Remote URLs

# List all remotes
git remote -v

# Get origin URL
git remote get-url origin

# Get specific remote
git remote get-url upstream

# Show remote details
git remote show origin

Extract Repository Name

# From HTTPS URL
git remote get-url origin | sed 's/.*\/\([^/]*\)\.git/\1/'

# From SSH URL
git remote get-url origin | sed 's/.*:\([^/]*\/[^/]*\)\.git/\1/' | cut -d'/' -f2

# From any URL (owner/repo format)
git remote get-url origin | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/'

# Just repository name (no owner)
basename $(git remote get-url origin) .git

Extract Owner

# From any URL
git remote get-url origin | sed 's/.*[:/]\([^/]*\)\/[^/]*\.git/\1/'

# Alternative with awk
git remote get-url origin | awk -F '[:/]' '{print $(NF-1)}'

Get Full Identifier (owner/repo)

# Standard format for GitHub CLI/API
git remote get-url origin | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/'

# With validation
REPO=$(git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/')
echo "${REPO:-Unknown}"

# Store in variable
REPO_FULL=$(git remote get-url origin | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/')
echo "Repository: $REPO_FULL"

URL Format Examples

HTTPS URLs

# Standard GitHub
https://github.com/owner/repo.git
# Extract: owner/repo

# Without .git suffix
https://github.com/owner/repo
# Extract: owner/repo

# GitHub Enterprise
https://github.company.com/owner/repo.git
# Extract: owner/repo

SSH URLs

# Standard SSH
[email protected]:owner/repo.git
# Extract: owner/repo

# Custom SSH port
ssh://[email protected]:443/owner/repo.git
# Extract: owner/repo

# Enterprise SSH
[email protected]:owner/repo.git
# Extract: owner/repo

Parsing Patterns

Universal Parser (HTTPS or SSH)

# Works for both HTTPS and SSH
parse_repo() {
  local url="$1"
  # Remove .git suffix
  url="${url%.git}"
  # Extract owner/repo
  if [[ "$url" =~ github\.com[:/]([^/]+/[^/]+) ]]; then
    echo "${BASH_REMATCH[1]}"
  elif [[ "$url" =~ :([^/]+/[^/]+)$ ]]; then
    echo "${BASH_REMATCH[1]}"
  fi
}

REPO=$(parse_repo "$(git remote get-url origin)")
echo "$REPO"

Robust Extraction with sed

# Handle both HTTPS and SSH, with or without .git
git remote get-url origin \
  | sed -E 's#.*github\.com[:/]##; s#\.git$##'

Using awk

# Split by : or / and get last two components
git remote get-url origin \
  | awk -F'[/:]' '{print $(NF-1)"/"$NF}' \
  | sed 's/\.git$//'

Real-World Usage

With GitHub CLI

# Get repo identifier for gh commands
REPO=$(git remote get-url origin | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/')

# Use with gh
gh repo view "$REPO"
gh issue list --repo "$REPO"
gh pr list --repo "$REPO"

# Or use current directory (gh auto-detects)
gh repo view

For API usage, multiple remotes, scripts, aliases, and integration examples, see REFERENCE.md.

Edge Cases

Case Check
No remote git remote get-url origin &>/dev/null
Non-GitHub git remote get-url origin | grep -q github.com
Multiple remotes Use git remote get-url upstream for fork source
Submodule git -C "$(git rev-parse --show-toplevel)" remote get-url origin

Quick Reference

Purpose Command
Full identifier (owner/repo) git remote get-url origin | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/'
Owner only git remote get-url origin | sed 's/.*[:/]\([^/]*\)\/[^/]*\.git/\1/'
Name only basename $(git remote get-url origin) .git
Is GitHub? `git remote get-ur
Полный SKILL.md на GitHub

Установить git-repo-detection в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(git remote -v)
Bash(git remote get-url *)
Bash(git remote show *)
Bash(git rev-parse *)
Bash(sed *)
Bash(awk *)
Bash(cut *)
Bash(grep *)
Bash(gh repo view *)
Bash(gh issue list *)
Bash(gh pr list *)
Read
Grep

Вложенные файлы

REFERENCE.md

FAQ

Что делает скилл git-repo-detection?

Detect GitHub repo owner/name from git remotes. Use when needing the owner/repo identifier for GitHub CLI or API calls, especially across multiple repos.

Как установить скилл git-repo-detection?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл git-repo-detection запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить git-repo-detection с