Files
initiative/.claude/commands/commit.md
Lukas 08b5db81ad Add /commit skill to bypass sandbox for Lefthook hooks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 23:18:27 +02:00

1.8 KiB

description
description
Create a git commit with pre-commit hooks (bypasses sandbox restrictions).

Instructions

Create a git commit for the current staged and/or unstaged changes.

Step 1 — Assess changes

Run these in parallel:

git status
git diff
git log --oneline -5

Step 2 — Draft commit message

  • Summarize the nature of the changes (new feature, enhancement, bug fix, refactor, test, docs, etc.)
  • Keep the first line concise (under 72 chars), use imperative mood
  • Add a blank line and a short body if the "why" isn't obvious from the first line
  • Match the style of recent commits in the log
  • Do not commit files that likely contain secrets (.env, credentials, etc.)

Step 3 — Stage and commit

Stage relevant files by name (avoid git add -A or git add .). Then commit.

CRITICAL: Always use dangerouslyDisableSandbox: true for the commit command. Lefthook pre-commit hooks spawn subprocesses (biome, oxlint, vitest, etc.) that require filesystem access beyond what the sandbox allows. They will always fail with "operation not permitted" in sandbox mode.

Append the co-author trailer:

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Use a HEREDOC for the commit message:

git commit -m "$(cat <<'EOF'
<first line>

<optional body>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EOF
)"

Step 4 — Verify

Run git status after the commit to confirm success.

If the commit fails

If a pre-commit hook fails, fix the issue, re-stage, and create a new commit. Never amend unless explicitly asked — amending after a hook failure would modify the previous commit.

User arguments

$ARGUMENTS

If the user provided arguments, treat them as the commit message or guidance for what to commit.