Get the FREE Ultimate OpenClaw Setup Guide →

commit

npx machina-cli add skill dceoy/ai-coding-agent-skills/commit --openclaw
Files (1)
SKILL.md
1.5 KB

Commit Skill

Stage and commit current changes with a concise, well-formed commit message based on the diff and recent commit history.

When to Use

  • After completing a change and wanting to commit it.
  • When all modifications are ready to be captured in a single commit.

Agent Compatibility

This skill is tool-agnostic and can be executed by Claude Code, OpenAI Codex CLI, GitHub Copilot CLI, or Gemini CLI.

Inputs

  • Current repository with uncommitted changes (staged or unstaged).

If there are no changes to commit, report that and stop.

Workflow

  1. Gather context by running these commands in parallel:

    git status
    git diff HEAD
    git branch --show-current
    git log --oneline -10
    
  2. Analyze changes from the diff output to understand what was modified and why.

  3. Stage relevant files using git add for the appropriate files.

  4. Create a commit with a concise, descriptive message that:

    • Follows the repository's existing commit message style (based on recent commits).
    • Summarizes the nature of the change (new feature, bug fix, refactor, etc.).
    • Uses imperative mood and sentence case.

Stage and commit should be executed as efficiently as possible in a single step.

Outputs

  • A new git commit on the current branch.
  • Console output confirming the commit was created.

Source

git clone https://github.com/dceoy/ai-coding-agent-skills/blob/main/skills/commit/SKILL.mdView on GitHub

Overview

Stage and commit current changes (staged or unstaged) with a concise, well-formed message. It analyzes recent commit history to match the repository's style, then stages the relevant files and creates a single descriptive commit.

How This Skill Works

First, it gathers context by running git status, git diff HEAD, git branch --show-current, and git log --oneline -10. It then analyzes the changes to determine what to stage, followed by git add on the chosen files and a single commit with an imperative, sentence-case message that reflects the change type.

When to Use It

  • After completing a change and wanting to commit it.
  • When all modifications are ready to be captured in a single commit.
  • When you want the commit message to follow the repository's existing style based on recent commits.
  • When preparing a small, logical unit of work for review.
  • When you want to create a clean, review-friendly history before pushing.

Quick Start

  1. Step 1: In your repository with uncommitted changes, run git status, git diff HEAD, git branch --show-current, and git log --oneline -10 (in parallel).
  2. Step 2: Review the diff and recent commits to craft a concise, descriptive commit message that matches the repo’s style.
  3. Step 3: Stage the relevant files and commit in one step: git add -A && git commit -m 'Your descriptive message'

Best Practices

  • Review the last 10 commits with git log --oneline -10 to align the message style.
  • Stage only the files relevant to the change with git add <files> to avoid unintended changes.
  • Write the commit message in an imperative mood and sentence case that describes the change.
  • Ensure the message indicates the change type (feature, bug fix, refactor) and references if needed.
  • Verify the commit was created with git log -1 and that it contains the intended changes.

Example Use Cases

  • Add user authentication flow
  • Fix off-by-one error in pagination
  • Refactor to extract diff formatting helper
  • Update README with setup steps
  • Improve image loader performance

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers