[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C2EY01FZPQNVCZS50TJC6B":3,"skill-same:01M6C2EY01FZPQNVCZS50TJC6B":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":44,"install":45,"resources":58},"01M6C2EY01FZPQNVCZS50TJC6B","sync",null,"\u002Fsync - Synchronize a local branch with a GitHub PR (fetch, switch\u002Fcreate branch, match remote PR state)","jleechanorg\u002Fjleechan-skills","jleechanorg","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F221404966?v=4","01M6C1VJ99XG950X1DWPEBCBGX","01M6C1VJDK5YVDNT3362RT5WSB",6,"MIT","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsync\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"github","pr","create","state","create branch","branch","user","fetch","switch","github pr","local","remote","with","match","2026-11-10 10:12:30",false,"---\nname: sync\ndescription: \u002Fsync - Synchronize a local branch with a GitHub PR (fetch, switch\u002Fcreate branch, match remote PR state)\ntype: skill\nscope: user\n---\n\n# \u002Fsync - Synchronize Local Branch with PR\n\n## Description\n\nSynchronizes local branch with a GitHub PR by fetching, switching\u002Fcreating branch, and ensuring local copy matches remote PR state.\n\n## Usage\n\n- `\u002Fsync \u003Cpr_number>` - Sync with PR by number\n- `\u002Fsync \u003Cpr_url>` - Sync with PR by GitHub URL\n\n## Implementation\n\n```bash\n\n# Check for required tools\n\nif ! command -v gh >\u002Fdev\u002Fnull 2>&1; then\n    echo \"❌ Error: GitHub CLI (gh) is required but not installed\"\n    exit 1\nfi\n\nif ! command -v jq >\u002Fdev\u002Fnull 2>&1; then\n    echo \"❌ Error: jq is required but not installed\"\n    exit 1\nfi\n\n# ALWAYS fetch latest info from remote first - ensures we know about ALL branches\n# Fail hard if any remote fetch fails so we don't end up partially pruned\necho \"? Fetching latest info from all remotes...\"\nif ! git fetch --all --prune; then\n    echo \"❌ Error: Failed to fetch from all remotes. Please resolve git remote issues and try again.\"\n    exit 1\nfi\necho \"✅ Remote refs updated\"\n\n# Parse input to extract PR number\n\nif [[ \"$1\" =~ ^[0-9]+$ ]]; then\n    PR_NUMBER=\"$1\"\nelif [[ \"$1\" =~ github\\.com.*pull\u002F([0-9]+) ]]; then\n    PR_NUMBER=$(echo \"$1\" | grep -o 'pull\u002F[0-9]*' | cut -d'\u002F' -f2)\nelse\n    echo \"❌ Invalid input. Use PR number or GitHub PR URL\"\n    exit 1\nfi\n\necho \"? Syncing with PR #$PR_NUMBER...\"\n\n# Get PR info using gh CLI\n\nPR_INFO=$(gh pr view \"$PR_NUMBER\" --json headRefName,baseRefName,headRepository,headRepositoryOwner 2>\u002Fdev\u002Fnull)\nif [ $? -ne 0 ]; then\n    echo \"❌ Failed to fetch PR #$PR_NUMBER info\"\n    exit 1\nfi\n\n# Extract branch information\n\nHEAD_BRANCH=$(echo \"$PR_INFO\" | jq -r '.headRefName')\nBASE_BRANCH=$(echo \"$PR_INFO\" | jq -r '.baseRefName')\nHEAD_REPO=$(echo \"$PR_INFO\" | jq -r '(.headRepositoryOwner.login \u002F\u002F \"\" )')\nif [ -z \"$HEAD_REPO\" ]; then\n    HEAD_REPO=$(echo \"$PR_INFO\" | jq -r '(.headRepository.nameWithOwner \u002F\u002F \"\" )' | awk -F'\u002F' '{print $1}')\nfi\nif [ -z \"$HEAD_REPO\" ]; then\n    HEAD_REPO=$(gh api repos\u002F:owner\u002F:repo --jq .owner.login)\nfi\nREMOTE_BRANCH=\"$HEAD_BRANCH\"  # Store original remote branch name\n\nCURRENT_ORIGIN_URL=$(git remote get-url origin 2>\u002Fdev\u002Fnull || echo \"\")\nCURRENT_OWNER=\"\"\nif [[ \"$CURRENT_ORIGIN_URL\" == git@github.com:* ]]; then\n    CURRENT_OWNER=\"${CURRENT_ORIGIN_URL#git@github.com:}\"\n    CURRENT_OWNER=\"${CURRENT_OWNER%%\u002F*}\"\nelif [[ \"$CURRENT_ORIGIN_URL\" == https:\u002F\u002Fgithub.com\u002F* ]] || [[ \"$CURRENT_ORIGIN_URL\" == http:\u002F\u002Fgithub.com\u002F* ]]; then\n    CURRENT_OWNER=\"${CURRENT_ORIGIN_URL#*:\u002F\u002Fgithub.com\u002F}\"\n    CURRENT_OWNER=\"${CURRENT_OWNER%%\u002F*}\"\nfi\nif [ -z \"$CURRENT_OWNER\" ]; then\n    CURRENT_OWNER=$(gh api repos\u002F:owner\u002F:repo --jq .owner.login 2>\u002Fdev\u002Fnull || echo \"\")\nfi\n\necho \"? PR #$PR_NUMBER: $HEAD_BRANCH -> $BASE_BRANCH (owner=$HEAD_REPO; repo=$CURRENT_OWNER)\"\n\n# Handle fork PRs using gh pr checkout\n\nif [ -n \"$HEAD_REPO\" ] && [ -n \"$CURRENT_OWNER\" ] && [ \"$HEAD_REPO\" != \"$CURRENT_OWNER\" ]; then\n    echo \"? Fork detected, using gh pr checkout for proper remote setup...\"\n    gh pr checkout \"$PR_NUMBER\"\nelse\n    # Remote refs already fetched at start - proceed with branch operations\n\n    # ALWAYS try to switch to a local branch mirroring the remote branch name\n    CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)\n    SWITCHED_TO_TARGET=false  # Track if we successfully switched to target branch\n\n    # Check if local branch with target name already exists\n    if git show-ref --verify --quiet \"refs\u002Fheads\u002F$HEAD_BRANCH\"; then\n        # Local branch exists - try to checkout\n        if git checkout \"$HEAD_BRANCH\" 2>\u002Fdev\u002Fnull; then\n            echo \"? Switched to existing branch: $HEAD_BRANCH\"\n            SWITCHED_TO_TARGET=true\n        else\n            # Branch locked in another worktree - find which one\n            # Note: git worktree list --porcelain outputs branch as refs\u002Fheads\u002Fbranch-name\n            # Use substr to capture full path including spaces (everything after \"worktree \")\n            WORKTREE_INFO=$(git worktree list --porcelain 2>\u002Fdev\u002Fnull | awk -v br=\"refs\u002Fheads\u002F$HEAD_BRANCH\" '\u002F^worktree \u002F{path=substr($0,10)} \u002F^branch \u002F && $2==br {print path}' )\n            if [ -z \"$WORKTREE_INFO\" ]; then\n                WORKTREE_INFO=\"unknown location\"\n            fi\n            echo \"? Attempting to resolve branch conflict with remote...\"\n\n            # Try to free the branch by switching the OTHER worktree off it,\n            # so this directory can check it out directly (matches user intent:\n            # \"checkout the PR branch here\" means HERE, not a differently-named\n            # local mirror). Only ever touches the other worktree when it is\n            # verified clean (no uncommitted changes) -- a dirty other worktree\n            # is left completely alone and we fall back to the sync-branch path.\n            FREED_OTHER_WORKTREE=false\n            if [ \"$WORKTREE_INFO\" != \"unknown location\" ] && [ -d \"$WORKTREE_INFO\" ]; then\n                OTHER_DIRTY=$(git -C \"$WORKTREE_INFO\" status --porcelain 2>\u002Fdev\u002Fnull)\n                if [ -n \"$OTHER_DIRTY\" ]; then\n                    echo \"⚠️ Branch $HEAD_BRANCH is checked out elsewhere with uncommitted changes: $WORKTREE_INFO\"\n                    echo \"⚠️ Leaving that worktree untouched; falling back to a local sync branch here.\"\n                else\n                    OTHER_COMMIT=$(git -C \"$WORKTREE_INFO\" rev-parse HEAD 2>\u002Fdev\u002Fnull)\n                    if git -C \"$WORKTREE_INFO\" checkout --detach \"$OTHER_COMMIT\" 2>\u002Fdev\u002Fnull; then\n                        echo \"✅ Switched other worktree off $HEAD_BRANCH (now detached at $OTHER_COMMIT): $WORKTREE_INFO\"\n                        FREED_OTHER_WORKTREE=true\n                    else\n                        echo \"⚠️ Could not switch other worktree off $HEAD_BRANCH: $WORKTREE_INFO\"\n                    fi\n                fi\n            fi\n\n            if [ \"$FREED_OTHER_WORKTREE\" = \"true\" ] && git checkout \"$HEAD_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"? Switched to freed branch: $HEAD_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n            echo \"⚠️ Checkout failed for $HEAD_BRANCH; creating a safe local sync branch instead.\"\n            if [ \"$WORKTREE_INFO\" != \"unknown location\" ]; then\n                echo \"⚠️ Branch $HEAD_BRANCH is checked out elsewhere: $WORKTREE_INFO\"\n            fi\n\n            # Create a unique local branch that still tracks the PR remote branch.\n            # This avoids blocking the existing checked-out worktree and preserves both copies.\n            SYNC_BRANCH_BASE=\"${HEAD_BRANCH}__sync-${PR_NUMBER}\"\n            SYNC_BRANCH=\"$SYNC_BRANCH_BASE\"\n            SYNC_SUFFIX=1\n            while git show-ref --verify --quiet \"refs\u002Fheads\u002F$SYNC_BRANCH\"; do\n                SYNC_BRANCH=\"${SYNC_BRANCH_BASE}-${SYNC_SUFFIX}\"\n                SYNC_SUFFIX=$((SYNC_SUFFIX + 1))\n            done\n\n            if git checkout -b \"$SYNC_BRANCH\" --track \"origin\u002F$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"✅ Created local sync branch: $SYNC_BRANCH (tracking origin\u002F$REMOTE_BRANCH)\"\n                HEAD_BRANCH=\"$SYNC_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n                echo \"❌ Failed to create local sync branch $SYNC_BRANCH\"\n                echo \"? Falling back to syncing content on current branch...\"\n                if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                    exit 1\n                fi\n                if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to reset to remote state\"\n                    exit 1\n                fi\n                echo \"✅ Content synced to remote state\"\n                echo \"? Stayed on $CURRENT_BRANCH and replaced content from origin\u002F$REMOTE_BRANCH.\"\n                HEAD_BRANCH=\"$CURRENT_BRANCH\"\n            fi\n            fi\n        fi\n    else\n        # No local branch exists - create it from remote\n        if [ \"$CURRENT_BRANCH\" != \"$HEAD_BRANCH\" ]; then\n            echo \"? Creating local branch to mirror remote: $HEAD_BRANCH\"\n            if git checkout -b \"$HEAD_BRANCH\" \"origin\u002F$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"✅ Switched to new local branch: $HEAD_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n                echo \"❌ Failed to create branch $HEAD_BRANCH\"\n                echo \"? Syncing content on current branch instead...\"\n                if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                    exit 1\n                fi\n                if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to reset to remote state\"\n                    exit 1\n                fi\n                echo \"✅ Content synced to remote state\"\n                HEAD_BRANCH=\"$CURRENT_BRANCH\"\n            fi\n        else\n            # Edge case: Already on a branch with target name but ref doesn't exist\n            # (can happen with corrupted refs or detached HEAD with matching name)\n            echo \"ℹ️ Already on target branch name; ensuring content is up to date...\"\n            SWITCHED_TO_TARGET=true\n            if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                exit 1\n            fi\n            if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to reset to remote state\"\n                exit 1\n            fi\n            echo \"✅ Content synced to remote state on $CURRENT_BRANCH\"\n        fi\n    fi\n\n    # Set upstream tracking only if we successfully switched to target branch\n    # (Don't corrupt upstream tracking on fallback branches)\n    if [ \"$SWITCHED_TO_TARGET\" = \"true\" ]; then\n        echo \"? Setting upstream tracking...\"\n        git branch --set-upstream-to=origin\u002F\"$REMOTE_BRANCH\" \"$HEAD_BRANCH\"\n\n        # Pull latest changes\n        echo \"⬇️ Pulling latest changes...\"\n        if git pull origin \"$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n            echo \"✅ Successfully pulled changes\"\n        else\n            echo \"⚠️ Pull failed, trying to reset to remote state...\"\n            if ! git reset --hard origin\u002F\"$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to reset to remote state\"\n                exit 1\n            fi\n            echo \"✅ Reset to remote state successful\"\n        fi\n    else\n        echo \"⚠️ Skipping upstream tracking (fell back to $HEAD_BRANCH, not target branch)\"\n        echo \"? Content synced but branch name differs from PR branch\"\n    fi\nfi\n\n# Verify sync status\n\necho \"? Verifying sync status...\"\nLOCAL_COMMIT=$(git rev-parse HEAD)\nREMOTE_COMMIT=$(git rev-parse origin\u002F\"$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull || echo \"unknown\")\n\nif [ \"$LOCAL_COMMIT\" = \"$REMOTE_COMMIT\" ]; then\n    echo \"✅ Local branch perfectly synced with remote\"\nelse\n    echo \"⚠️ Local\u002Fremote mismatch detected\"\n    echo \"   Local:  $LOCAL_COMMIT\"\n    echo \"   Remote: $REMOTE_COMMIT\"\nfi\n\n# Show current status\n\necho \"? Current status:\"\ngit status --short\necho \"? Current branch: $(git rev-parse --abbrev-ref HEAD)\"\necho \"✨ Synced with PR #$PR_NUMBER ($REMOTE_BRANCH)\"\n```\n\n## Success Criteria\n\n- ✅ Branch exists locally and matches remote\n- ✅ All changes from PR are present\n- ✅ Clean working directory\n- ✅ Upstream tracking configured\n","# \u002Fsync - Synchronize Local Branch with PR\n\n## Description\n\nSynchronizes local branch with a GitHub PR by fetching, switching\u002Fcreating branch, and ensuring local copy matches remote PR state.\n\n## Usage\n\n- `\u002Fsync \u003Cpr_number>` - Sync with PR by number\n- `\u002Fsync \u003Cpr_url>` - Sync with PR by GitHub URL\n\n## Implementation\n\n```bash\n\n# Check for required tools\n\nif ! command -v gh >\u002Fdev\u002Fnull 2>&1; then\n    echo \"❌ Error: GitHub CLI (gh) is required but not installed\"\n    exit 1\nfi\n\nif ! command -v jq >\u002Fdev\u002Fnull 2>&1; then\n    echo \"❌ Error: jq is required but not installed\"\n    exit 1\nfi\n\n# ALWAYS fetch latest info from remote first - ensures we know about ALL branches\n# Fail hard if any remote fetch fails so we don't end up partially pruned\necho \"? Fetching latest info from all remotes...\"\nif ! git fetch --all --prune; then\n    echo \"❌ Error: Failed to fetch from all remotes. Please resolve git remote issues and try again.\"\n    exit 1\nfi\necho \"✅ Remote refs updated\"\n\n# Parse input to extract PR number\n\nif [[ \"$1\" =~ ^[0-9]+$ ]]; then\n    PR_NUMBER=\"$1\"\nelif [[ \"$1\" =~ github\\.com.*pull\u002F([0-9]+) ]]; then\n    PR_NUMBER=$(echo \"$1\" | grep -o 'pull\u002F[0-9]*' | cut -d'\u002F' -f2)\nelse\n    echo \"❌ Invalid input. Use PR number or GitHub PR URL\"\n    exit 1\nfi\n\necho \"? Syncing with PR #$PR_NUMBER...\"\n\n# Get PR info using gh CLI\n\nPR_INFO=$(gh pr view \"$PR_NUMBER\" --json headRefName,baseRefName,headRepository,headRepositoryOwner 2>\u002Fdev\u002Fnull)\nif [ $? -ne 0 ]; then\n    echo \"❌ Failed to fetch PR #$PR_NUMBER info\"\n    exit 1\nfi\n\n# Extract branch information\n\nHEAD_BRANCH=$(echo \"$PR_INFO\" | jq -r '.headRefName')\nBASE_BRANCH=$(echo \"$PR_INFO\" | jq -r '.baseRefName')\nHEAD_REPO=$(echo \"$PR_INFO\" | jq -r '(.headRepositoryOwner.login \u002F\u002F \"\" )')\nif [ -z \"$HEAD_REPO\" ]; then\n    HEAD_REPO=$(echo \"$PR_INFO\" | jq -r '(.headRepository.nameWithOwner \u002F\u002F \"\" )' | awk -F'\u002F' '{print $1}')\nfi\nif [ -z \"$HEAD_REPO\" ]; then\n    HEAD_REPO=$(gh api repos\u002F:owner\u002F:repo --jq .owner.login)\nfi\nREMOTE_BRANCH=\"$HEAD_BRANCH\"  # Store original remote branch name\n\nCURRENT_ORIGIN_URL=$(git remote get-url origin 2>\u002Fdev\u002Fnull || echo \"\")\nCURRENT_OWNER=\"\"\nif [[ \"$CURRENT_ORIGIN_URL\" == git@github.com:* ]]; then\n    CURRENT_OWNER=\"${CURRENT_ORIGIN_URL#git@github.com:}\"\n    CURRENT_OWNER=\"${CURRENT_OWNER%%\u002F*}\"\nelif [[ \"$CURRENT_ORIGIN_URL\" == https:\u002F\u002Fgithub.com\u002F* ]] || [[ \"$CURRENT_ORIGIN_URL\" == http:\u002F\u002Fgithub.com\u002F* ]]; then\n    CURRENT_OWNER=\"${CURRENT_ORIGIN_URL#*:\u002F\u002Fgithub.com\u002F}\"\n    CURRENT_OWNER=\"${CURRENT_OWNER%%\u002F*}\"\nfi\nif [ -z \"$CURRENT_OWNER\" ]; then\n    CURRENT_OWNER=$(gh api repos\u002F:owner\u002F:repo --jq .owner.login 2>\u002Fdev\u002Fnull || echo \"\")\nfi\n\necho \"? PR #$PR_NUMBER: $HEAD_BRANCH -> $BASE_BRANCH (owner=$HEAD_REPO; repo=$CURRENT_OWNER)\"\n\n# Handle fork PRs using gh pr checkout\n\nif [ -n \"$HEAD_REPO\" ] && [ -n \"$CURRENT_OWNER\" ] && [ \"$HEAD_REPO\" != \"$CURRENT_OWNER\" ]; then\n    echo \"? Fork detected, using gh pr checkout for proper remote setup...\"\n    gh pr checkout \"$PR_NUMBER\"\nelse\n    # Remote refs already fetched at start - proceed with branch operations\n\n    # ALWAYS try to switch to a local branch mirroring the remote branch name\n    CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)\n    SWITCHED_TO_TARGET=false  # Track if we successfully switched to target branch\n\n    # Check if local branch with target name already exists\n    if git show-ref --verify --quiet \"refs\u002Fheads\u002F$HEAD_BRANCH\"; then\n        # Local branch exists - try to checkout\n        if git checkout \"$HEAD_BRANCH\" 2>\u002Fdev\u002Fnull; then\n            echo \"? Switched to existing branch: $HEAD_BRANCH\"\n            SWITCHED_TO_TARGET=true\n        else\n            # Branch locked in another worktree - find which one\n            # Note: git worktree list --porcelain outputs branch as refs\u002Fheads\u002Fbranch-name\n            # Use substr to capture full path including spaces (everything after \"worktree \")\n            WORKTREE_INFO=$(git worktree list --porcelain 2>\u002Fdev\u002Fnull | awk -v br=\"refs\u002Fheads\u002F$HEAD_BRANCH\" '\u002F^worktree \u002F{path=substr($0,10)} \u002F^branch \u002F && $2==br {print path}' )\n            if [ -z \"$WORKTREE_INFO\" ]; then\n                WORKTREE_INFO=\"unknown location\"\n            fi\n            echo \"? Attempting to resolve branch conflict with remote...\"\n\n            # Try to free the branch by switching the OTHER worktree off it,\n            # so this directory can check it out directly (matches user intent:\n            # \"checkout the PR branch here\" means HERE, not a differently-named\n            # local mirror). Only ever touches the other worktree when it is\n            # verified clean (no uncommitted changes) -- a dirty other worktree\n            # is left completely alone and we fall back to the sync-branch path.\n            FREED_OTHER_WORKTREE=false\n            if [ \"$WORKTREE_INFO\" != \"unknown location\" ] && [ -d \"$WORKTREE_INFO\" ]; then\n                OTHER_DIRTY=$(git -C \"$WORKTREE_INFO\" status --porcelain 2>\u002Fdev\u002Fnull)\n                if [ -n \"$OTHER_DIRTY\" ]; then\n                    echo \"⚠️ Branch $HEAD_BRANCH is checked out elsewhere with uncommitted changes: $WORKTREE_INFO\"\n                    echo \"⚠️ Leaving that worktree untouched; falling back to a local sync branch here.\"\n                else\n                    OTHER_COMMIT=$(git -C \"$WORKTREE_INFO\" rev-parse HEAD 2>\u002Fdev\u002Fnull)\n                    if git -C \"$WORKTREE_INFO\" checkout --detach \"$OTHER_COMMIT\" 2>\u002Fdev\u002Fnull; then\n                        echo \"✅ Switched other worktree off $HEAD_BRANCH (now detached at $OTHER_COMMIT): $WORKTREE_INFO\"\n                        FREED_OTHER_WORKTREE=true\n                    else\n                        echo \"⚠️ Could not switch other worktree off $HEAD_BRANCH: $WORKTREE_INFO\"\n                    fi\n                fi\n            fi\n\n            if [ \"$FREED_OTHER_WORKTREE\" = \"true\" ] && git checkout \"$HEAD_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"? Switched to freed branch: $HEAD_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n            echo \"⚠️ Checkout failed for $HEAD_BRANCH; creating a safe local sync branch instead.\"\n            if [ \"$WORKTREE_INFO\" != \"unknown location\" ]; then\n                echo \"⚠️ Branch $HEAD_BRANCH is checked out elsewhere: $WORKTREE_INFO\"\n            fi\n\n            # Create a unique local branch that still tracks the PR remote branch.\n            # This avoids blocking the existing checked-out worktree and preserves both copies.\n            SYNC_BRANCH_BASE=\"${HEAD_BRANCH}__sync-${PR_NUMBER}\"\n            SYNC_BRANCH=\"$SYNC_BRANCH_BASE\"\n            SYNC_SUFFIX=1\n            while git show-ref --verify --quiet \"refs\u002Fheads\u002F$SYNC_BRANCH\"; do\n                SYNC_BRANCH=\"${SYNC_BRANCH_BASE}-${SYNC_SUFFIX}\"\n                SYNC_SUFFIX=$((SYNC_SUFFIX + 1))\n            done\n\n            if git checkout -b \"$SYNC_BRANCH\" --track \"origin\u002F$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"✅ Created local sync branch: $SYNC_BRANCH (tracking origin\u002F$REMOTE_BRANCH)\"\n                HEAD_BRANCH=\"$SYNC_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n                echo \"❌ Failed to create local sync branch $SYNC_BRANCH\"\n                echo \"? Falling back to syncing content on current branch...\"\n                if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                    exit 1\n                fi\n                if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to reset to remote state\"\n                    exit 1\n                fi\n                echo \"✅ Content synced to remote state\"\n                echo \"? Stayed on $CURRENT_BRANCH and replaced content from origin\u002F$REMOTE_BRANCH.\"\n                HEAD_BRANCH=\"$CURRENT_BRANCH\"\n            fi\n            fi\n        fi\n    else\n        # No local branch exists - create it from remote\n        if [ \"$CURRENT_BRANCH\" != \"$HEAD_BRANCH\" ]; then\n            echo \"? Creating local branch to mirror remote: $HEAD_BRANCH\"\n            if git checkout -b \"$HEAD_BRANCH\" \"origin\u002F$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n                echo \"✅ Switched to new local branch: $HEAD_BRANCH\"\n                SWITCHED_TO_TARGET=true\n            else\n                echo \"❌ Failed to create branch $HEAD_BRANCH\"\n                echo \"? Syncing content on current branch instead...\"\n                if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                    exit 1\n                fi\n                if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                    echo \"❌ Failed to reset to remote state\"\n                    exit 1\n                fi\n                echo \"✅ Content synced to remote state\"\n                HEAD_BRANCH=\"$CURRENT_BRANCH\"\n            fi\n        else\n            # Edge case: Already on a branch with target name but ref doesn't exist\n            # (can happen with corrupted refs or detached HEAD with matching name)\n            echo \"ℹ️ Already on target branch name; ensuring content is up to date...\"\n            SWITCHED_TO_TARGET=true\n            if ! git fetch origin \"$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to fetch origin\u002F$REMOTE_BRANCH\"\n                exit 1\n            fi\n            if ! git reset --hard \"origin\u002F$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to reset to remote state\"\n                exit 1\n            fi\n            echo \"✅ Content synced to remote state on $CURRENT_BRANCH\"\n        fi\n    fi\n\n    # Set upstream tracking only if we successfully switched to target branch\n    # (Don't corrupt upstream tracking on fallback branches)\n    if [ \"$SWITCHED_TO_TARGET\" = \"true\" ]; then\n        echo \"? Setting upstream tracking...\"\n        git branch --set-upstream-to=origin\u002F\"$REMOTE_BRANCH\" \"$HEAD_BRANCH\"\n\n        # Pull latest changes\n        echo \"⬇️ Pulling latest changes...\"\n        if git pull origin \"$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull; then\n            echo \"✅ Successfully pulled changes\"\n        else\n            echo \"⚠️ Pull failed, trying to reset to remote state...\"\n            if ! git reset --hard origin\u002F\"$REMOTE_BRANCH\"; then\n                echo \"❌ Failed to reset to remote state\"\n                exit 1\n            fi\n            echo \"✅ Reset to remote state successful\"\n        fi\n    else\n        echo \"⚠️ Skipping upstream tracking (fell back to $HEAD_BRANCH, not target branch)\"\n        echo \"? Content synced but branch name differs from PR branch\"\n    fi\nfi\n\n# Verify sync status\n\necho \"? Verifying sync status...\"\nLOCAL_COMMIT=$(git rev-parse HEAD)\nREMOTE_COMMIT=$(git rev-parse origin\u002F\"$REMOTE_BRANCH\" 2>\u002Fdev\u002Fnull || echo \"unknown\")\n\nif [ \"$LOCAL_COMMIT\" = \"$REMOTE_COMMIT\" ]; then\n    echo \"✅ Local branch perfectly synced with remote\"\nelse\n    echo \"⚠️ Local\u002Fremote mismatch detected\"\n    echo \"   Local:  $LOCAL_COMMIT\"\n    echo \"   Remote: $REMOTE_COMMIT\"\nfi\n\n# Show current status\n\necho \"? Current status:\"\ngit status --short\necho \"? Current branch: $(git rev-parse --abbrev-ref HEAD)\"\necho \"✨ Synced with PR #$PR_NUMBER ($REMOTE_BRANCH)\"\n```\n\n## Success Criteria\n\n- ✅ Branch exists locally and matches remote\n- ✅ All changes from PR are present\n- ✅ Clean working directory\n- ✅ Upstream tracking configured\n",{"name":5,"type":37,"scope":24,"description":7},"skill","main","42ccd02cbf5e8e47839dc3eab6fc754dc6b339cf",".claude\u002Fskills\u002Fsync",0,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills","https:\u002F\u002Fgithub.com\u002Fjleechanorg","2026-11-11 09:18:40",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add jleechanorg\u002Fjleechan-skills --skill sync",{"tool":51,"command":52},"bunx","bunx skills add jleechanorg\u002Fjleechan-skills --skill sync",{"tool":54,"command":55},"pnpm","pnpm dlx skills add jleechanorg\u002Fjleechan-skills --skill sync","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fsync\u002FSKILL.md",true,[],[60,77,98,111,125,141],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":32},"01M716Y5MTJ6GYJZ2ATXCJK8G4","instinct","Use when the user invokes \u002Finstinct or \u002Fin, or asks to \"message Instinct\", \"ask Instinct\", \"tell Instinct\", \"check Instinct\", or read replies from the configured peer assistant. iMessage first, WhatsApp Web as fallback.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Finstinct\u002FSKILL.md",[],[62,24,67,68,69,70,71,72,73,74,75,76],"when","replies","check","use","identity","whatsapp","gmail","read","message","ask",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":88,"publishedAt":32},"01M716Y4HF7FVVMJSA2CCVN5VF","hr","Compatibility alias for history-resume; produce the same fresh-state, provenance-aware resume briefing.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhr\u002FSKILL.md",[83],{"categoryNo":84,"categoryName":85,"taxonomyType":86,"taxonomyTypeDesc":87},"01JBSEEDCAT000000000000038","人力资源","PROFESSION","适用职业",[79,89,90,91,92,93,94,95,96,21,97],"resume","compatibility","provenance","for","history","produce","alias","briefing","fresh",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":105,"publishedAt":32},"01M716Y1FFNFKFJYYKF8HQA6T8","history-resume","Resume briefing for the current repository branch or worktree using fresh state and admitted history sources.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhistory-resume\u002FSKILL.md",[104],{"categoryNo":84,"categoryName":85,"taxonomyType":86,"taxonomyTypeDesc":87},[93,89,106,23,24,107,96,108,92,109,110,21,97],"history resume","analysis","repository","worktree","sources",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":32},"01M716XWXJ8EPHK4RH9T14TR85","grok","Alias for the canonical grokbot browser conversation workflow; \u002Fgrok talks to the Grok bot the same way \u002Fdot talks to Dot.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgrok\u002FSKILL.md",[],[113,118,119,120,92,121,95,122,123,124],"dot","bot","workflow","canonical","conversation","browser","grokbot",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":32},"01M70N9Q07DTE0EW5KFXMMMSJ0","codexa-bench","Compare `codexa` and normal `codex` on a fair split of comparable work by default; use `--strict` for duplicate runs of the exact same task.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcodexa-bench\u002FSKILL.md",[],[132,133,134,70,135,92,136,137,138,139,140],"codexa bench","work","split","default","duplicate","task","compare","normal","codex",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":145,"licenseFileUrl":146,"sourceHtmlUrl":147,"categories":148,"keywords":160,"publishedAt":32},"01M6C24S2X60SP8BBFGAEKPEGW","frontend-design","Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML\u002FCSS layouts, or when styling\u002Fbeautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ffrontend-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ffrontend-design\u002FSKILL.md",[149,154,157],{"categoryNo":150,"categoryName":151,"taxonomyType":152,"taxonomyTypeDesc":153},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",{"categoryNo":155,"categoryName":156,"taxonomyType":152,"taxonomyTypeDesc":153},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":158,"categoryName":159,"taxonomyType":86,"taxonomyTypeDesc":87},"01JBSEEDCAT000000000000032","设计师",[161,162,163,70,164,165,166,24,167,168,169,170,171,172,173,174,175,176,177,178,179,20,180,30,181,182,67,183],"frontend","design","frontend design","generic","ui design","react","html","components","code","artifacts","ui","aesthetics","Production","web components","landing","applications","quality","web","css","examples","react components","web ui","pages"]