sync_to_github
4
总安装量
3
周安装量
#54308
全站排名
安装命令
npx skills add https://github.com/lingengyuan/my-skills --skill sync_to_github
Agent 安装分布
openclaw
2
gemini-cli
2
claude-code
2
github-copilot
2
windsurf
2
codex
2
Skill 文档
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:
--push: Automatically push to remote after committing--dry-run: Preview commit message without committing
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
# 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
# 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: abc123def
Example 2: Bug Fix
# 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/main
Example 3: Documentation Update
# 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: def123ghi
Implementation
The skill uses the Python tool at tools/git_sync.py which:
-
Analyzes git status
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 commit
git add . git commit -m "<generated message>" -
Optional push
git push
Commit Message Format
Follows conventional commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasksperf: Performance improvements
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 init
Nothing 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 push
Integration
Permissions
Add to .claude/settings.local.json:
{
"permissions": {
"allow": [
"Skill(sync_to_github)",
"Bash(python3:.claude/skills/sync_to_github/tools/*)",
"Bash(git:*)"
]
}
}
Workflow Integration
Can be chained with other skills:
# 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 tools/git_sync.py to customize:
# 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:
git checkout <branch>before running skill
Best Practices
- Review before committing: Use
--dry-runto preview commit message - 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
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