Synchroniser les modifications vers GitHub

VérifiéPrudence

Pousse les modifications locales de configuration vers un dépôt GitHub. Vérifie la présence d'un remote Git, effectue un commit avec un message personnalisable (par défaut 'Update Claude Code configuration'), puis pousse la branche. Utile pour synchroniser manuellement vos paramètres Claude Code avec un dépôt distant.

Spar Skills Guide Bot
DeveloppementDébutant
6002/06/2026
Claude Code
#claude-code#github-sync#configuration#push

Recommandé pour

Notre avis

Cette compétence pousse les modifications de configuration locales de Claude Code vers un dépôt GitHub.

Points forts

  • Automatise la synchronisation des configurations vers GitHub.
  • Gère les commits avec des messages personnalisables.
  • Vérifie l'authentification et l'existence du dépôt distant.
  • Fournit un résumé des fichiers modifiés après le push.

Limites

  • Nécessite une configuration préalable du dépôt git dans ~/.claude.
  • Ne fonctionne qu'avec GitHub (pas d'autres forges).
  • Dépend de l'interface en ligne de commande `gh` pour certaines vérifications.
Quand l'utiliser

Utilisez cette compétence lorsque vous souhaitez sauvegarder et versionner votre configuration Claude Code sur GitHub.

Quand l'éviter

Évitez de l'utiliser si vous ne voulez pas versionner votre configuration ou si vous utilisez un autre hébergeur git.

Analyse de sécurité

Prudence
Score qualité85/100

The skill automates pushing local configuration to GitHub using git and gh CLI. While the operations are legitimate and well-contained, they involve network communication and file staging that could accidentally expose sensitive data if misconfigured. No destructive or obfuscated actions are present.

Points d'attention
  • Runs multiple bash commands including git push, which could publish local files to a remote repository
  • Uses `git add -A` which stages all changes in ~/.claude, potentially including unintended files
  • Relies on external CLI tools (gh, git) that may not be available or authenticated

Exemples

Push with default message
/claude-github-sync:push
Push with custom message
/claude-github-sync:push "Updated settings for new project"

name: push description: Push configuration changes to GitHub

Push Configuration

Push local configuration changes to GitHub.

Usage

/claude-github-sync:push
/claude-github-sync:push "Custom commit message"

Configuration Reference

| Item | Path | Description | |------|------|-------------| | Config file | ~/.claude/sync-config.json | Sync configuration (repo URL, setup method) | | Git remote | ~/.claude/.git/config | Primary check - git origin remote URL | | Sync settings | ~/.claude/settings.sync.json | Shared settings (synced to GitHub) | | Local settings | ~/.claude/settings.local.json | Machine-specific settings (gitignored) | | Merged output | ~/.claude/settings.json | Auto-merged result of sync + local |

Instructions

Step 1: Check git remote (primary check)

The sync is configured if ~/.claude has a git remote. Config file (~/.claude/sync-config.json) is optional fallback.

cd ~/.claude

# Primary check: git remote
REPO_URL=$(git remote get-url origin 2>/dev/null)
if [ -n "$REPO_URL" ]; then
    echo "✅ Remote configured: $REPO_URL"
else
    # Fallback: check config file
    CONFIG_FILE="$HOME/.claude/sync-config.json"
    if [ -f "$CONFIG_FILE" ]; then
        echo "⚠️  Config exists but no git remote"
        echo "Run: /claude-github-sync:setup to fix"
        exit 1
    else
        echo "❌ Not configured"
        echo ""
        echo "Run one of:"
        echo "  /claude-github-sync:setup       - Interactive setup (recommended)"
        echo "  /claude-github-sync:init <url>  - Manual setup with URL"
        exit 1
    fi
fi

Step 2: Verify gh CLI and authentication

# Check if gh CLI is available (for better error messages)
if command -v gh &>/dev/null; then
    if ! gh auth status --hostname github.com &>/dev/null 2>&1; then
        echo "⚠️  GitHub CLI not authenticated"
        echo "   Run: gh auth login"
        echo ""
        echo "Attempting push anyway (may fail)..."
    fi
fi

Step 3: Verify remote repository exists (optional)

# REPO_URL already set in Step 1
# Verify remote exists only if gh CLI is 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 "⚠️  Cannot verify remote: $REPO_PATH"
        echo "   (May still work if repo exists)"
    fi
fi

Step 4: Stage and commit

Extract optional commit message from $ARGUMENTS. Default: "Update Claude Code configuration"

cd ~/.claude

# Get current branch
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")

# Stage all changes
git add -A

# Check if there are changes to commit
if git diff --cached --quiet; then
    echo "✅ Nothing to push - already in sync"
    exit 0
fi

# Commit with message
MESSAGE="${ARGUMENTS:-Update Claude Code configuration}"
git commit -m "$MESSAGE"
echo "✅ Committed: $MESSAGE"

Step 5: Push to remote

# Push with upstream tracking
if git push -u origin "$BRANCH" 2>&1; then
    echo "✅ Pushed to GitHub ($BRANCH)"
else
    echo ""
    echo "❌ Push failed"
    echo ""
    echo "Troubleshooting:"
    echo "  1. Check authentication: gh auth status"
    echo "  2. Pull first if remote has changes: /claude-github-sync:pull"
    echo "  3. Check network connection"
    echo ""
    echo "For detailed git error, run:"
    echo "  cd ~/.claude && git push -u origin $BRANCH"
    exit 1
fi

Step 6: Show summary

Show what was pushed, including file changes and commit details.

echo ""
echo "📊 Push Summary:"
echo ""
echo "--- Commit ---"
git log --oneline -1
echo ""
echo "--- Files changed ---"
git diff --stat HEAD~1..HEAD 2>/dev/null || echo "  (first commit)"
echo ""
echo "Remote: $REPO_URL"
Skills similaires