push
Push — Stage, Commit, and Push with Approval
Process
Phase 1: Collect Repository State
Run these commands in parallel to build a complete picture:
git status— working tree state (staged, unstaged, untracked)git diff HEAD --stat— summary of all changes vs HEADgit diff HEAD— full diff for internal analysis (do NOT dump to user)git log --oneline -5— recent commits for message style matchinggit branch --show-current— current branch namegit rev-parse --abbrev-ref HEAD— detect detached HEADgit remote -v— verify remote exists
Abort conditions — check before proceeding:
| Condition | Detection | Action |
|---|---|---|
| Nothing to commit | Clean working tree, no staged/unstaged/untracked | Tell user "Nothing to push — working tree is clean." Stop. |
| Detached HEAD | rev-parse --abbrev-ref HEAD returns literal "HEAD" |
Tell user to create or checkout a branch first. Stop. |
| No remote | git remote -v returns empty |
Tell user to add a remote. Stop. |
| No upstream | rev-parse --abbrev-ref @{upstream} fails |
Note this; offer push -u origin <branch> in Phase 3. |
Phase 2: Analyze Changes
Categorize every changed file:
- New — untracked files
- Modified — tracked files with changes
- Deleted — removed files
- Renamed — files detected as renames
Group by purpose when possible. If >15 files, summarize by directory instead of listing each file.
Draft a commit message:
- Match the style of the 5 recent commits (conventional commits, imperative mood, etc.)
- Explain WHAT changed and WHY, not just list files
- First line under 72 characters; add body if changes are complex
Phase 3: Present Summary and Request Approval
Use AskUserQuestion to show the summary and get explicit approval. Format:
## Changes to push (branch: <branch>)
### Files
- [New] path/to/file
- [Modified] path/to/file
- [Deleted] path/to/file
- [Renamed] old/path -> new/path
### Summary
<1-3 sentence description of what changed>
### Proposed commit message
<the drafted message>
If no upstream, append: "No upstream set. Will push with git push -u origin <branch>."
Wait for user response. Do NOT proceed without approval.
Handle responses:
- Approve → proceed to Phase 4
- User provides alternative commit message → use theirs
- Cancel → stop, nothing pushed
- User excludes files → adjust staging accordingly
Phase 4: Execute
Only after approval:
- Stage:
git addrelevant files. If all approved:git add -A. If user excluded files: add only approved files by name. **NEVER stage .env, credentials.json, .secret, .pem, .key without explicit user confirmation. - Commit:
git commit -m "<approved message>"via heredoc for multi-line. - Push:
git push(orgit push -u origin <branch>if no upstream).
Phase 5: Confirm
On success:
Pushed to origin/<branch>: <hash> <message>
(<N> files changed, <insertions> insertions, <deletions> deletions)
On failure — report clearly, never force-push:
- Rejected (non-fast-forward) → "Remote has new changes. Run
git pullfirst." - Permission denied → "Auth failed. Check credentials or SSH key."
- Remote not found → "Verify URL with
git remote -v."
Anti-Patterns
| Do Not | Do Instead |
|---|---|
| Push without showing summary | Always present changes first |
| Auto-commit without approval | Wait for explicit approval |
| Force-push to resolve conflicts | Report error, let user decide |
| Stage secret files silently | Warn and require explicit confirmation |
| Create branches or PRs | Stay on current branch |
| Dump full diff to user | Summarize in natural language |
| Use generic messages like "update files" | Draft specific messages from actual changes |
More from touricks/fanshi_personal_skills
study-notes-generator
Transform documents into interactive HTML study notes with key concepts, problem-solution pairs, examples, and self-quiz questions. Use when asked to create study notes, summarize lecture slides, or generate learning materials from documents in slides/ folder. Output goes to notes/ folder.
9scientific-slides
Build slide decks and presentations for research talks. Use this for making PowerPoint slides, conference presentations, seminar talks, research presentations, thesis defense slides, or any scientific talk. Provides slide structure, design templates, timing guidance, and visual validation. Works with PowerPoint and LaTeX Beamer.
7langgraph
Expert in LangGraph - the production-grade framework for building stateful, multi-actor AI applications. Covers graph construction, state management, cycles and branches, persistence with checkpointers, human-in-the-loop patterns, and the ReAct agent pattern. Used in production at LinkedIn, Uber, and 400+ companies. This is LangChain's recommended approach for building agents. Use when: langgraph, langchain agent, stateful agent, agent graph, react agent.
6humanizer-zh
去除文本中的 AI 生成痕迹。适用于编辑或审阅文本,使其听起来更自然、更像人类书写。基于维基百科的\"AI 写作特征\"综合指南。检测并修复以下模式:夸大的象征意义、宣传性语言、以 -ing 结尾的肤浅分析、模糊的归因、破折号过度使用、三段式法则、AI 词汇、否定式排比、过多的连接性短语。
6docx
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
6ml-paper-writing
Write publication-ready ML/AI papers for NeurIPS, ICML, ICLR, ACL, AAAI, COLM. Use when drafting papers from research repos, structuring arguments, verifying citations, or preparing camera-ready submissions. Includes LaTeX templates, reviewer guidelines, and citation verification workflows.
6