sync_to_github
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Automated git commit and push tool with AI-generated commit messages
2installs
Sourcelingengyuan/my-skills
Added on
NPX Install
npx skill4agent add lingengyuan/my-skills sync_to_githubTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →sync_to_github
Automatically analyze project changes, generate descriptive commit messages using AI, and commit to git.
Purpose
This skill automates the git workflow by:
- Analyzing current git status (staged and unstaged changes)
- Generating descriptive commit messages based on change content
- Creating commits with AI-generated messages
- Optionally pushing to remote repository
Input/Output Contract
Input
- No required parameters
- Optional flags:
- : Automatically push to remote after committing
--push - : Preview commit message without committing
--dry-run
Output
- Git commit created with descriptive message
- Optional: Push to remote repository
- Console output showing:
- Files changed
- Generated commit message
- Commit hash
Dependencies
- Git (command line)
- Python 3.x
- Working git repository with commits
Usage
Basic Usage
bash
# Analyze changes and create commit
Skill(sync_to_github)
# Commit and push to remote
Skill(sync_to_github, args="--push")
# Preview without committing
Skill(sync_to_github, args="--dry-run")Examples
Example 1: Feature Development
bash
# After implementing a new feature
Skill(sync_to_github)Output:
Analyzing changes...
Files modified:
src/components/Button.tsx
src/styles/button.css
Generated commit message:
feat: add Button component with hover states
- Add reusable Button component with props interface
- Implement hover and active state animations
- Add CSS module for button styling
Commit created: abc123defExample 2: Bug Fix
bash
# After fixing a bug
Skill(sync_to_github, args="--push")Output:
Analyzing changes...
Files modified:
src/utils/api.ts
tests/api.test.ts
Generated commit message:
fix: resolve API timeout error in data fetching
- Increase timeout from 5s to 30s for slow endpoints
- Add retry logic with exponential backoff
- Update test coverage for timeout scenarios
Commit created: 456789ghi
Pushed to origin/mainExample 3: Documentation Update
bash
# After updating documentation
Skill(sync_to_github)Output:
Analyzing changes...
Files modified:
README.md
docs/api.md
docs/examples.md
Generated commit message:
docs: update API documentation with new endpoints
- Add new authentication endpoint examples
- Clarify rate limiting behavior
- Fix broken links in API reference
Commit created: def123ghiImplementation
The skill uses the Python tool at which:
tools/git_sync.py-
Analyzes git statusbash
git status --porcelain git diff --cached git diff -
Generates commit message
- Categorizes change type (feat/fix/docs/refactor/test/chore)
- Summarizes main changes in title
- Lists specific changes in bullet points
- Follows conventional commits format
-
Creates commitbash
git add . git commit -m "<generated message>" -
Optional pushbash
git push
Commit Message Format
Follows conventional commits specification:
<type>(<scope>): <subject>
<body>
<footer>Types:
- : New feature
feat - : Bug fix
fix - : Documentation changes
docs - : Code style changes (formatting)
style - : Code refactoring
refactor - : Adding or updating tests
test - : Maintenance tasks
chore - : Performance improvements
perf
Error Handling
No Changes Detected
Error: No changes to commit
Working directory is clean. Make some changes before running sync_to_github.Git Repository Not Found
Error: Not a git repository
Initialize with: git initNothing Staged
The skill automatically stages all changes with
git add .Push Fails
Warning: Commit created but push failed
Commit hash: abc123def
Error: <git error message>
Manual push required: git pushIntegration
Permissions
Add to :
.claude/settings.local.jsonjson
{
"permissions": {
"allow": [
"Skill(sync_to_github)",
"Bash(python3:.claude/skills/sync_to_github/tools/*)",
"Bash(git:*)"
]
}
}Workflow Integration
Can be chained with other skills:
bash
# After note creation
Skill(note-creator, "Create API docs")
Skill(sync_to_github, args="--push")
# After code generation
# ... code changes ...
Skill(sync_to_github)Configuration
Commit Message Customization
Edit to customize:
tools/git_sync.pypython
# Default commit types
COMMIT_TYPES = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "perf"]
# Message template
COMMIT_TEMPLATE = """{type}({scope}): {subject}
{body}
Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
"""Branch Behavior
Default behavior:
- Commits to current branch
- Pushes to current branch's remote
- To change branch: before running skill
git checkout <branch>
Best Practices
- Review before committing: Use to preview commit message
--dry-run - Stage selectively: Commit all changes or stage specific files first
- Meaningful changes: Ensure changes are complete before committing
- Branch management: Commit to feature branches, not main directly
- Commit frequency: Use for logical units of work, not every file save
Limitations
- Requires at least one existing commit in repository
- Cannot handle merge conflicts
- Does not create pull requests
- Requires git configured with user.name and user.email
- Only commits to current branch
Troubleshooting
"git config" errors
bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Large commits fail
- Consider splitting into smaller commits
- Check git LFS for large files
Push permission denied
- Check remote URL:
git remote -v - Verify authentication credentials
- Check branch permissions on GitHub