
Commit
- 285 installs
- 69 repo stars
- Updated August 4, 2026
- paulrberg/agent-skills
Generate conventional commit messages from staged diffs so agents produce readable history, accurate scopes, and changelog-friendly subjects before push.
About
Helps agents write clear conventional commit messages with scoped subjects, imperative summaries, and explanatory bodies that align with project history and support automated changelog generation.
- Conventional commit formatting
- Scope inference from changed paths
- Imperative subject line discipline
- Body bullets for breaking changes
- History-aware tone matching
Commit by the numbers
- 285 all-time installs (skills.sh)
- +9 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #145 of 733 Git & Pull Requests skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/paulrberg/agent-skills --skill commitAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 285 |
|---|---|
| repo stars | ★ 69 |
| Last updated | August 4, 2026 |
| Repository | paulrberg/agent-skills ↗ |
What it does
Generate conventional commit messages from staged diffs so agents produce readable history, accurate scopes, and changelog-friendly subjects before push.
Files
Git Commit
Create atomic commits by staging the right files, analyzing the staged diff, composing a commit message, and optionally pushing.
Workflow
1) Parse arguments
Arguments: $ARGUMENTS
- Flags:
--allcommit all changes--stagedcommit exactly the current index; do not auto-stage or unstage (conflicts with--all)--deepdeep analysis with the active session model, breaking changes, concise body--naturalforce Natural Language Format--pushpush after commit--close <issue_numbers>appendCloses #Ntrailers for listed issues (comma/space-separated)- Value arguments:
- Conventional Prefix Format: type keyword overrides inferred type
- Natural Language Format: leading verb/category keyword overrides inferred verb
- Quoted text overrides inferred description or subject
Pass --natural through to the prepare helper when requested. The helper resolves the message format from the target repository cwd. Never cd into the skill directory.
2) Prepare staged diff
Run the portable helper from the target repository cwd. Never cd into the skill directory, and never use dynamic ! shell injection.
For Claude Code:
bash "${CLAUDE_SKILL_DIR}/scripts/prepare-commit.sh" [--all] [--staged] [--natural] [--diff summary|full] -- [session_modified_paths...]For Codex CLI, resolve <skill-dir> from the loaded SKILL.md path:
bash "<skill-dir>/scripts/prepare-commit.sh" [--all] [--staged] [--natural] [--diff summary|full] -- [session_modified_paths...]Use --diff summary by default. Use --diff full only when the intent is ambiguous or --deep was requested.
The helper performs Git preflight checks, stages --all or the session-modified paths (or, with --staged, leaves the current index untouched), unstages unrelated pre-staged paths, rejects empty staged diffs, and prints the message format, branch, staged name-status, shortstat, and optional full diff. If it fails, stop with its error and a concise suggested fix.
The helper also acquires a repo+branch commit lock before staging. If it fails because another agent is already committing for this repo and branch, stop and tell the user that committing is blocked by another active commit attempt. Do not describe internal lock paths, tokens, retries, or metadata.
On success, save the ## commit lock token value from the helper output. Treat it as internal. Release it exactly once with:
bash "<skill-dir>/scripts/commit-lock.sh" release "<commit-lock-token>"Run the release command after the commit workflow completes, including after optional push. If any post-prepare step fails or you stop before committing, release the lock before reporting the failure.
- If
--all: - Include all tracked, untracked, modified, deleted, and already staged changes
- If
--staged: - Commit exactly what is already staged; pass no session paths. The helper neither stages nor unstages. Conflicts with
--all. - Otherwise (atomic commits):
- Session-modified files = files edited in this session
- Pass every session-modified path after
-- - The helper stages only those paths and unstages unrelated pre-staged paths
- Unrelated changes: session-modified files may contain pre-existing uncommitted changes (hunks not from this session). Include the entire file—partial staging is impractical. Never revert, discard, or
git checkoutunrelated changes.
3) Analyze + compose message
Read the helper output and produce the commit message in a single pass.
Message format — use the ## message format value from the helper output.
- If
conventional: read references/conventional-prefix-format.md. - If
natural: read references/natural-language-format.md.
Read only the selected format reference before composing the message.
Unrelated hunks — ignore pre-existing changes when determining type/scope/description. If unrelated changes are in the same file as session changes, they are included in the commit scope but should not influence the message.
Issue linking — scan the chat transcript for GitHub issue references (e.g. #123, owner/repo#123, issue URLs) that the current changes resolve. For each match, append a Closes #N trailer. Skip issues merely mentioned in passing; include only ones the commit actually closes.
If `--deep`:
- Deep semantic analysis; detect breaking changes
- Infer Conventional Prefix Format scope or Natural Language context from code structure even when path isn't clear
- Follow the selected reference's body and breaking-change rules
If `--close`:
- Append a
Closes #Nline for each issue number provided - Multiple issues: one
Closes #Nper line in the body/trailer - Merge with transcript-scanned issues; de-duplicate
4) Commit
- Use
git commit -m "subject"(add-m "body"only if body is non-empty) - Output exactly: commit hash, subject, and
N files changedsummary. Nothing else. - Do not report branch ahead/behind counts, unpushed commits, push availability, unrelated tree state, staging steps, or pre-commit hook activity unless a command failed.
- If failed: show error + suggest fix
- Pre-commit hook failure: if the hook fails on unrelated/pre-existing changes (not this session's changes), retry automatically with
git commit --no-verify— do not ask. Report the bypass in one line, noting the failure was unrelated to the staged changes. Never bypass hooks for failures caused by the session's own changes; fix those or surface the error instead. - Keep the commit lock held through hook retries, then release it before reporting the final result or final failure.
5) Push (if --push)
- If upstream exists:
git push - If no upstream:
git push -u origin HEAD - If failed: show error + suggest fix (pull/rebase first, set upstream, check auth)
- Release the commit lock after push succeeds or fails, before the final user-facing response.
policy:
allow_implicit_invocation: true
Conventional Prefix Format
Use this format by default. Prefix the subject with a Conventional Commits-style type, optionally followed by a scope.
Type Inference
Infer the type from the dominant user-visible intent, not the largest file diff or the presence of dependency/config churn.
Choose the highest-signal behavior that explains why the commit exists:
- If a dependency bump only enables a migration/refactor/fix, use the migration/refactor/fix type instead of
chore(deps). - If tooling/scripts/config changes keep existing behavior working after a code migration, use the same type as the migration.
- Use
choreonly for maintenance that does not fit a more specific behavioral category. - Use
chore(deps)only for dependency-only updates or dependency updates whose main purpose is routine maintenance.
| Behavior | Type |
|---|---|
| New functionality | feat |
| Bug fix / error handling | fix |
| Code migration or API adaptation without new UX/API | refactor |
| Code reorganization, no behavior change | refactor |
| Documentation | docs |
| Tests | test |
| Build system (webpack, vite, esbuild) | build |
| CI/CD pipelines | ci |
| Dependency-only maintenance | chore(deps) |
| Formatting / whitespace only | style |
| Performance | perf |
| Reverting previous commit | revert |
| AI config (CLAUDE.md, .claude/, .gemini/, .codex/) | ai |
| Other maintenance | chore |
Explicit type keyword in arguments takes precedence over inference.
Scope
Infer scope only when the path or code structure makes it obvious. Keep scope lowercase.
With --deep, infer scope from code structure even when the path alone is unclear.
Subject
- Subject line (\<= 50 chars):
type(scope): descriptionortype: description - Description uses imperative mood:
add, notadded - Description is lowercase unless a proper noun or code identifier requires casing
- No trailing period
- Describe what the change does, not which files changed
Body
- Use hyphenated lines for distinct changes
- Skip the body for trivial changes
- With
--deep, write 2-3 hyphenated lines max and focus on why the change exists - For breaking changes, add
BREAKING CHANGE:plus a one-line migration note
Natural Language Format
Use this format only when --natural is present. Write a human-readable commit subject in the spirit of Common Changelog entries: present-tense, imperative, impact-focused, and self-describing. Do not add a Conventional Commits prefix.
Verb Selection
Choose the leading verb from the dominant user-visible intent, not the largest file diff or the presence of dependency/config churn. Common Changelog's core wording is useful, but do not stop at Change, Add, Remove, and Fix when a sharper verb exists.
| Behavior | Leading verb |
|---|---|
| New functionality | Add |
| Bug fix / error handling | Fix |
| Existing behavior or API change | Change |
| Removed functionality | Remove |
| Deprecated functionality | Deprecate |
| Code migration or API adaptation without new UX/API | Refactor |
| Code reorganization, no behavior change | Refactor |
| Documentation | Document |
| Tests | Test |
| Build system or local tooling | Configure, Build |
| CI/CD pipelines | Configure |
| Dependency-only maintenance | Bump |
| Formatting / whitespace only | Format |
| Performance | Improve, Speed up |
| Security | Harden |
| Reverting previous commit | Revert |
| AI config (CLAUDE.md, .claude/, .gemini/, .codex/) | Update |
| Other maintenance | Update |
Use Change only for a meaningful behavior/API change. For maintenance, prefer a more precise verb such as Configure, Bump, Document, or Refactor.
If a dependency bump only enables a migration/refactor/fix, choose the migration/refactor/fix verb instead of Bump.
Explicit leading verb/category keywords in arguments take precedence over inference. Normalize lowercase keywords and Changed, Added, Removed, and Fixed to the table's imperative forms.
Subject
- Subject line (\<= 72 chars, prefer \<= 50 when it still reads naturally):
Verb object/context - Capitalize the leading verb and proper nouns only
- No trailing period
- Describe what the change does, not which files changed
- Keep the subject self-describing without relying on a category label
- Do not add
type:,type(scope):, ticket IDs, or changelog headings
Examples:
Add natural-language commit messagesFix commit hook retry handlingRemove stale release helperRefactor API client setupBump Foundry from 1.x to 2.x
Body
- Use hyphenated lines for distinct changes
- Skip the body for trivial changes
- With
--deep, write 2-3 hyphenated lines max and focus on why the change exists - For breaking changes, add
BREAKING CHANGE:plus a one-line migration note
#!/usr/bin/env bash
set -u
lock_sleep_seconds=15
lock_max_waits=10
usage() {
printf 'Usage: bash <skill-dir>/scripts/commit-lock.sh acquire|release [lock_token]\n' >&2
}
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
physical_dir() {
_dir=$1
[ -d "$_dir" ] || return 1
(cd "$_dir" 2>/dev/null && pwd -P)
}
hash_stdin() {
if command -v shasum >/dev/null 2>&1; then
_hash_output=$(shasum -a 256) || return 1
elif command -v sha256sum >/dev/null 2>&1; then
_hash_output=$(sha256sum) || return 1
else
die 'missing shasum or sha256sum'
fi
_hash_output=${_hash_output%% *}
printf '%s\n' "$_hash_output"
}
resolve_repo_context() {
inside_work_tree=$(git rev-parse --is-inside-work-tree 2>/dev/null) || die 'not inside a git work tree'
[ "$inside_work_tree" = true ] || die 'not inside a git work tree'
repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || die 'cannot resolve git repository root'
repo_root=$(physical_dir "$repo_root") || die 'cannot resolve git repository root'
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || die 'detached HEAD; check out a branch before committing'
git_dir=$(git rev-parse --absolute-git-dir 2>/dev/null) || die 'cannot resolve git directory'
git_dir=$(physical_dir "$git_dir") || die 'cannot resolve git directory'
lock_root="$git_dir/agent-skills/commit-locks"
}
resolve_lock_root() {
inside_work_tree=$(git rev-parse --is-inside-work-tree 2>/dev/null) || die 'not inside a git work tree'
[ "$inside_work_tree" = true ] || die 'not inside a git work tree'
git_dir=$(git rev-parse --absolute-git-dir 2>/dev/null) || die 'cannot resolve git directory'
git_dir=$(physical_dir "$git_dir") || die 'cannot resolve git directory'
lock_root="$git_dir/agent-skills/commit-locks"
}
pid_is_running() {
_pid=$1
case "$_pid" in
'' | *[!0123456789]*)
return 1
;;
esac
kill -0 "$_pid" 2>/dev/null
}
metadata_value() {
_metadata_file=$1
_key=$2
while IFS= read -r _line; do
case "$_line" in
"$_key="*)
printf '%s\n' "${_line#*=}"
return 0
;;
esac
done <"$_metadata_file"
return 1
}
remove_stale_lock() {
_lock_dir=$1
_metadata_file="$_lock_dir/metadata"
if [ ! -f "$_metadata_file" ]; then
rmdir "$_lock_dir" 2>/dev/null
return $?
fi
_holder_pid=$(metadata_value "$_metadata_file" "pid" 2>/dev/null) || return 1
if pid_is_running "$_holder_pid"; then
return 1
fi
rm -f "$_metadata_file" 2>/dev/null || return 1
rmdir "$_lock_dir" 2>/dev/null
}
acquire_lock() {
[ "$#" -eq 0 ] || {
usage
die "unexpected argument: $1"
}
resolve_repo_context
lock_hash=$(printf '%s\n%s\n' "$repo_root" "$branch" | hash_stdin) || die 'failed to hash commit lock key'
owner=$(printf '%s\n%s\n%s\n%s\n%s\n%s\n' "$repo_root" "$branch" "$$" "$(date +%s)" "$RANDOM" "$RANDOM" | hash_stdin) || die 'failed to create commit lock owner'
lock_holder_pid=$PPID
lock_token="$lock_hash:$owner"
lock_dir="$lock_root/$lock_hash.lock"
mkdir -p "$lock_root" || die 'failed to create commit lock directory'
waits=0
waiting_reported=false
while ! mkdir "$lock_dir" 2>/dev/null; do
if remove_stale_lock "$lock_dir"; then
continue
fi
if [ "$waits" -ge "$lock_max_waits" ]; then
die 'another agent is already committing for this repo and branch'
fi
if [ "$waiting_reported" = false ]; then
printf 'waiting for another commit attempt to finish...\n' >&2
waiting_reported=true
fi
sleep "$lock_sleep_seconds"
waits=$((waits + 1))
done
if ! {
printf 'owner=%s\n' "$owner"
printf 'repo=%s\n' "$repo_root"
printf 'branch=%s\n' "$branch"
printf 'pid=%s\n' "$lock_holder_pid"
printf 'helper_pid=%s\n' "$$"
date -u '+created_at=%Y-%m-%dT%H:%M:%SZ'
} >"$lock_dir/metadata"; then
rm -f "$lock_dir/metadata"
rmdir "$lock_dir" 2>/dev/null
die 'failed to write commit lock metadata'
fi
printf '%s\n' "$lock_token"
}
release_lock() {
[ "$#" -eq 1 ] || {
usage
die 'release requires a lock token'
}
lock_token=$1
case "$lock_token" in
*:*) ;;
*)
die 'invalid lock token'
;;
esac
lock_hash=${lock_token%%:*}
owner=${lock_token#*:}
case "$lock_hash" in
'' | *[!0123456789abcdef]*)
die 'invalid lock token'
;;
esac
case "$owner" in
'' | *[!0123456789abcdef]*)
die 'invalid lock token'
;;
esac
resolve_lock_root
lock_dir="$lock_root/$lock_hash.lock"
[ -d "$lock_dir" ] || exit 0
metadata_file="$lock_dir/metadata"
[ -f "$metadata_file" ] || die 'commit lock metadata is missing'
IFS= read -r owner_line <"$metadata_file" || die 'failed to read commit lock metadata'
case "$owner_line" in
owner=*) stored_owner=${owner_line#owner=} ;;
*) die 'commit lock metadata is invalid' ;;
esac
[ "$stored_owner" = "$owner" ] || die 'commit lock is owned by another process'
rm -f "$metadata_file" || die 'failed to remove commit lock metadata'
rmdir "$lock_dir" || die 'failed to remove commit lock directory'
}
case "${1:-}" in
acquire)
shift
acquire_lock "$@"
;;
release)
shift
release_lock "$@"
;;
*)
usage
die 'expected acquire or release'
;;
esac
#!/usr/bin/env bash
set -u
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd -P) || {
printf 'error: cannot resolve commit skill script directory\n' >&2
exit 1
}
commit_lock_token=
should_release_commit_lock=false
release_commit_lock() {
[ "$should_release_commit_lock" = true ] || return 0
[ -n "$commit_lock_token" ] || return 0
bash "$script_dir/commit-lock.sh" release "$commit_lock_token" >/dev/null 2>&1 || true
}
trap release_commit_lock EXIT
usage() {
printf 'Usage: bash <skill-dir>/scripts/prepare-commit.sh [--all] [--staged] [--natural] [--diff summary|full] -- [session_modified_paths...]\n' >&2
}
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
add_unique_path() {
_candidate=$1
shift
for _existing in "$@"; do
if [ "$_existing" = "$_candidate" ]; then
return 1
fi
done
return 0
}
path_in_list() {
_needle=$1
shift
for _candidate in "$@"; do
if [ "$_candidate" = "$_needle" ]; then
return 0
fi
done
return 1
}
physical_dir() {
_dir=$1
[ -d "$_dir" ] || return 1
(cd "$_dir" 2>/dev/null && pwd -P)
}
collect_path_output() {
while IFS= read -r -d '' _path; do
if add_unique_path "$_path" ${session_git_paths[@]+"${session_git_paths[@]}"}; then
session_git_paths[${#session_git_paths[@]}]=$_path
fi
done
}
collect_stageable_paths() {
for _path in "$@"; do
if [ -e "$_path" ] || [ -L "$_path" ] || git ls-files --error-unmatch -- "$_path" >/dev/null 2>&1; then
if add_unique_path "$_path" ${stageable_paths[@]+"${stageable_paths[@]}"}; then
stageable_paths[${#stageable_paths[@]}]=$_path
fi
fi
done
}
collect_unstage_path() {
_path=$1
if add_unique_path "$_path" ${unstage_paths[@]+"${unstage_paths[@]}"}; then
unstage_paths[${#unstage_paths[@]}]=$_path
fi
}
unstage_collected_paths() {
[ "${#unstage_paths[@]}" -gt 0 ] || return 0
_chunk=()
for _path in "${unstage_paths[@]}"; do
_chunk[${#_chunk[@]}]=$_path
if [ "${#_chunk[@]}" -ge "$unstage_chunk_size" ]; then
git restore --staged -- "${_chunk[@]}" || return 1
_chunk=()
fi
done
if [ "${#_chunk[@]}" -gt 0 ]; then
git restore --staged -- "${_chunk[@]}" || return 1
fi
}
resolve_message_format() {
if [ "$force_natural" = true ]; then
printf 'natural\n'
return 0
fi
[ -n "${HOME:-}" ] || die 'HOME is not set'
_repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || die 'cannot resolve git repository root'
_repo_root=$(physical_dir "$_repo_root") || die 'cannot resolve git repository root'
_always_natural_language_repos=(
"$HOME/.agents"
"$HOME/.claude"
"$HOME/.codex"
"$HOME/.local/share/chezmoi"
"$HOME/projects/agent-skills"
"$HOME/projects/evm-sweeper"
"$HOME/projects/home-control"
"$HOME/projects/prb-chats"
"$HOME/projects/prb-finance"
"$HOME/work/mailops"
)
for _natural_repo in "${_always_natural_language_repos[@]}"; do
_natural_repo_root=$(physical_dir "$_natural_repo") || continue
if [ "$_repo_root" = "$_natural_repo_root" ]; then
printf 'natural\n'
return 0
fi
done
printf 'conventional\n'
}
all=false
staged=false
force_natural=false
diff_mode=summary
unstage_chunk_size=100
session_paths=()
session_git_paths=()
stageable_paths=()
unstage_paths=()
while [ "$#" -gt 0 ]; do
case "$1" in
--all)
all=true
shift
;;
--staged)
staged=true
shift
;;
--natural)
force_natural=true
shift
;;
--diff)
[ "$#" -ge 2 ] || {
usage
die '--diff requires summary or full'
}
diff_mode=$2
case "$diff_mode" in
summary | full) ;;
*)
usage
die '--diff must be summary or full'
;;
esac
shift 2
;;
--)
shift
break
;;
-*)
usage
die "unknown option: $1"
;;
*)
break
;;
esac
done
while [ "$#" -gt 0 ]; do
session_paths[${#session_paths[@]}]=$1
shift
done
if [ "$all" = true ] && [ "$staged" = true ]; then
usage
die '--all and --staged are mutually exclusive'
fi
inside_work_tree=$(git rev-parse --is-inside-work-tree 2>/dev/null) || die 'not inside a git work tree'
[ "$inside_work_tree" = true ] || die 'not inside a git work tree'
# Anchor to the repository root so repo-root-relative session pathspecs resolve
# correctly regardless of the caller's current directory. Without this, running
# from a subdirectory makes git interpret pathspecs relative to that subdir,
# doubling the prefix and matching nothing.
repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || die 'cannot resolve git repository root'
cd "$repo_root" || die 'cannot enter git repository root'
merge_head=$(git rev-parse --git-path MERGE_HEAD 2>/dev/null) || die 'cannot resolve git state'
cherry_pick_head=$(git rev-parse --git-path CHERRY_PICK_HEAD 2>/dev/null) || die 'cannot resolve git state'
rebase_merge=$(git rev-parse --git-path rebase-merge 2>/dev/null) || die 'cannot resolve git state'
rebase_apply=$(git rev-parse --git-path rebase-apply 2>/dev/null) || die 'cannot resolve git state'
[ ! -f "$merge_head" ] || die 'merge in progress; resolve or abort it before committing'
[ ! -f "$cherry_pick_head" ] || die 'cherry-pick in progress; resolve or abort it before committing'
[ ! -d "$rebase_merge" ] || die 'rebase in progress; resolve or abort it before committing'
[ ! -d "$rebase_apply" ] || die 'rebase in progress; resolve or abort it before committing'
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || die 'detached HEAD; check out a branch before committing'
commit_lock_token=$(bash "$script_dir/commit-lock.sh" acquire) || exit 1
should_release_commit_lock=true
message_format=$(resolve_message_format) || exit 1
if [ "$all" = true ]; then
if [ -z "$(git status --porcelain=v1 --untracked-files=all)" ]; then
die 'No changes to commit'
fi
git add -A || die 'failed to stage all changes'
elif [ "$staged" = true ]; then
: # commit the current index as-is; the empty-index guard below applies
else
[ "${#session_paths[@]}" -gt 0 ] || die 'No files modified in this session'
collect_path_output < <(git diff --cached --name-only -z --no-ext-diff --no-textconv -- "${session_paths[@]}") || exit 1
collect_path_output < <(git ls-files --full-name -z --modified --deleted --others --exclude-standard -- "${session_paths[@]}") || exit 1
while IFS= read -r -d '' staged_status; do
case "$staged_status" in
R* | C*)
IFS= read -r -d '' staged_old_path || die 'failed to parse staged rename/copy'
IFS= read -r -d '' staged_new_path || die 'failed to parse staged rename/copy'
if ! path_in_list "$staged_old_path" ${session_git_paths[@]+"${session_git_paths[@]}"} && ! path_in_list "$staged_new_path" ${session_git_paths[@]+"${session_git_paths[@]}"}; then
collect_unstage_path "$staged_old_path"
collect_unstage_path "$staged_new_path"
fi
;;
*)
IFS= read -r -d '' staged_path || die 'failed to parse staged path'
if ! path_in_list "$staged_path" ${session_git_paths[@]+"${session_git_paths[@]}"}; then
collect_unstage_path "$staged_path"
fi
;;
esac
done < <(git diff --cached --name-status -z --no-ext-diff --no-textconv)
unstage_collected_paths || die 'failed to unstage unrelated staged paths'
[ "${#session_git_paths[@]}" -gt 0 ] || die 'No files modified in this session'
collect_stageable_paths "${session_paths[@]}"
if [ "${#stageable_paths[@]}" -gt 0 ]; then
git add -- "${stageable_paths[@]}" || die 'failed to stage session-modified paths'
fi
fi
if git diff --cached --quiet --exit-code; then
die 'No staged changes to commit'
fi
printf '## message format\n'
printf '%s\n\n' "$message_format"
printf '## branch\n'
printf '%s\n\n' "$branch"
printf '## commit lock token\n'
printf '%s\n\n' "$commit_lock_token"
printf '## staged name-status\n'
git diff --cached --name-status --no-ext-diff --no-textconv -- || die 'failed to print staged name-status'
printf '\n'
printf '## shortstat\n'
git diff --cached --shortstat --no-ext-diff --no-textconv -- || die 'failed to print staged shortstat'
if [ "$diff_mode" = full ]; then
printf '\n## staged diff\n'
git diff --cached --no-ext-diff --no-textconv -- || die 'failed to print staged diff'
fi
should_release_commit_lock=false
#!/usr/bin/env bash
set -u
usage() {
printf 'Usage: bash <skill-dir>/scripts/select-message-format.sh [--natural]\n' >&2
}
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
physical_dir() {
_dir=$1
[ -d "$_dir" ] || return 1
(cd "$_dir" 2>/dev/null && pwd -P)
}
force_natural=false
while [ "$#" -gt 0 ]; do
case "$1" in
--natural)
force_natural=true
shift
;;
--)
shift
break
;;
-*)
usage
die "unknown option: $1"
;;
*)
usage
die "unexpected argument: $1"
;;
esac
done
[ "$#" -eq 0 ] || {
usage
die "unexpected argument: $1"
}
if [ "$force_natural" = true ]; then
printf 'natural\n'
exit 0
fi
[ -n "${HOME:-}" ] || die 'HOME is not set'
inside_work_tree=$(git rev-parse --is-inside-work-tree 2>/dev/null) || die 'not inside a git work tree'
[ "$inside_work_tree" = true ] || die 'not inside a git work tree'
repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || die 'cannot resolve git repository root'
repo_root=$(physical_dir "$repo_root") || die 'cannot resolve git repository root'
always_natural_language_repos=(
"$HOME/.agents"
"$HOME/.claude"
"$HOME/.codex"
"$HOME/.local/share/chezmoi"
"$HOME/projects/agent-skills"
"$HOME/projects/evm-sweeper"
"$HOME/projects/home-control"
"$HOME/projects/prb-chats"
"$HOME/projects/prb-finance"
"$HOME/work/mailops"
)
for natural_repo in "${always_natural_language_repos[@]}"; do
natural_repo_root=$(physical_dir "$natural_repo") || continue
if [ "$repo_root" = "$natural_repo_root" ]; then
printf 'natural\n'
exit 0
fi
done
printf 'conventional\n'