AgentSkillsCN

status

显示同步状态与待处理变更

SKILL.md
--- frontmatter
name: status
description: Show sync status and pending changes

Sync Status

Show current sync status and any pending changes.

Usage

code
/claude-github-sync:status

Configuration Reference

ItemPathDescription
Config file~/.claude/sync-config.jsonSync configuration (repo URL, setup method)
Git remote~/.claude/.git/configPrimary check - git origin remote URL
Git repo~/.claude/.git/Must exist for sync to be initialized
Sync settings~/.claude/settings.sync.jsonShared settings (synced to GitHub)
Local settings~/.claude/settings.local.jsonMachine-specific settings (gitignored)
Merged output~/.claude/settings.jsonAuto-merged result of sync + local

Instructions

Execute:

bash
echo "📊 Claude GitHub Sync Status"
echo "============================"

cd ~/.claude

# Check if git repo exists
if [ ! -d ".git" ]; then
    echo ""
    echo "❌ Not initialized"
    echo ""
    echo "Run one of:"
    echo "  /claude-github-sync:setup       - Interactive setup (recommended)"
    echo "  /claude-github-sync:init <url>  - Manual setup"
    exit 0
fi

GitHub CLI Status (if available)

bash
echo ""
echo "🔐 Authentication:"
if command -v gh &>/dev/null; then
    if gh auth status --hostname github.com &>/dev/null 2>&1; then
        echo "  ✅ GitHub CLI authenticated"
        gh auth status --hostname github.com 2>&1 | grep "Logged in" | head -1 | sed 's/^/  /'
    else
        echo "  ⚠️  GitHub CLI not authenticated"
        echo "     Run: gh auth login"
    fi
else
    echo "  ⚠️  GitHub CLI not installed (optional but recommended)"
    echo "     Install: brew install gh"
fi

Remote Repository Status

bash
echo ""
echo "🌐 Remote Repository:"
REPO_URL=$(git remote get-url origin 2>/dev/null)
if [ -n "$REPO_URL" ]; then
    echo "  URL: $REPO_URL"

    # Check if repo is accessible (if gh available)
    if command -v gh &>/dev/null; then
        REPO_PATH=$(echo "$REPO_URL" | sed -E 's|.*github.com[:/]||' | sed 's|\.git$||')
        if gh repo view "$REPO_PATH" &>/dev/null 2>&1; then
            echo "  ✅ Repository accessible"
            # Get repo visibility
            VISIBILITY=$(gh repo view "$REPO_PATH" --json isPrivate --jq 'if .isPrivate then "private" else "public" end' 2>/dev/null)
            [ -n "$VISIBILITY" ] && echo "  Visibility: $VISIBILITY"
        else
            echo "  ❌ Repository not accessible (check permissions)"
        fi
    fi
else
    echo "  ❌ Not configured"
fi

Local Changes

bash
echo ""
echo "📝 Local Changes:"
CHANGES=$(git status --short 2>/dev/null)
if [ -n "$CHANGES" ]; then
    echo "$CHANGES" | head -10 | sed 's/^/  /'
    TOTAL=$(echo "$CHANGES" | wc -l | tr -d ' ')
    [ "$TOTAL" -gt 10 ] && echo "  ... and $((TOTAL - 10)) more"
else
    echo "  ✅ No pending changes"
fi

Sync Status

bash
echo ""
echo "🔄 Sync Status:"
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
echo "  Branch: $BRANCH"

# Check if we're ahead/behind remote
git fetch origin "$BRANCH" --quiet 2>/dev/null
AHEAD=$(git rev-list --count "origin/$BRANCH..HEAD" 2>/dev/null || echo "?")
BEHIND=$(git rev-list --count "HEAD..origin/$BRANCH" 2>/dev/null || echo "?")

if [ "$AHEAD" = "0" ] && [ "$BEHIND" = "0" ]; then
    echo "  ✅ In sync with remote"
elif [ "$AHEAD" != "?" ] && [ "$BEHIND" != "?" ]; then
    [ "$AHEAD" != "0" ] && echo "  ⬆️  $AHEAD commit(s) ahead (run: /claude-github-sync:push)"
    [ "$BEHIND" != "0" ] && echo "  ⬇️  $BEHIND commit(s) behind (run: /claude-github-sync:pull)"
else
    echo "  ⚠️  Unable to determine sync status"
fi

Recent Commits

bash
echo ""
echo "📜 Recent Commits:"
git log --oneline -3 2>/dev/null | sed 's/^/  /' || echo "  No commits yet"

Report result to user.