Agent skill
git-sync
USE WHEN syncing code changes with git, creating commits with intelligent messages, pushing to remote repositories, or automating git workflows. Triggers on 'sync my changes', 'commit and push', 'git sync', 'sync to remote'.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/git-sync-caibingcheng-my-skills-collection
SKILL.md
Git Sync Skill
Automate git workflow with smart commit message generation and email verification.
Quick Start
python scripts/sync.py
This will:
- Check email consistency with recent commits
- Analyze commit message patterns
- Generate an appropriate commit message
- Stage, commit, and push
Core Features
1. Email Consistency Check
Before committing, verifies your user.email matches recent commits:
- If last 5 commits use
@company.com, your config must too - Prevents mixing personal/work emails
- Use
--forceto skip
Example:
⚠️ Email domain mismatch detected!
Recent commits use: @company.com
Your config uses: @gmail.com
To fix, run:
git config user.email '[email protected]'
Or if this is intentional, use --force to continue anyway.
2. Intelligent Commit Messages
Analyzes your repo's commit history to match style:
| Pattern Detected | Applied to New Message |
|---|---|
| Conventional commits | Adds feat:/fix: prefix |
| Capitalization | "Add feature" vs "add feature" |
| Punctuation | Period at end or not |
| Common verbs | Uses repository's preferred verbs |
Auto-generated based on changes:
- Adding files → "Add {files}"
- Modifying files → "Update {files}"
- Deleting files → "Remove {files}"
- Mixed changes → "Update {N} files"
3. Workflow Options
# Dry run - preview without changes
python scripts/sync.py --dry-run
# Commit only, don't push
python scripts/sync.py --no-push
# Skip email verification
python scripts/sync.py --force
# Custom message (formatted to match repo style)
python scripts/sync.py -m "Implement user authentication"
# Analyze more commits for pattern detection
python scripts/sync.py --pattern-count 10
Workflow
┌─────────────────────────────┐
│ Check email consistency │──Fail──▶ Show fix suggestion, exit
└─────────────────────────────┘
│ Pass
▼
┌─────────────────────────────┐
│ Analyze commit patterns │
│ (style, verbs, format) │
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ Categorize changes │
│ (add/modify/delete) │
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ Generate matching message │
└─────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ Stage → Commit → Push │
└─────────────────────────────┘
Scripts
scripts/sync.py - Main Entry
| Flag | Description |
|---|---|
-m, --message |
Custom commit message |
--no-push |
Commit only, skip push |
-f, --force |
Skip email verification |
-n, --dry-run |
Preview without changes |
--email-count N |
Check last N commits for email (default: 5) |
--pattern-count N |
Analyze last N commits for patterns (default: 5) |
scripts/check_email.py - Standalone Email Check
python scripts/check_email.py # Check and exit with status
python scripts/check_email.py --json # JSON output
python scripts/check_email.py -f # Force skip
scripts/analyze_commits.py - Pattern Analysis
python scripts/analyze_commits.py # Human-readable
python scripts/analyze_commits.py --json # JSON output
Example Output
$ python scripts/sync.py
📧 Checking email consistency...
✓ Email consistency check passed. Domain: @company.com
📊 Analyzing commit message patterns...
Pattern: simple messages
Capitalization: first letter uppercase
📝 Changes to be committed:
M src/main.py
?? src/utils.py
💬 Generated commit message: "Update src/main.py and add 1 file"
📦 Staging changes...
🚀 Committing...
✓ Committed: Update src/main.py and add 1 file
☁️ Pushing to main...
✓ Pushed to origin/main
✅ Sync complete!
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (email mismatch, git error, etc.) |
Requirements
- Python 3.7+
- Git repository with at least 1 commit
- Git
user.nameanduser.emailconfigured
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?