From 08b5db81adfeb5dc82bc6630e7be38516295bb50 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 29 Mar 2026 23:18:27 +0200 Subject: [PATCH] Add /commit skill to bypass sandbox for Lefthook hooks Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/commands/commit.md | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .claude/commands/commit.md diff --git a/.claude/commands/commit.md b/.claude/commands/commit.md new file mode 100644 index 0000000..450b711 --- /dev/null +++ b/.claude/commands/commit.md @@ -0,0 +1,72 @@ +--- +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: + +```bash +git status +``` + +```bash +git diff +``` + +```bash +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) +``` + +Use a HEREDOC for the commit message: + +```bash +git commit -m "$(cat <<'EOF' + + + + +Co-Authored-By: Claude Opus 4.6 (1M context) +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 + +```text +$ARGUMENTS +``` + +If the user provided arguments, treat them as the commit message or guidance for what to commit.