git-workflow
Scannednpx machina-cli add skill Dqz00116/skill-lib/git-workflow --openclawGit Workflow Skill
Automate Git operations with safety checks and user confirmation.
What This Skill Does
-
Checks Workspace Status
- Shows modified files
- Lists untracked files
- Detects conflicts or merge states
-
Smart Confirmation Prompt
- Lists all changes clearly
- Asks for explicit approval
- Provides multiple options (commit all, specific files, ignore, skip)
-
Safe Commit & Push
- Only commits after confirmation
- Handles GitHub authentication
- Reports success or failure
-
Conflict Detection
- Detects merge conflicts
- Suggests resolution steps
- Prevents force pushes
Quick Start
Simple Commit
python scripts/git_commit.py
The script will:
- Show
git status - Ask for confirmation
- Commit and push if approved
Interactive Mode
python scripts/git_commit.py --interactive
Step-by-step confirmation for each file.
Confirmation Format
š **Git Status Summary:**
Modified:
- SOUL.md (41 insertions)
- README.md (5 deletions)
Untracked:
- new-feature.md
- temp.log (should be ignored?)
ā
**Confirm:**
Reply:
- "yes" ā commit all modified
- "commit with untracked" ā commit all including untracked
- "only SOUL.md" ā commit specific file
- "ignore temp.log" ā add to .gitignore
- "skip" ā do nothing
Safety Rules
Never
- ā Commit without checking status first
- ā Commit without user confirmation
- ā Force push (
git push -f) - ā Commit binary/temporary files without asking
Always
- ā
Check
git statusbefore any operation - ā Show list of changes for approval
- ā
Respect
.gitignore - ā Handle errors gracefully
- ā Report what was done
Usage Examples
Example 1: Simple Workflow
$ python scripts/git_commit.py
š Git Status:
M SOUL.md
?? new-file.md
š Changes Summary:
Modified: SOUL.md
Untracked: new-file.md
ā
Confirm: Reply "yes" to commit modified, "commit with untracked" for all, or specify files
> yes
š Commit message: Update SOUL.md
ā
Committed: a1b2c3d Update SOUL.md
š Pushed to origin/main
Example 2: With Untracked Files
$ python scripts/git_commit.py
š Git Status:
M README.md
?? temp.log
?? important.md
š Changes Summary:
Modified: README.md
Untracked: temp.log, important.md
ā
Confirm: What to commit?
> commit with untracked
ā ļø temp.log looks like a temporary file. Add to .gitignore instead?
> yes
š Commit message: Update README and add important docs
ā
Committed: b2c3d4e Update README and add important docs
š Pushed to origin/main
Example 3: Skip Everything
$ python scripts/git_commit.py
š Git Status:
M SOUL.md
š Changes Summary:
Modified: SOUL.md
ā
Confirm: Reply "yes" to commit
> skip
ā¹ļø Skipped. No changes committed.
Handling Edge Cases
Merge Conflicts
ā ļø **Merge Conflict Detected!**
Conflicted files:
- README.md
- config.yaml
Cannot commit until conflicts are resolved.
Suggested steps:
1. Edit files to resolve conflicts
2. Run: git add <resolved-files>
3. Run this script again
Diverged Branches
ā ļø **Local branch is behind remote**
Run: git pull origin main first?
> yes
Pulling latest changes...
[...]
ā
Now you can commit your changes.
Authentication Issues
ā **Push Failed: Authentication Error**
Possible causes:
- SSH key not configured
- Token expired
- Wrong remote URL
Suggested fixes:
1. Check: git remote -v
2. Test: ssh -T git@github.com
3. Or use HTTPS with token
Best Practices
- Check before committing: Always review changes
- Write clear messages: Describe what and why
- Commit related changes: One logical change per commit
- Don't commit secrets: Check for API keys, passwords
- Keep commits small: Easier to review and revert
Troubleshooting
"nothing to commit"
# Check if files are actually modified
git status
# Check if in git repository
git rev-parse --git-dir
"Permission denied"
# Check SSH key
ssh -T git@github.com
# Or use HTTPS
git remote set-url origin https://github.com/username/repo.git
"failed to push"
# Pull first
git pull origin main
# Resolve any conflicts
# Then commit again
Overview
Automates Git operations with safety checks and explicit user confirmation. It reviews workspace status, lists changes, and only commits after your approval, then safely pushes to the remote. It also detects conflicts and blocks dangerous actions like force pushes.
How This Skill Works
The skill runs a helper script that executes git status, aggregates changed and untracked files, and presents a confirmation prompt with options to commit all, a subset, or ignore files. Upon explicit approval, it performs the commit and push, handling authentication and reporting success or failure. It also detects conflicts and provides suggested resolutions to prevent unsafe pushes.
When to Use It
- When preparing to commit changes after reviewing local work
- When you have both modified and untracked files and want explicit control
- When you need granular approval (specific files) or an ignore decision
- When you want to detect merge conflicts or a diverged branch before pushing
- When remote authentication or push issues might occur and you need guidance
Quick Start
- Step 1: Run python scripts/git_commit.py
- Step 2: Review git status and confirmation prompts
- Step 3: Approve to commit and push or choose a granular option
Best Practices
- Always run git status before committing
- Review the full changes list and write clear messages
- Respect .gitignore and avoid committing ignored files
- Prefer small, related changes per commit
- Avoid force pushes and handle errors gracefully
Example Use Cases
- Simple commit with user confirmation and push
- Interactive mode with per-file approvals
- Handling untracked files and adding to .gitignore prompts
- Conflict detection stopping a commit until resolved
- Authentication error scenario with troubleshooting tips