Create a conventional commit with pre-commit validation — format check, sensitive file detection, test count verification
Create a git commit following this project's conventions, with automatic pre-commit validation.
Run these in parallel:
git status — see all untracked and modified filesgit diff --staged — see what's already stagedgit diff — see unstaged changesgit log --oneline -10 — recent commit messages for style referencegit branch --show-current — current branch name.env, credentials.json, *.pem, *.key, secrets. Warn if these appear in the diff.git add -ABefore committing, run these checks:
Format check — find all changed C/C++ files and verify formatting:
git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(h|cpp)$' | xargs -r clang-format-18 --dry-run --Werror 2>&1
If format issues are found:
clang-format-18 -i <files>Sensitive file check — scan staged filenames AND diff content for secrets:
# Check filenames for known secret file patterns
git diff --cached --name-only | grep -iE '\.env|credential|secret|\.pem|\.key|token'
# Check staged diff content for hardcoded secrets (passwords, API keys, tokens)
git diff --cached -U0 | grep -iE 'password\s*=|api_key\s*=|secret\s*=|token\s*=|-----BEGIN' | head -20
If either check finds matches, warn the user with the specific matches and ask for explicit confirmation before proceeding.
Test count check (only if test files changed) — if any files in tests/ are staged:
ctest -N --test-dir build 2>/dev/null | grep "Total Tests:"
Compare against the baseline in tests/TESTS.md. Warn if mismatched.
Follow the project's conventional commit format: type(#issue): description
Types: feat, fix, refactor, test, docs, chore, perf
Rules:
feature/issue-XX-* or fix/issue-XX-* patternCo-Authored-By: Claude Opus 4.6 <[email protected]>If the user provided a description in $ARGUMENTS, use it as the basis for the commit message.
Show the draft message and ask for approval. Then commit using a heredoc:
git commit -m "$(cat <<'EOF'
type(#issue): subject line
Optional body explaining why.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
EOF
)"
Run git status to confirm the commit succeeded and show the result.
If the commit fails due to a pre-commit hook:
git commit with the same message--amend would modify the previous unrelated commit — only use --amend if a commit already exists and you explicitly want to update itIf the user provided arguments, use them as context: $ARGUMENTS