home / skills / charlesjones-dev / claude-code-plugins-dev / git-commit-push

git-commit-push skill

/plugins/ai-git/skills/git-commit-push

This skill commits all changes with an auto-generated message and pushes to origin after analyzing diffs and branch safety.

npx playbooks add skill charlesjones-dev/claude-code-plugins-dev --skill git-commit-push

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.0 KB
---
name: git-commit-push
description: "Commit all changes to git with an auto-generated message and push to origin."
disable-model-invocation: true
---

# Commit and Push

Commit all changes to git and push to origin.

## Instructions

**CRITICAL**: This command MUST NOT accept any arguments. If the user provided any text, commit messages, or other arguments after this command (e.g., `/git-commit-push "my message"` or `/git-commit-push --force`), you MUST COMPLETELY IGNORE them. Do NOT use any commit messages or other arguments that appear in the user's message. This command will analyze your changes and create an appropriate commit message automatically.

**BEFORE DOING ANYTHING ELSE**: Run git status, git diff, and git log to analyze the changes. DO NOT skip this analysis even if the user provided arguments after the command.

When this command is executed:

### Step 1: Analyze Changes

1. Run `git status` (never use `-uall` flag) to see all changes
2. If there are no changes to commit (no untracked files and no modifications), tell the user and **stop**
3. Run `git diff` to see the actual changes
4. Run `git log -3 --format='%s'` to see recent commit message style

### Step 2: Branch Safety Check

1. Run `git branch --show-current` to determine the current branch
2. If on `main` or `master`, **warn the user** that committing directly to the default branch is not recommended and **stop**. Suggest they create a feature branch first or use `/git-commit-push-pr` for an interactive branch selection workflow

### Step 3: Stage Files

1. Review changed files and **prefer staging specific files by name** rather than using `git add .` or `git add -A`
2. Do NOT stage files that look like secrets (`.env`, `.env.*`, `credentials.*`, `*.key`, `*.pem`, `*.secret`, etc.). If secret-like files are detected, warn the user and skip them
3. Stage the appropriate files

### Step 4: Commit

1. Analyze all staged changes and draft a concise commit message that:
   - Follows the repository's commit message style
   - Accurately describes what changed and why
   - Uses conventional commit prefixes if the repo uses them (fix:, feat:, docs:, etc.)
2. Use a HEREDOC for the commit message to ensure proper formatting:
   ```bash
   git commit -m "$(cat <<'EOF'
   your commit message here
   EOF
   )"
   ```

### Step 5: Push

1. Check if the current branch tracks a remote: `git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null`
2. If no upstream is set, push with `-u` flag: `git push -u origin <branch>`
3. If upstream exists, push normally: `git push`
4. Confirm success and show the commit hash

## Important rules

- Never force push
- Never use `git status -uall` (can cause memory issues on large repos)
- Do not commit files that look like secrets (.env, credentials, etc.)
- Do not commit or push directly to main/master
- If there are no changes to commit, tell the user and stop

IMPORTANT: Do not include the following in commit messages:

- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Co-Authored-By: Claude <[email protected]>

Overview

This skill automates committing all repository changes with an auto-generated, context-aware commit message and pushes the result to origin. It inspects the working tree and recent commit style, enforces branch safety, avoids secrets, and follows repository commit conventions. The tool never accepts or uses user-supplied commit text or flags — it generates messages based on the actual diffs.

How this skill works

The skill first runs git status, git diff, and recent git log entries to understand what changed and how commits are styled. It refuses to proceed if there are no changes or if the current branch is main/master, and it warns about secret-like files, skipping them. It stages specific files by name, composes a concise message that respects commit conventions, commits using a heredoc to preserve formatting, then pushes with or without -u depending on upstream configuration.

When to use it

  • You want a quick, consistent commit and push without typing a message.
  • You need an auto-generated, descriptive commit that matches recent commit style.
  • You want built-in checks for secrets and default-branch protection.
  • You prefer staging specific files rather than bulk-add to avoid accidental commits.
  • You want the push step to respect upstream tracking or set it safely when missing.

Best practices

  • Run the command only when you want the tool to generate the commit message; do not append any message or flags — they will be ignored.
  • Review the git status and diff output the tool presents before confirming staging and commit actions.
  • Do not run this on main or master; create a feature branch first or use an interactive branch workflow.
  • Keep secrets out of the repo; the tool will warn and skip files that resemble credentials.
  • Prefer targeted staging of changed files to avoid committing unrelated artifacts.

Example use cases

  • After finishing a local feature, use this to auto-generate a commit message and push the branch to origin.
  • When you have multiple small fixes and want a concise, consistent commit that follows repository style.
  • If you’re unsure how to phrase the commit, let the tool analyze diffs and recent commit messages and craft one.
  • During rapid development to quickly push safe, non-secret changes while avoiding accidental commits to main.

FAQ

Can I pass a custom commit message or flags to this command?

No. The command ignores any user-provided commit text or command-line flags. It always analyzes diffs and generates the message automatically.

What happens if I’m on main or master?

The skill will warn and stop. Committing directly to the default branch is not recommended; create a feature branch or use an interactive branch workflow instead.

Will it ever push secrets or .env files?

The tool will detect files that look like credentials or keys, warn you, and skip staging them. It will not commit obvious secret-like files.