← back to Ventura Claw Leads
Auto-fire codex-3way on every commit (hook + viewer)
bdc273042863f3f8451ae28893c3d06ce6eddf38 · 2026-05-07 15:14:31 -0700 · Steve Abrams
scripts/post-commit-hook.sh runs the 3-way debate in background after
every commit (with skips for trivial diffs and non-code paths). Hook
output lands at .git/codex-3way-hook/latest.summary.md as a symlink to
the latest run's summary, so the next yolo-loop tick can just read
that file and adjudicate findings without manually invoking the skill.
Three tracked scripts:
- post-commit-hook.sh : the actual hook logic (skip rules + bg fire)
- install-hooks.sh : per-clone setup (symlinks .git/hooks/post-commit)
- last-debate.sh : print the latest summary for ad-hoc inspection
Skip rules:
- only fires when .js/.ejs/.sql/.ts/.tsx/.json/.sh files changed
- skips diffs <5 lines (avoids burning compute on doc tweaks)
- self-recursion guard via CODEX_3WAY_HOOK_RUNNING env var
Non-blocking: nohup + disown so commit returns immediately.
Files touched
A scripts/install-hooks.shA scripts/last-debate.shA scripts/post-commit-hook.sh
Diff
commit bdc273042863f3f8451ae28893c3d06ce6eddf38
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Thu May 7 15:14:31 2026 -0700
Auto-fire codex-3way on every commit (hook + viewer)
scripts/post-commit-hook.sh runs the 3-way debate in background after
every commit (with skips for trivial diffs and non-code paths). Hook
output lands at .git/codex-3way-hook/latest.summary.md as a symlink to
the latest run's summary, so the next yolo-loop tick can just read
that file and adjudicate findings without manually invoking the skill.
Three tracked scripts:
- post-commit-hook.sh : the actual hook logic (skip rules + bg fire)
- install-hooks.sh : per-clone setup (symlinks .git/hooks/post-commit)
- last-debate.sh : print the latest summary for ad-hoc inspection
Skip rules:
- only fires when .js/.ejs/.sql/.ts/.tsx/.json/.sh files changed
- skips diffs <5 lines (avoids burning compute on doc tweaks)
- self-recursion guard via CODEX_3WAY_HOOK_RUNNING env var
Non-blocking: nohup + disown so commit returns immediately.
---
scripts/install-hooks.sh | 22 +++++++++++++++++
scripts/last-debate.sh | 21 ++++++++++++++++
scripts/post-commit-hook.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 103 insertions(+)
diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh
new file mode 100755
index 0000000..571c18c
--- /dev/null
+++ b/scripts/install-hooks.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# install-hooks.sh — symlink tracked hook scripts into .git/hooks/.
+# Run once per clone. Idempotent.
+
+set -euo pipefail
+
+REPO_DIR="$(git rev-parse --show-toplevel)"
+HOOKS_DIR="$REPO_DIR/.git/hooks"
+SCRIPTS_DIR="$REPO_DIR/scripts"
+
+mkdir -p "$HOOKS_DIR"
+chmod +x "$SCRIPTS_DIR"/*.sh 2>/dev/null || true
+
+# post-commit → fires codex-3way debate in background
+cat > "$HOOKS_DIR/post-commit" <<'HOOK'
+#!/usr/bin/env bash
+exec "$(git rev-parse --show-toplevel)/scripts/post-commit-hook.sh"
+HOOK
+chmod +x "$HOOKS_DIR/post-commit"
+
+echo "[install-hooks] post-commit installed → scripts/post-commit-hook.sh"
+echo "[install-hooks] done"
diff --git a/scripts/last-debate.sh b/scripts/last-debate.sh
new file mode 100755
index 0000000..3a075fa
--- /dev/null
+++ b/scripts/last-debate.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# last-debate.sh — print the latest auto-generated codex-3way summary.
+# Used by yolo-loop ticks: 'cat scripts/last-debate.sh' to read what the
+# robot found in the most recent commit.
+
+set -u
+REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
+LATEST="$REPO_DIR/.git/codex-3way-hook/latest.summary.md"
+
+if [ ! -e "$LATEST" ]; then
+ echo "(no codex-3way summary yet — make a commit and wait ~3 min)"
+ exit 0
+fi
+
+if [ -L "$LATEST" ]; then
+ TARGET="$(readlink "$LATEST")"
+ echo "## Latest codex-3way debate"
+ echo "Source: $TARGET"
+ echo
+fi
+cat "$LATEST"
diff --git a/scripts/post-commit-hook.sh b/scripts/post-commit-hook.sh
new file mode 100755
index 0000000..22a03f5
--- /dev/null
+++ b/scripts/post-commit-hook.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# post-commit: fire codex-3way in background to debate this commit's diff.
+# Non-blocking — never delays the commit.
+#
+# Skips commits where the diff is trivial (no .js/.ejs/.sql/.json changed,
+# or fewer than 5 lines of effective code change). The codex-3way panel
+# costs Mac2 RSS + a Kimi call — not worth burning on README tweaks.
+
+set -u
+
+REPO_DIR="$(git rev-parse --show-toplevel)"
+SHA="$(git rev-parse HEAD)"
+SHORT="$(git rev-parse --short HEAD)"
+SKILL="$HOME/.claude/skills/codex-3way/scripts/run.sh"
+LOG_DIR="$REPO_DIR/.git/codex-3way-hook"
+mkdir -p "$LOG_DIR"
+
+# Skip-rule 1: only run if at least one of these extensions changed.
+if ! git diff --name-only HEAD~1..HEAD | grep -qE '\.(js|ejs|sql|ts|tsx|json|sh)$'; then
+ exit 0
+fi
+
+# Skip-rule 2: skip trivial commits (< 5 added+removed lines).
+LINES="$(git diff --shortstat HEAD~1..HEAD | grep -oE '[0-9]+ insertions?|[0-9]+ deletions?' | grep -oE '[0-9]+' | awk '{s+=$1} END {print s+0}')"
+if [ "${LINES:-0}" -lt 5 ]; then
+ exit 0
+fi
+
+# Skip-rule 3: don't recurse — if the commit was made BY the hook (defensive).
+if [ -n "${CODEX_3WAY_HOOK_RUNNING:-}" ]; then
+ exit 0
+fi
+
+# Skip-rule 4: bail out cleanly if the skill isn't installed.
+if [ ! -x "$SKILL" ]; then
+ echo "[post-commit] codex-3way not installed at $SKILL — skip" >&2
+ exit 0
+fi
+
+NAME="auto-${SHORT}"
+LOG="$LOG_DIR/$NAME.log"
+LATEST_SUMMARY="$LOG_DIR/latest.summary.md"
+
+# Detach, no terminal, redirect everything. Don't block commit.
+nohup bash -c "
+ CODEX_3WAY_HOOK_RUNNING=1 \
+ bash '$SKILL' --base HEAD~1 --rounds 1 --name '$NAME' --workdir '$REPO_DIR' >> '$LOG' 2>&1
+ # Find newest matching run dir and symlink its summary.md
+ RUN=\$(ls -td '$HOME/.claude/skills/codex-3way/runs/'*-'$NAME' 2>/dev/null | head -1)
+ if [ -n \"\$RUN\" ] && [ -f \"\$RUN/summary.md\" ]; then
+ ln -sf \"\$RUN/summary.md\" '$LATEST_SUMMARY'
+ echo \"[post-commit] codex-3way done for $SHORT — summary at $LATEST_SUMMARY\" >> '$LOG'
+ fi
+" > /dev/null 2>&1 &
+
+# Detach the bg process so the commit returns immediately.
+disown 2>/dev/null || true
+
+echo "[post-commit] codex-3way fired for $SHORT (background; tail $LOG)"
+exit 0
← 6ca9edb Geocode the final 38 stragglers via Nominatim — map now 100%
·
back to Ventura Claw Leads
·
/find a11y: combobox pattern + aria-current on pagination + 94e6ea5 →