| name | Project Sync Checker |
| description | Check alignment between local project and git remote. Analyzes uncommitted changes, unpushed commits, unpulled updates, branch status, and divergence to ensure local and remote are synchronized. |
| version | 1.0.0 |
| dependencies | git |
Project Sync Checker
A skill for ensuring local project state is aligned with the git remote repository. Analyzes the full synchronization status including uncommitted changes, staged files, unpushed commits, unpulled commits, branch tracking, and divergence states.
When This Skill Activates
This skill automatically activates when you:
- Need to check if local and remote are synchronized
- Want to verify project state before starting work
- Debug sync issues between local and remote
- Need to understand divergence between branches
- Check what commits need to be pushed or pulled
- Start a new session and need project context
- Want a full project status overview
Keywords: sync status, project sync, git status, local vs remote, check alignment, push status, pull status, unpushed commits, uncommitted changes, divergence, branch status, remote status, project context
Core Concepts
Sync States
| State | Meaning | Action Required |
|---|
| Fully Synced | Local matches remote exactly | None - ready to work |
| Uncommitted Changes | Modified files not committed | Commit or stash |
| Unpushed Commits | Local ahead of remote | Push to sync |
| Unpulled Commits | Remote ahead of local | Pull to sync |
| Diverged | Both local and remote have new commits | Pull, merge/rebase, push |
| Untracked Branch | Local branch has no upstream | Set upstream or push |
Status Indicators
[SYNCED] - Fully synchronized
[AHEAD] - Local has unpushed commits
[BEHIND] - Remote has unpulled commits
[DIVERGED] - Both have new commits
[DIRTY] - Uncommitted local changes
[UNTRACKED] - New files not in git
[CONFLICT] - Merge conflicts present
Quick Check Methods
Method 1: Using PowerShell Script (Recommended)
# Full sync check
powershell -File .claude/skills/project-sync/check-sync.ps1
# Check specific branch
powershell -File .claude/skills/project-sync/check-sync.ps1 -Branch "feature/my-branch"
# Include remote comparison (fetches latest)
powershell -File .claude/skills/project-sync/check-sync.ps1 -FetchRemote
# Quick status only (no details)
powershell -File .claude/skills/project-sync/check-sync.ps1 -Quick
Method 2: Git Commands (Manual)
git fetch origin --prune
git status -sb
git rev-list --left-right --count origin/main...HEAD
git diff --stat
git diff --cached --stat
git log origin/main..HEAD --oneline
git log HEAD..origin/main --oneline
git log --oneline --left-right origin/main...HEAD
Method 3: Comprehensive Analysis (Claude Code)
When you need detailed sync analysis, provide these outputs:
1. Current branch: git branch --show-current
2. Remote tracking: git for-each-ref --format='%(upstream:short)' refs/heads/$(git branch --show-current)
3. Status: git status --porcelain
4. Ahead/behind: git rev-list --left-right --count @{u}...HEAD
5. Unpushed: git log @{u}..HEAD --oneline
6. Unpulled: git log HEAD..@{u} --oneline
7. Last remote sync: git show -s --format=%ci @{u}
8. Stash list: git stash list
Sync Status Report Template
When reporting sync status, use this format:
## Project Sync Status Report
**Project**: [project name]
**Branch**: [current branch] → [remote/branch]
**Status**: [SYNCED/AHEAD/BEHIND/DIVERGED/DIRTY]
**Generated**: [timestamp]
### Local State
- **Uncommitted Changes**: [count] files
- **Staged for Commit**: [count] files
- **Untracked Files**: [count] files
- **Stashed Changes**: [count] stashes
### Remote Comparison
- **Commits Ahead**: [count] (need to push)
- **Commits Behind**: [count] (need to pull)
- **Last Remote Sync**: [date/time]
- **Remote Last Commit**: [short hash] - [message]
### Recommendations
1. [Action 1]
2. [Action 2]
Common Sync Scenarios
Scenario 1: Start of Work Session
Before starting work, always check sync status:
# Fetch and show full status
powershell -File .claude/skills/project-sync/check-sync.ps1 -FetchRemote
Expected Actions:
- If BEHIND:
git pull origin main
- If AHEAD: Consider pushing before starting new work
- If DIRTY: Commit, stash, or discard changes
Scenario 2: Before Creating a PR
Ensure branch is ready for PR:
git checkout feature/my-feature
git fetch origin
git log HEAD..origin/main --oneline
git rebase origin/main
git push --force-with-lease
Scenario 3: Resolving Divergence
When local and remote have diverged:
git fetch origin
git rebase origin/main
git push --force-with-lease
git fetch origin
git merge origin/main
git push
Scenario 4: Multiple Developers / CI Conflicts
When commits appear on remote during your work:
git stash
git pull origin main
git stash pop
Detailed Analysis Functions
Check Uncommitted Changes
git status --short
git diff
git diff --name-only
git diff --stat
Check Staged Changes
git diff --cached
git diff --cached --name-only
Check Unpushed Commits
git log @{u}..HEAD --oneline
git log @{u}..HEAD
git rev-list @{u}..HEAD --count
Check Unpulled Commits
git fetch origin
git log HEAD..@{u} --oneline
git diff --stat HEAD..@{u}
Check Branch Tracking
git branch -vv
git rev-parse --abbrev-ref @{u}
git config branch.$(git branch --show-current).remote
Alignment Remediation Actions
Action: Sync with Remote (Pull)
git pull origin main
git pull --rebase origin main
git status
git add <resolved-files>
git rebase --continue
git commit
Action: Push Local Commits
git push origin main
git push -u origin feature/my-branch
git push --force-with-lease origin main
Action: Stash Changes Temporarily
git stash push -m "WIP: description"
git stash list
git stash pop
git stash apply stash@{2}
Action: Discard Local Changes
git checkout -- .
git fetch origin
git reset --hard origin/main
git clean -fd
Integration with CircleTel Workflow
Pre-Deploy Check
Before deploying to staging or production:
# Full sync check
powershell -File .claude/skills/project-sync/check-sync.ps1 -FetchRemote
# Expected output:
# - Branch: main
# - Status: SYNCED
# - Uncommitted: 0
# - Ahead: 0
# - Behind: 0
Feature Branch Workflow
git checkout main
powershell -File .claude/skills/project-sync/check-sync.ps1 -FetchRemote
git checkout -b feature/new-feature
git fetch origin
git rebase origin/main
git push -u origin feature/new-feature
Staging Branch Pattern
git push origin feature/my-feature:staging
git fetch origin
git log staging..origin/staging --oneline
Environment Variables
No environment variables required. Uses local git configuration.
Related Files
| File | Purpose |
|---|
.git/config | Local repository configuration |
.git/refs/remotes/origin/ | Remote tracking references |
.gitignore | Ignored file patterns |
.claude/skills/project-sync/check-sync.ps1 | Quick check script |
Troubleshooting
Issue: "No upstream branch"
git branch --set-upstream-to=origin/main main
git push -u origin main
Issue: "Diverged branches"
git log --oneline --left-right origin/main...HEAD
git rebase origin/main
git push --force-with-lease
Issue: "Cannot pull - uncommitted changes"
git stash
git pull
git stash pop
git add .
git commit -m "WIP"
git pull --rebase
Issue: "Remote rejected (non-fast-forward)"
git fetch origin
git rebase origin/main
git push
Best Practices
- Always fetch before checking status - Local tracking info may be stale
- Check sync at session start - Avoid merge conflicts later
- Commit frequently - Smaller commits are easier to sync
- Use feature branches - Keep main clean and synced
- Pull before push - Avoid non-fast-forward rejections
- Prefer rebase over merge - Cleaner history for feature branches
- Use --force-with-lease - Safer than --force when needed
- Stash before switching branches - Don't carry uncommitted changes
Quick Reference Card
┌─────────────────────────────────────────────────────────┐
│ PROJECT SYNC QUICK REFERENCE │
├─────────────────────────────────────────────────────────┤
│ CHECK STATUS │
│ Full check: check-sync.ps1 -FetchRemote │
│ Quick: git status -sb │
│ Ahead: git log @{u}..HEAD --oneline │
│ Behind: git log HEAD..@{u} --oneline │
├─────────────────────────────────────────────────────────┤
│ FIX SYNC ISSUES │
│ Behind: git pull --rebase origin main │
│ Ahead: git push origin main │
│ Diverged: git pull --rebase && git push │
│ Dirty: git stash or git commit │
├─────────────────────────────────────────────────────────┤
│ DANGER ZONE (use carefully!) │
│ Reset to remote: git reset --hard origin/main │
│ Force push: git push --force-with-lease │
│ Discard changes: git checkout -- . │
└─────────────────────────────────────────────────────────┘
Version: 1.0.0
Last Updated: 2025-01-08
Maintained By: CircleTel Development Team
Reference: https://git-scm.com/docs