AgentSkillsCN

commit

将更改提交到 Git 仓库,必要时推送

SKILL.md
--- frontmatter
name: "commit"
description: "commit changes to git repository and push if needed"
argument-hint: [--push | -p] [--main | -m]
allowed-tools: TodoWrite Bash(gh *) Bash(git switch *) Bash(git add *) Bash(git commit *) Bash(git push *) Bash(git rev-parse *) Bash(git log *) Bash(git diff *)

Quick Reference

bash
/commit
/commit --push  # Commit and push changes
/commit --main  # Commit directly to the default branch without creating a new branch
/commit -m -p   # Commit directly to the default branch and push

Workflow

Run these commands in parallel to gather information:

  • git status
  • git diff
  • git log --oneline -5
  • gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' (to get default branch)

If --main or -m option is given, commit directly to the default branch without creating a new branch.

Otherwise, if the current branch is the default branch and there are differences, create a new branch. Give the branch an appropriate name and commit the changes.

If --push or -p option is given, push the branch to the remote repository.

Commit Message

Use the Conventional Commits format for commit messages:

code
<type>(<scope>)!: <subject>
(blank line)
<body>
(blank line)
<footer / BREAKING CHANGE / related issue(s) etc.>

Required: type, subject Optional: scope, ! (breaking change), body, footer

type list

feat : New feature fix : Bug fix docs : Documentation only style : Formatting (whitespace, semicolons, etc.) refactor : Refactoring (not a feature, not a bug fix) perf : Performance improvement test : Add/modify tests build : Build system / dependencies / distribution ci : CI configuration / scripts chore : Chore (other than src / test) revert : Revert previous commit