Back to list
sergeyklay

git-commit

by sergeyklay

A self-hosted, local-first bill manager for the Active Payer.

2🍴 1📅 Jan 23, 2026

SKILL.md


name: git-commit description: Execute Git commits with proper workflow including authentication, branch safety, atomic commits, and style analysis. Use when asked to commit, save, or persist changes to Git, after completing tasks where committing is logical, or when autonomously checkpointing work. This skill handles the HOW of committing (workflow steps, commands, branch management).

Git Commit Skill

Execute Git commits following a structured workflow that ensures authentication, branch safety, atomic commits, and project style consistency.

References

Workflow

Step 1: Verify GitHub CLI Authentication

Before any Git operation, verify authentication status:

gh auth status

If authentication fails (exit code non-zero or error message contains "not logged in"):

  1. Inform the user: "GitHub CLI authentication is missing or expired."
  2. Provide the command to re-authenticate:
    gh auth login --web
    
  3. Wait for the user to complete authentication before proceeding.

Common authentication error patterns:

  • "You are not logged in"
  • "authentication required"
  • "token has expired"
  • "invalid token"
  • Exit code 1 with stderr output

Step 2: Identify Files to Commit

Atomic commits principle: Each commit should represent ONE logical change. Do not bundle unrelated changes into a single commit.

Analyze the current Git status to identify files to commit:

# Show current status
git status --short

Not all changed files should be committed. Having a branch with multiple unrelated changes makes it hard to review, revert, or understand history. Try to determine what the user intends to commit based on context and recent changes. If unclear, ask the user for clarification on which files or changes to include in the commit.

# Show detailed diff for unstaged changes
git diff

# Show detailed diff for staged changes
git diff --cached

Grouping strategy:

  1. Analyze all pending changes and identify logical groups
  2. Group by purpose: Files that serve the same change belong together
  3. Separate unrelated changes: Different features, fixes, or docs = separate commits
  4. Ask user if ambiguous: When grouping is unclear, ask for clarification

Examples of logical grouping:

ChangesCommits
New service + its unit tests1 commit: feat: add PaymentService
New feature + unrelated config change2 commits: feature first, then config
Bug fix in component + related test fix1 commit: fix: handle null in BillForm
Refactor + unrelated documentation update2 commits: refactor first, then docs
Multiple files for one feature (action, service, component)1 commit: all related files together

Staging rules:

User saysAction
"commit all changes"Group into logical atomic commits, create multiple if needed
"commit these files" + listgit add <file1> <file2>...
"commit staged files"Use already staged files
"commit "git add <file>
AmbiguousAsk user to clarify which files and grouping

Step 3: Verify Branch Safety

CRITICAL: Never commit directly to protected branches.

Detect Protected Branch

# Get the repository's default branch
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'

# Get current branch
git branch --show-current

Protected branches include:

  • The default branch (usually main or master)
  • develop or development
  • Any branch matching release/* or hotfix/* patterns

If on Protected Branch

  1. STOP - do not commit directly
  2. Inform the user: "You are on the protected branch <branch>. Creating a feature branch."
  3. Create an appropriately named feature branch based on analysis from Step 2:
git checkout -b <type>/<short-description>

Branch Naming Convention

Format: <type>/<kebab-case-description>

TypeUse CaseExample
featNew featurefeat/bill-reminders
fixBug fixfix/null-amount-validation
refactorCode restructuringrefactor/extract-payment-service
choreMaintenance taskschore/update-dependencies
docsDocumentationdocs/api-reference
testTest additionstest/payment-service-coverage

Rules:

  • Use kebab-case (lowercase with hyphens)
  • Keep it short (2-4 words max)
  • Make it descriptive of the change intent
  • ALWAYS in English

Step 4: Analyze Project Writing Style

Analyze recent commits to match the project's vocabulary and phrasing:

git log --format="%s" -30

You have to mimic the vocabulary, detail level, and phrasing style.

Writing style characteristics to identify:

CharacteristicWhat to Look For
VocabularyWhich verbs are commonly used? (add, implement, introduce, etc.)
Detail levelBrief ("fix bug") vs descriptive ("fix null pointer in auth flow")
Scope patternsCommon scopes: (deps), (api), (ui), or no scope
SpecificityGeneric vs domain-specific terminology

Important: The Conventional Commits format is fixed. Only adapt the vocabulary and phrasing style to match project conventions.

Identify:

  • Common verbs (add, implement, introduce, etc.)
  • Detail level (brief vs descriptive)
  • Scope usage patterns ((deps), (api), or none)
  • Domain-specific terminology

Mimic the identified style while following Conventional Commits format.

Step 5: Generate and Execute Commit

Stage files and create commit:

# Stage specific files
git add <files>

# Create commit with message
git commit -m "<message>"

For multi-line messages:

git commit -m "<subject>" -m "<body paragraph 1>" -m "<body paragraph 2>"

Follow the PR Description Structure from Commit Message Format.

Step 6: Confirm Success

Verify and report:

# Show the created commit
git log --oneline -1

# Show commit details
git show --stat HEAD

Report to user:

  • Commit hash (short form)
  • Files changed count
  • Insertions/deletions summary

Error Handling

Git Errors

ErrorCauseResolution
"nothing to commit"No staged changesVerify files exist and have changes
"pathspec did not match"File path incorrectCheck file path spelling
"not a git repository"Not in repo directoryNavigate to correct directory

Authentication Errors

If any gh command fails with authentication error:

  1. Run gh auth status to diagnose
  2. If token expired: gh auth refresh
  3. If no token: Report the issue clearly to the user and offer to run gh auth login --web

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon