git-commit-push
Commit and push code changes to the remote repository. Use when the user wants to commit their changes and push to remote.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- git-commit-push
- license
- MIT
- metadata
- { "author": "zhaoyi", "version": "1.2", "generatedBy": "1.0.0" }
- description
- Commit and push code changes to the remote repository. Use when the user wants to commit their changes and push to remote.
- compatibility
- Requires git CLI and a git repository.
03 SKILL.md 正文
Commit and push code changes to the remote repository.
Input: Optionally specify a commit message. If omitted, generate a meaningful commit message based on the changes.
Steps
-
Pre-commit checks
Run
git statusto check for:- Unstaged changes
- Staged changes
- Untracked files
Run
git stash listto check for existing stashes.If there are conflicts or issues:
- Warn user about uncommitted changes
- Ask if they want to proceed or stash changes first
-
Check branch sync status
Run
git fetch originto update remote tracking info.Run
git statusto check if current branch is:- Ahead of remote (needs push)
- Behind remote (needs pull first)
- Diverged (may need rebase or merge)
If behind or diverged:
- Warn user and ask how to proceed
- Options: Pull first, Force push (dangerous), Cancel
-
Check for sensitive files
Scan staged files for potentially sensitive content:
.envfiles- Files containing
password,secret,api_key,token - Private key files (
.pem,.key) - Configuration files with credentials
If sensitive files detected:
- Warn user and show the files
- Ask for confirmation before proceeding
-
Stage changes
If there are unstaged changes:
- Run
git add <files>to stage specific files - Or run
git add -Ato stage all changes
For OpenSpec changes: Always include openspec files:
openspec/changes/archive/(archived changes)openspec/specs/(synced specs)openspec/review/(code review reports)
- Run
-
Generate and confirm commit message
Generate a commit message based on the changes:
<type>: <description> [optional body] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Commit types:
feat: New featurefix: Bug fixperf: Performance improvementrefactor: Code refactoringdocs: Documentationtest: Adding/updating testschore: Maintenance tasksstyle: Code style changesci: CI/CD changes
Show the generated message to user for confirmation or editing.
Use heredoc for multi-line commit messages:
git commit -m "$(cat <<'EOF' <type>: <description> <optional body> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )" -
Push to remote
Get current branch name and push:
git push origin <current-branch>If push fails:
- Show error message
- Suggest possible solutions:
- Pull and retry:
git pull --rebase origin <branch> - Check network connectivity
- Verify permissions
- Pull and retry:
-
Display summary
Show:
- Commit hash
- Branch name
- Commit message
- Files changed count
- Remote URL or MR/PR creation link
Output On Success
## Commit & Push Complete
**Commit:** <commit-hash>
**Branch:** <branch-name>
**Message:**
<commit-message>
**Files changed:** <count> files (+<additions>, -<deletions>)
**Remote:** <remote-url>
**Create MR/PR:** <mr/pr-creation-url>
Output With Warnings
## Commit & Push (with warnings)
**Warnings:**
- Branch is behind remote by X commits
- Sensitive file detected: .env
**Action taken:** Proceeded with user confirmation
**Commit:** <commit-hash>
...
Guardrails
- Always check git status before committing
- Always check branch sync status before push
- Warn about sensitive files before committing
- Use conventional commit message format
- Include Co-Authored-By line for AI-generated code
- Never use
--no-verifyor skip hooks unless explicitly requested - Never force push without explicit user confirmation
- Stage all relevant files including openspec artifacts
- Show generated commit message for user confirmation
Error Handling
- If no changes to commit: Inform user and exit
- If branch behind remote: Warn and suggest pull first
- If push fails: Show error message and suggest resolution
- If commit hooks fail: Show error and do not proceed
- If sensitive files detected: Warn and ask for confirmation
Sensitive File Patterns
Check for these patterns in file names:
.env,.env.local,.env.*.local*secret*,*password*,*credential**.pem,*.key,*.p12,*.jksapplication-*.yml,application-*.properties(if contain secrets)
04 同仓库更多 Skills
opsx-dev-pipeline
OpenSpec + Git 需求开发全流程。
git-merge-branch
Merge current branch to a target branch. Use when the user wants to merge their current branch to another branch (e.g., qa, master, develop).
git-code-review
Review uncommitted or committed changes in the current branch and generate a code review report. Use when the user wants to review their changes before or after committing.
file-code-review
Review specified files or code snippets against project conventions and generate a code review report. Use when the user wants to review specific files (e.g., "review this file", "审查这个文件") or code blocks (e.g., "review this code", "审查这段代码") without git context. Supports single file, multiple files, or pasted code snippets.
openspec-propose
Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
openspec-explore
Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.