home / skills / kriscard / kriscard-claude-plugins / commit

This skill helps you manage Git commits by composing conventional messages, staging changes, and optionally pushing to remote.

npx playbooks add skill kriscard/kriscard-claude-plugins --skill commit

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

Files (1)
SKILL.md
2.7 KB
---
name: commit
disable-model-invocation: true
description: >-
  Creates semantic git commits with conventional commit format, stages changes, and
  pushes to remote. Handles pre-commit hooks and writes meaningful commit messages.
  Make sure to use this skill whenever the user says "commit", "push changes", "save
  to git", "commit this", or wants to create a git commit — even if they just say
  "save my work."
---

# Git Commit Workflow

Direct execution of git commit workflow - no agent delegation, fast and simple.

## Trigger Phrases

This skill activates on:
- "commit changes", "commit this", "commit my work"
- "save to git", "save my changes", "save this to git"
- "push this", "push my changes", "push my work"
- "create a commit", "make a commit"
- "git commit", "check in my changes"

## Proactive Triggering

After completing implementation work, **proactively offer** to commit:
- "I've finished implementing the feature. Would you like me to commit these changes?"
- Use AskUserQuestion with options: "Yes, commit now" / "No, I'll review first"

## Workflow

### Step 1: Assess Changes

```bash
git status
git diff
```

**If no changes:** Report "No changes to commit" and end.

### Step 2: Stage Files

Stage logically related changes:
```bash
git add <files>
```

**Skip sensitive files:** .env, credentials, tokens - warn user if detected.

### Step 3: Create Conventional Commit

Analyze changes and determine:
- **Type:** feat, fix, docs, style, refactor, perf, test, chore
- **Scope:** Component/area affected
- **Subject:** Imperative, lowercase, max 50 chars, no period

**Commit format:**
```
<type>(<scope>): <subject>

[Narrative body explaining WHAT and WHY - 2-4 sentences, NO bullet points]
```

**Good example:**
```
feat(auth): add session timeout handling

Implements automatic session refresh when user activity is detected
within the timeout window. Sessions now persist across page reloads
using localStorage with encrypted tokens.
```

**Bad example (avoid):**
```
feat(auth): add features

- Added timeout
- Added refresh
- Added localStorage
```

### Step 4: Execute Commit

```bash
git commit -m "$(cat <<'EOF'
<commit message here>
EOF
)"
```

### Step 5: Handle Pre-commit Hooks

If hooks modify files:
1. Stage the modified files
2. Amend the commit: `git commit --amend --no-edit`

### Step 6: Ask About Push

Use AskUserQuestion:
- "Commit successful! Push to remote?"
- Options: "Yes, push now" / "No, keep local"

### Step 7: Push (if confirmed)

```bash
git push
# or if no upstream:
git push -u origin <branch>
```

## Safety Rules

- NEVER commit .env files or credentials
- NEVER force push without explicit user request
- NEVER amend commits on shared branches without warning
- Always show what will be committed before committing

Overview

This skill automates a safe, conventional git commit workflow for local changes. It stages relevant files, composes semantic Conventional Commits, runs the commit, handles pre-commit hook changes, and can optionally push to the remote. It enforces safety rules to avoid leaking secrets and prevents risky operations like force-pushes without explicit consent.

How this skill works

It inspects the working tree with git status and git diff to determine changed files. It stages logically related files (skipping sensitive files like .env), generates a Conventional Commit message (type, scope, concise subject, and a 2–4 sentence body), runs git commit, re-stages and amends if pre-commit hooks modify files, and then asks whether to push. It never delegates to PR creation or branch management.

When to use it

  • After finishing implementation or a bug fix and you want a semantic commit
  • When you need a clear Conventional Commit message for changelogs or CI
  • When you want automatic handling of pre-commit hooks and amended changes
  • For local commits before creating a pull request (use /pr for PRs)
  • When you want a safe push prompt after committing

Best practices

  • Always review git status and the staged diff before committing
  • Use descriptive scope and an imperative, lowercase subject under 50 characters
  • Include a 2–4 sentence body explaining what changed and why, without bullet lists
  • Never commit secrets or .env files; the skill will warn and skip them
  • Avoid force-pushing and do not amend shared-branch commits without confirmation

Example use cases

  • Finish a new login feature and create a commit: feat(auth): add session timeout handling
  • Fix a bug in payment calculation with a precise commit message: fix(pay): correct rounding error in totals
  • Update documentation for an API endpoint: docs(api): document pagination parameters
  • Run commits after automated formatting and have pre-commit hooks amend files safely
  • Commit a set of related files together while skipping credentials and getting a push prompt

FAQ

What if there are no changes?

The skill will report "No changes to commit" and stop.

How are commit types and scopes chosen?

The skill analyzes the modified files and context, then suggests a conventional type and a concise scope; you can review or edit before committing.

What happens if pre-commit hooks modify files?

Modified files are restaged and the commit is amended with --no-edit to include the hook changes.

Will it ever push automatically?

No. After committing the skill asks for explicit confirmation before pushing to the remote.