commit
Creates and executes one coherent git commit from staged or selected working-tree changes. Use when the user asks to commit changes, stage and commit a logical change, or create a git commit with an appropriate message. Do not use for a draft-only message request or an operation that only pushes existing commits.
How do I install this agent skill?
npx skills add https://github.com/jacehwang/harness --skill commitIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill is a git management tool designed to assist with staging and committing changes. It incorporates security-focused 'Edge Case Guards' to detect and prevent the accidental inclusion of credentials, secrets, or environment files in the repository.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerpass
1 file scanned · No issues
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
Create exactly one coherent commit while preserving changes outside its intended scope. Write the commit message in English and communicate with the user in their language. Follow explicit user instructions and applicable repository guidance before the defaults below.
Repository Context
- Status: !
git status --short - Staged changes: !
git diff --cached - Unstaged changes: !
git diff - Untracked files: !
git ls-files --others --exclude-standard - Unmerged files: !
git diff --name-only --diff-filter=U - Current branch: !
git branch --show-current - Recent commits: !
git log --oneline -10
1. Define the Commit Scope
- If the worktree and index contain no changes, tell the user there is nothing to commit and stop.
- Select the target changes in this order:
- If the user named files or a logical change, use that scope. If unrelated changes are already staged, explain the conflict and ask how to proceed before changing the index.
- Otherwise, if staged changes exist, treat the staged diff as the complete target. Leave unstaged and untracked changes untouched.
- Otherwise, group unstaged and untracked changes by purpose. If they form one clear logical change, use that group. If there are multiple plausible groups or a file's inclusion is ambiguous, present the groups and ask which one to commit.
- Judge cohesion by behavior and purpose, not by file count alone. Keep tests, documentation, and configuration with the implementation they directly support.
2. Prepare the Index
When the exact target is not already staged, stage only its files with explicit pathspecs:
git add -- "path/with[brackets]/file.ts" "another path/file.md"
Use -- before paths and quote paths containing spaces, brackets, parentheses,
wildcards, or other shell-special characters. Include untracked files only when
they are part of the target change. Exclude local configuration, credentials,
temporary files, logs, and build artifacts unless repository guidance explicitly
tracks them and they are required by the change. If a target file mixes relevant
and unrelated hunks, stage only the relevant hunks; ask the user before staging
the whole file when safe partial staging is not practical.
After staging, re-run git status --short and git diff --cached. The staged diff
is now the sole source of truth for the commit.
3. Review the Staged Diff
Stop before committing when any blocking condition is present:
| Condition | Required action |
|---|---|
| Empty staged diff | Tell the user there is nothing staged for this commit. |
| Unmerged entries or real conflict markers | List the affected files and ask the user to resolve them. |
Suspected secret, credential, private key, or unintended .env file | Identify the location without repeating the value; ask the user to remove it or confirm it is non-secret test data. |
| Unclear or unrelated staged content | Explain the mismatch and ask how to scope the commit. |
Also inspect added lines for accidental debug statements, generated output, logs,
and unexplained TODO or FIXME markers. Ask only when an item appears unintended;
do not treat every occurrence as an error.
4. Compose the Message
Treat the message as a compact, standalone explanation for a human or coding agent that may not inspect the diff. Prioritize the changed behavior or system rule over author activity, file lists, and implementation inventory. Ground every claim in the staged changes and relevant repository context.
First follow an explicit repository commit convention. Use recent commit history as supporting evidence, not as a replacement for written guidance. Then distill:
- The primary before-and-after change in behavior, capability, data flow, or system rule.
- The single core intuition that explains most of the staged diff.
- Only the context needed to prevent a reader from forming the wrong mental model.
When no convention is defined, use these defaults:
- Title (subject): Start with an imperative English verb. Name the affected
concept and its changed behavior or governing rule, not merely the editing
action or a broad benefit. Prefer
Deduplicate retries by request IDtoUpdate retry handling. Omit a trailing period and keep the title concise; do not exceed 72 characters. - Description (body): Default to one short paragraph whose first sentence
states the smallest true transition:
Previously, <old rule>. Now, <new rule>.Include the deciding unit, direction, or unchanged boundary only when it is part of that transition. Omit the body only when the title itself makes both sides and the governing rule recoverable. Do not summarize files or tests. - Use one minimal toy example when concrete input, state, or output makes a
non-obvious rule faster to understand. For example:
Attempts r1, r1, r2 now create two jobs instead of three because request ID defines identity.Keep the example faithful to the diff; do not invent unsupported behavior. - After the intuition, include motivation, an important constraint or tradeoff, breaking behavior, or migration guidance only when it materially helps the reader understand or act on the change.
- Separate the description from the title with a blank line and wrap body lines at 72 characters.
Do not turn the description into a file-by-file or hunk-by-hunk summary. Omit secondary edits, routine tests, and mechanical details unless they change the core mental model. Do not force a body or toy example based only on change size.
5. Verify and Commit
Before executing the commit, review git diff --cached one final time and verify:
- Every staged change belongs to the selected scope.
- The message gives an accurate core mental model of the staged change without requiring file-by-file inspection or claiming unstaged work.
- The staged diff still passes the safety review above.
For a subject-only message, run:
git commit -m "Subject line"
For a message with a body, use separate -m arguments so Git inserts a real blank
line. Put real line breaks in a long body; never encode them as literal \n text.
git commit \
-m "Deduplicate retries by request ID" \
-m "Retries now treat request ID as the unit of identity. Attempts r1, r1,
r2 create two jobs instead of three."
If the commit fails, inspect the error and current status before taking further action. If a hook modified files or the index, review the new staged diff and revalidate the message before retrying. Do not retry a failure blindly.
After success, inspect the complete stored message with
git log -1 --format='%B'. Verify that the title/body separator and body line
breaks are real line breaks, not literal \n text. If the just-created message
is malformed, amend it using actual line breaks and inspect it again. Then run
git log -1 --format='%h %s' and git status --short. Report the commit hash and
subject, then mention any remaining unstaged or untracked changes. Do not push
unless the user separately requested it.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/jacehwang/harness/commit">View commit on skillZs</a>