<feed xmlns='http://www.w3.org/2005/Atom'>
<title>claude-plugins-official.git/plugins/security-guidance/hooks/sg-python.sh, branch bump/cloud-sql-sqlserver</title>
<subtitle>Official Claude Code plugin directory
</subtitle>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/'/>
<entry>
<title>security-guidance: set an environment variable for the launcher's interpreter probes</title>
<updated>2026-11-09T18:55:10+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-11-09T18:55:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=f3700b581c4f4df3b69cba3e276b23042f1bf200'/>
<id>f3700b581c4f4df3b69cba3e276b23042f1bf200</id>
<content type='text'>
sg-python.sh asks a candidate interpreter for its version and, for a
packaged Windows alias, for its real path, with `python -c`. Both calls
import only os and sys, so they now run with PYTHONSAFEPATH=1, which tells
Python not to add its usual first entry to the import path.

The variable is set for those two calls alone, so the hook starts with the
same environment as before. Python older than 3.11 ignores the variable.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sg-python.sh asks a candidate interpreter for its version and, for a
packaged Windows alias, for its real path, with `python -c`. Both calls
import only os and sys, so they now run with PYTHONSAFEPATH=1, which tells
Python not to add its usual first entry to the import path.

The variable is set for those two calls alone, so the hook starts with the
same environment as before. Python older than 3.11 ignores the variable.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: stop starting the packaged Python alias on every hook</title>
<updated>2026-10-27T20:11:58+00:00</updated>
<author>
<name>mhegazy</name>
<email>mhegazy@users.noreply.github.com</email>
</author>
<published>2026-10-27T20:11:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=70ef2c2ed7001343cc954bb6ea8060d9475639bb'/>
<id>70ef2c2ed7001343cc954bb6ea8060d9475639bb</id>
<content type='text'>
On Windows with the Python Install Manager, python, python3 and py are
packaged aliases under ...\Microsoft\WindowsApps, and each start of one
makes Windows run an App Installer update check for the package. The
launcher started the chosen alias twice per hook (probe, then the hook),
on every Edit, prompt and Stop. See anthropics/claude-code#98929.

When the name that answers is such an alias and its interpreter is a
regular python*.exe elsewhere, the launcher now checks that interpreter
once (same version, reads the hook script when started by itself), runs
the hook with it, and keeps its path in the state folder for a day.
Later hooks start it directly: one process, none through the alias.

The remembered path is used only while PATH and the hook folder are
unchanged and the file is still there. A hook that fails on it empties
the entry so the next hook searches again. Not used while VIRTUAL_ENV is
set. Other systems, regular installs and Microsoft Store Python are
unchanged.

Hooks report launcher_direct (1 remembered, 2 just checked) as the last
metric key on rows they already send.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Windows with the Python Install Manager, python, python3 and py are
packaged aliases under ...\Microsoft\WindowsApps, and each start of one
makes Windows run an App Installer update check for the package. The
launcher started the chosen alias twice per hook (probe, then the hook),
on every Edit, prompt and Stop. See anthropics/claude-code#98929.

When the name that answers is such an alias and its interpreter is a
regular python*.exe elsewhere, the launcher now checks that interpreter
once (same version, reads the hook script when started by itself), runs
the hook with it, and keeps its path in the state folder for a day.
Later hooks start it directly: one process, none through the alias.

The remembered path is used only while PATH and the hook folder are
unchanged and the file is still there. A hook that fails on it empties
the entry so the next hook searches again. Not used while VIRTUAL_ENV is
set. Other systems, regular installs and Microsoft Store Python are
unchanged.

Hooks report launcher_direct (1 remembered, 2 just checked) as the last
metric key on rows they already send.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'main' into mhegazy/sg-launcher-probe-timing</title>
<updated>2026-10-20T22:36:29+00:00</updated>
<author>
<name>Claude</name>
<email>noreply@anthropic.com</email>
</author>
<published>2026-10-20T22:36:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=6d4e17c8c4d45de2eba6dce119e56fff18ae43b1'/>
<id>6d4e17c8c4d45de2eba6dce119e56fff18ae43b1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: report how long the launcher waits for interpreter probes</title>
<updated>2026-10-19T16:29:25+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-15T22:47:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=d2919136660832d06d5260677b256033c7dbdbda'/>
<id>d2919136660832d06d5260677b256033c7dbdbda</id>
<content type='text'>
sg-python.sh asks each candidate interpreter for its version before running a
hook, and waits as long as that takes. Nothing recorded how long.

The launcher now times each probe with bash builtins (no extra process) and
passes the result to the hook, which reports two keys when the probes of one
launch took a second or more together:

- launcher_probe_ms: all probes of this launch
- launcher_probe_max_ms: the slowest one

The keys go last on a row, so they never displace an existing key. Measurement
only: the launcher still waits for every probe and picks the same interpreter.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sg-python.sh asks each candidate interpreter for its version before running a
hook, and waits as long as that takes. Nothing recorded how long.

The launcher now times each probe with bash builtins (no extra process) and
passes the result to the hook, which reports two keys when the probes of one
launch took a second or more together:

- launcher_probe_ms: all probes of this launch
- launcher_probe_max_ms: the slowest one

The keys go last on a row, so they never displace an existing key. Measurement
only: the launcher still waits for every probe and picks the same interpreter.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: find Python releases newer than the launcher's list</title>
<updated>2026-10-19T16:29:25+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-14T16:56:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=6d446623cb5fe608905d07ab4c3a2002a268ee65'/>
<id>6d446623cb5fe608905d07ab4c3a2002a268ee65</id>
<content type='text'>
sg-python.sh prefers the versioned names python3.13 to python3.10, then
python3 / python / py -3 when they are 3.10 or newer. A machine whose
`python3` is older (stock macOS: 3.9) and whose only newer interpreter is
python3.14 ended up on 3.9, which cannot load the agent SDK, so the commit
reviewer was off with no sign that an installed Python had been missed
(#4907, #5024).

- When none of the existing candidates is 3.10 or newer, try python3.14 to
  python3.19, oldest first, before settling for an older Python.
- An interpreter that is picked today is still picked: the newer names are
  only reached where the launcher used to fall back to a Python below 3.10
  or find none. Names not on PATH cost no process.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sg-python.sh prefers the versioned names python3.13 to python3.10, then
python3 / python / py -3 when they are 3.10 or newer. A machine whose
`python3` is older (stock macOS: 3.9) and whose only newer interpreter is
python3.14 ended up on 3.9, which cannot load the agent SDK, so the commit
reviewer was off with no sign that an installed Python had been missed
(#4907, #5024).

- When none of the existing candidates is 3.10 or newer, try python3.14 to
  python3.19, oldest first, before settling for an older Python.
- An interpreter that is picked today is still picked: the newer names are
  only reached where the launcher used to fall back to a Python below 3.10
  or find none. Names not on PATH cost no process.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: start fewer processes in the hook launcher</title>
<updated>2026-10-15T22:39:39+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-12T19:42:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=cae27dda6824b4861e305c3a145e22379fd837ed'/>
<id>cae27dda6824b4861e305c3a145e22379fd837ed</id>
<content type='text'>
sg-python.sh runs on every hook, and under Git Bash each command
substitution is a new Windows process, whether or not the interpreter it
probes exists (#6470). On a machine with only `python` it started 13
processes before the hook; it now starts 1.

- Skip interpreter names that are not on PATH (a builtin lookup) before
  probing them.
- The probe execs the interpreter in its subshell instead of forking
  again from it.
- Remember the first Python below 3.10 seen in pass 2 instead of probing
  the same names a second time in pass 3.
- Convert drive paths (/c/Users/...) to Windows form in-shell under Git
  Bash / MSYS2; mount points and Cygwin still go through cygpath.

Interpreter order and the choice made are unchanged.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sg-python.sh runs on every hook, and under Git Bash each command
substitution is a new Windows process, whether or not the interpreter it
probes exists (#6470). On a machine with only `python` it started 13
processes before the hook; it now starts 1.

- Skip interpreter names that are not on PATH (a builtin lookup) before
  probing them.
- The probe execs the interpreter in its subshell instead of forking
  again from it.
- Remember the first Python below 3.10 seen in pass 2 instead of probing
  the same names a second time in pass 3.
- Convert drive paths (/c/Users/...) to Windows form in-shell under Git
  Bash / MSYS2; mount points and Cygwin still go through cygpath.

Interpreter order and the choice made are unchanged.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: report launcher fallback and give-up as metrics</title>
<updated>2026-10-15T22:39:39+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-12T19:27:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=5a1d326c862f33d05a9e65f30e50a71a4e71d4a5'/>
<id>5a1d326c862f33d05a9e65f30e50a71a4e71d4a5</id>
<content type='text'>
Two count-only metrics, emitted only when nonzero, so the launcher change
can be checked in the field:

- launcher_fallback: the hook ran, but only because the launcher started
  the interpreter by its real path (the names on PATH could not read the
  plugin files). Added to the hook's and the SessionStart bootstrap's
  existing metrics.
- launcher_unreadable: no interpreter could read the hook script. No
  Python runs in that case, so the launcher prints the metrics line
  itself before exiting 1.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Two count-only metrics, emitted only when nonzero, so the launcher change
can be checked in the field:

- launcher_fallback: the hook ran, but only because the launcher started
  the interpreter by its real path (the names on PATH could not read the
  plugin files). Added to the hook's and the SessionStart bootstrap's
  existing metrics.
- launcher_unreadable: no interpreter could read the hook script. No
  Python runs in that case, so the launcher prints the metrics line
  itself before exiting 1.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: never run a hook with a Python that cannot read it</title>
<updated>2026-10-15T22:39:38+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-12T18:43:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=5ac3c91066c7ec7f36e84348316742f7dd12de6a'/>
<id>5ac3c91066c7ec7f36e84348316742f7dd12de6a</id>
<content type='text'>
On Windows, python/python3/py can be packaged launcher aliases (Microsoft
Store Python, Python Install Manager). Started through the alias, the
interpreter answers `-c` but has a different view of %APPDATA% and cannot
see a plugin staged there. sg-python.sh picked it, CPython failed with
"can't open file ... [Errno 2]" and exit code 2, and exit 2 from the
asyncRewake Stop hook was delivered to the model as review findings. The
model's reply ran the Stop hook again, so the session looped without ever
reviewing anything (#6251, #5781).

The launcher's probe now also checks that the interpreter can read the
hook script. When no name on PATH qualifies, it tries the other
python3/python entries on PATH by full path and the real executable each
alias reports. If nothing can read the script it says so and exits 1, so
a launch failure is never reported as findings.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Windows, python/python3/py can be packaged launcher aliases (Microsoft
Store Python, Python Install Manager). Started through the alias, the
interpreter answers `-c` but has a different view of %APPDATA% and cannot
see a plugin staged there. sg-python.sh picked it, CPython failed with
"can't open file ... [Errno 2]" and exit code 2, and exit 2 from the
asyncRewake Stop hook was delivered to the model as review findings. The
model's reply ran the Stop hook again, so the session looped without ever
reviewing anything (#6251, #5781).

The launcher's probe now also checks that the interpreter can read the
hook script. When no name on PATH qualifies, it tries the other
python3/python entries on PATH by full path and the real executable each
alias reports. If nothing can read the script it says so and exits 1, so
a launch failure is never reported as findings.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: purge text=True from subprocess.run + bake PYTHONUTF8=1 (#2099)</title>
<updated>2026-05-30T18:29:07+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-05-30T18:29:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=1ecf3d1bac6ca2be1fbedef9500ca1457da8d42d'/>
<id>1ecf3d1bac6ca2be1fbedef9500ca1457da8d42d</id>
<content type='text'>
URGENT WINDOWS FIX. Sibling of #2056 / PR #2075 but covering 14 more
sites that PR #2075 missed.

The bug class: on Windows with cp1252 default encoding (typical
en-US locale), `subprocess.run(..., text=True)` decodes child stdout
AND stderr via `locale.getpreferredencoding()`. When git emits a
UTF-8 byte that's undefined in cp1252 (e.g. `0x81` from ف, present
in any path/filename/branch ref/commit message containing
Arabic/Hebrew/CJK), Python's internal `_readerthread` raises
UnicodeDecodeError. The thread crash is silent in Python 3.13+ (only
printed to stderr), but `subprocess.run` returns `stdout=None` and
the caller AttributeErrors on `.strip()`. The user sees a misleading
"WinError 267" or similar catch-all message instead of the real
decode failure.

PR #2075 fixed 6 specific helpers in `diffstate.py` / `gitutil.py`.
This commit covers the 14 survivors. Plus a defense-in-depth belt:
`PYTHONUTF8=1` exported by sg-python.sh.

This commit:

1. sg-python.sh: `export PYTHONUTF8=1` (PEP 540). No-op on
   macOS/Linux (already UTF-8). On Windows, makes Python's
   `locale.getpreferredencoding()` return UTF-8 instead of cp1252 —
   so even if a future regression slips in text=True, the decode
   succeeds. Must be set BEFORE Python starts; changing it from
   inside the interpreter has no effect.

2. gitutil.py: convert 8 subprocess.run sites from
   `capture_output=True, text=True` to `capture_output=True` +
   manual `r.stdout.decode("utf-8", errors="replace")`:
     - _git_rev_parse_head           (stdout = SHA, stderr risk)
     - _find_git_index               (stdout = PATH, primary bug site)
     - _temp_index git add           (returncode only, stderr risk)
     - _git_toplevel                 (stdout = PATH, primary bug site)
     - _git_dir                      (stdout = PATH, primary bug site)
     - _git_rev_list_range           (stdout = SHAs, stderr risk)
     - _detect_main_branch           (stdout = ref, stderr risk)
     - merge-base --is-ancestor      (returncode only, stderr risk)

3. security_reminder_hook.py: convert 6 subprocess.run sites
   (rev-parse @{u}/@{u}@{1}/local_ref, merge-base, HEAD lookup,
   reflog SHA resolution) — same pattern.

4. security_reminder_hook.py: fix the misleading log line in
   handle_user_prompt_submit. Was:
     debug_log("Failed to capture git baseline (not a git repo?)")
   Now includes the cwd in the message so the next reporter doesn't
   waste an hour grepping for the real WinError, per reporter's
   secondary finding.

Verified locally on macOS Python 3.13:

  - py_compile clean on all modified files.
  - bash -n sg-python.sh clean.
  - sg-python.sh actually propagates PYTHONUTF8=1 to child Python
    (verified via probe — sys.flags.utf8_mode=1).
  - Existing 353 tests still pass — 0 regression.
  - 25 new tests in test_2099_subprocess_text_true.py:
      * 10 static-shape catchers (one per hooks/*.py file). Any
        future PR that reintroduces text=True OR encoding= in
        subprocess.run fails this check at PR time. Single source
        of truth for the regression class.
      * 2 sg-python.sh verifiers (literal export + actual
        propagation to child Python).
      * 5 macOS end-to-end against a real git repo containing
        non-cp1252 content (`ف.py` filename): _git_toplevel,
        _git_dir, _find_git_index, _git_rev_parse_head,
        _git_rev_list_range all return clean values without
        AttributeError / UnicodeDecodeError.
      * 7 round-trip bytes-decode pattern verifiers (parametrized
        over Arabic ف, Hebrew א, Japanese 案, raw 0x81, multiple
        cp1252-undefined bytes, real-world git diff headers).
      * 1 sanity check that cp1252 strict DOES raise on 0x81
        (proves the test environment can catch the bug class).

  - Full suite: 378/378 pass in 5.56s.

  - End-to-end tmux smoke test driving real claude 2.1.145 CLI:
    Made a git commit via Bash tool call. All 4 hooks fired through
    the fixed plugin path:
      11:28:16.730  Hook called with args: …/plugin/hooks/security_reminder_hook.py
      11:28:16.734  Processing: hook_event=UserPromptSubmit
      11:28:16.825  Captured git baseline: 445f7f213256
      11:28:19.923  Hook called with args: …
      11:28:19.923  Processing: hook_event=PostToolUse, tool=Bash
      11:28:19.971  Commit review: detected git commit in command
      11:28:20.020  Commit review: 1/1 sha(s) resolved, 1 files
      11:28:26.415  Hook called with args: …
      11:28:26.416  Processing: hook_event=Stop
      11:28:26.550  Stop hook: empty review set

    Confirms: PYTHONUTF8=1 export doesn't break anything; converted
    helpers (_git_rev_parse_head, _git_toplevel, _git_dir,
    _find_git_index) run end-to-end without issue on the happy path.

NOT verified end-to-end on Windows with actual non-cp1252 content
in path/filename/stderr. The static-shape catcher pins the
regression class permanently. Reporter's PYTHONUTF8=1 workaround
empirically proves the encoding-mode fix works for the affected
scenario; this commit just bakes it in.

Closes #2099.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
URGENT WINDOWS FIX. Sibling of #2056 / PR #2075 but covering 14 more
sites that PR #2075 missed.

The bug class: on Windows with cp1252 default encoding (typical
en-US locale), `subprocess.run(..., text=True)` decodes child stdout
AND stderr via `locale.getpreferredencoding()`. When git emits a
UTF-8 byte that's undefined in cp1252 (e.g. `0x81` from ف, present
in any path/filename/branch ref/commit message containing
Arabic/Hebrew/CJK), Python's internal `_readerthread` raises
UnicodeDecodeError. The thread crash is silent in Python 3.13+ (only
printed to stderr), but `subprocess.run` returns `stdout=None` and
the caller AttributeErrors on `.strip()`. The user sees a misleading
"WinError 267" or similar catch-all message instead of the real
decode failure.

PR #2075 fixed 6 specific helpers in `diffstate.py` / `gitutil.py`.
This commit covers the 14 survivors. Plus a defense-in-depth belt:
`PYTHONUTF8=1` exported by sg-python.sh.

This commit:

1. sg-python.sh: `export PYTHONUTF8=1` (PEP 540). No-op on
   macOS/Linux (already UTF-8). On Windows, makes Python's
   `locale.getpreferredencoding()` return UTF-8 instead of cp1252 —
   so even if a future regression slips in text=True, the decode
   succeeds. Must be set BEFORE Python starts; changing it from
   inside the interpreter has no effect.

2. gitutil.py: convert 8 subprocess.run sites from
   `capture_output=True, text=True` to `capture_output=True` +
   manual `r.stdout.decode("utf-8", errors="replace")`:
     - _git_rev_parse_head           (stdout = SHA, stderr risk)
     - _find_git_index               (stdout = PATH, primary bug site)
     - _temp_index git add           (returncode only, stderr risk)
     - _git_toplevel                 (stdout = PATH, primary bug site)
     - _git_dir                      (stdout = PATH, primary bug site)
     - _git_rev_list_range           (stdout = SHAs, stderr risk)
     - _detect_main_branch           (stdout = ref, stderr risk)
     - merge-base --is-ancestor      (returncode only, stderr risk)

3. security_reminder_hook.py: convert 6 subprocess.run sites
   (rev-parse @{u}/@{u}@{1}/local_ref, merge-base, HEAD lookup,
   reflog SHA resolution) — same pattern.

4. security_reminder_hook.py: fix the misleading log line in
   handle_user_prompt_submit. Was:
     debug_log("Failed to capture git baseline (not a git repo?)")
   Now includes the cwd in the message so the next reporter doesn't
   waste an hour grepping for the real WinError, per reporter's
   secondary finding.

Verified locally on macOS Python 3.13:

  - py_compile clean on all modified files.
  - bash -n sg-python.sh clean.
  - sg-python.sh actually propagates PYTHONUTF8=1 to child Python
    (verified via probe — sys.flags.utf8_mode=1).
  - Existing 353 tests still pass — 0 regression.
  - 25 new tests in test_2099_subprocess_text_true.py:
      * 10 static-shape catchers (one per hooks/*.py file). Any
        future PR that reintroduces text=True OR encoding= in
        subprocess.run fails this check at PR time. Single source
        of truth for the regression class.
      * 2 sg-python.sh verifiers (literal export + actual
        propagation to child Python).
      * 5 macOS end-to-end against a real git repo containing
        non-cp1252 content (`ف.py` filename): _git_toplevel,
        _git_dir, _find_git_index, _git_rev_parse_head,
        _git_rev_list_range all return clean values without
        AttributeError / UnicodeDecodeError.
      * 7 round-trip bytes-decode pattern verifiers (parametrized
        over Arabic ف, Hebrew א, Japanese 案, raw 0x81, multiple
        cp1252-undefined bytes, real-world git diff headers).
      * 1 sanity check that cp1252 strict DOES raise on 0x81
        (proves the test environment can catch the bug class).

  - Full suite: 378/378 pass in 5.56s.

  - End-to-end tmux smoke test driving real claude 2.1.145 CLI:
    Made a git commit via Bash tool call. All 4 hooks fired through
    the fixed plugin path:
      11:28:16.730  Hook called with args: …/plugin/hooks/security_reminder_hook.py
      11:28:16.734  Processing: hook_event=UserPromptSubmit
      11:28:16.825  Captured git baseline: 445f7f213256
      11:28:19.923  Hook called with args: …
      11:28:19.923  Processing: hook_event=PostToolUse, tool=Bash
      11:28:19.971  Commit review: detected git commit in command
      11:28:20.020  Commit review: 1/1 sha(s) resolved, 1 files
      11:28:26.415  Hook called with args: …
      11:28:26.416  Processing: hook_event=Stop
      11:28:26.550  Stop hook: empty review set

    Confirms: PYTHONUTF8=1 export doesn't break anything; converted
    helpers (_git_rev_parse_head, _git_toplevel, _git_dir,
    _find_git_index) run end-to-end without issue on the happy path.

NOT verified end-to-end on Windows with actual non-cp1252 content
in path/filename/stderr. The static-shape catcher pins the
regression class permanently. Reporter's PYTHONUTF8=1 workaround
empirically proves the encoding-mode fix works for the affected
scenario; this commit just bakes it in.

Closes #2099.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: enable LLM review on default macOS Python 3.9</title>
<updated>2026-05-29T05:58:01+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-05-29T05:46:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=a67587c81615b0cb92f17ea7dba2ff1b34a9050d'/>
<id>a67587c81615b0cb92f17ea7dba2ff1b34a9050d</id>
<content type='text'>
Fixes anthropics/claude-plugins-official#2071 — on macOS where the
default `python3` is Apple's Command Line Tools Python 3.9.6, the
plugin's agentic commit reviewer silently does not run, even when the
user has a newer Python installed.

Three compounding factors in the bug:

1. `sg-python.sh` only checks the major version (`3`), so it always
   picks 3.9 even when 3.10+ is on PATH.
2. `claude_agent_sdk` requires Python &gt;=3.10 — pip install on 3.9
   returns "No matching distribution" -&gt; bootstrap returns BUILD_FAILED.
3. Even with a hand-built 3.12 venv, `llm.py` imports the SDK
   in-process into the hook's interpreter (still 3.9), which raises
   SyntaxError. The existing venv-probe in `ensure_agent_sdk.py` uses
   the venv's own Python (3.12) so it reports NOOP_VENV (healthy) while
   the consumer fails — misleading telemetry on top of silent feature
   degradation.

Per BQ telemetry, 14,073 external macOS users hit
sdk_bootstrap=BUILD_FAILED in the past 4 days (the default-macOS
cohort), out of ~86K total external installed users. Combined with
~20K other users in similar broken-bootstrap states (Windows pre-#2055,
Linux &lt;3.10), about half the installed base has a silently-broken
agentic reviewer.

This PR implements the reporter's items #1, #3, and #4. Item #2
(running the SDK out-of-process) is deferred as a bigger refactor.

Item #1 — hooks/sg-python.sh — prefer &gt;=3.10 binaries via 3-pass probe:

  Pass 1: python3.13 / 3.12 / 3.11 / 3.10 (&gt;=3.10 by name, highest wins)
  Pass 2: bare python3 / python / py -3 (accept only if reported &gt;=3.10)
  Pass 3: bare python3 / python / py -3 (any Python 3, FALLBACK so
          pattern checks still work on macOS-default 3.9 — no regression
          vs today; SDK-dependent paths detect the version mismatch
          inside Python and degrade cleanly via item #4)

Item #4 — ensure_agent_sdk.py — health-check honesty:

Added HOOK_PY_INCOMPATIBLE=6 outcome with short-circuit at top of main():

  if sys.version_info &lt; (3, 10):
      return HOOK_PY_INCOMPATIBLE, "hook_py", f"py_{...}"

Telemetry consequences after rollout: sdk_bootstrap=6 is a new clean
bucket; some users currently miscounted in sdk_bootstrap=3 BUILD_FAILED
(wasted pip cycles) and sdk_bootstrap=1 NOOP_VENV (falsely-healthy)
move to sdk_bootstrap=6. The remaining NOOP_VENV count becomes
trustworthy.

Item #3 — ensure_agent_sdk.py — one-time user-visible notice:

When outcome == HOOK_PY_INCOMPATIBLE and a marker file at
`~/.claude/security/.agentic_unavailable_notice_v&lt;pv&gt;` doesn't exist,
the SessionStart response includes hookSpecificOutput.additionalContext
+ systemMessage explaining the situation. Marker file is plugin-
version-keyed so a future fix (e.g. shipping out-of-process SDK) can
bump pv and re-notify users.

BUILD_FAILED is intentionally excluded from the notice — it covers
transient causes where a permanent banner would mislead.

Verified locally on macOS Python 3.13:
  - py_compile clean on both files.
  - Existing 45-test smoke + extensibility suite: 45/45 PASS in 2.50s.
  - Unit test of simulated 3.9 path: HOOK_PY_INCOMPATIBLE returned with
    correct phase/kind; notice shown on first call, suppressed on
    second, reshown on bumped pv; BUILD_FAILED correctly does NOT
    trigger notice.

NOT verified: actual Python 3.9 behavior end-to-end (would need a 3.9
install). Worth a follow-up smoke test in a 3.9 venv before next
release. The unit test simulating 3.9 covers the logic but not the
runtime invocation through the shim.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes anthropics/claude-plugins-official#2071 — on macOS where the
default `python3` is Apple's Command Line Tools Python 3.9.6, the
plugin's agentic commit reviewer silently does not run, even when the
user has a newer Python installed.

Three compounding factors in the bug:

1. `sg-python.sh` only checks the major version (`3`), so it always
   picks 3.9 even when 3.10+ is on PATH.
2. `claude_agent_sdk` requires Python &gt;=3.10 — pip install on 3.9
   returns "No matching distribution" -&gt; bootstrap returns BUILD_FAILED.
3. Even with a hand-built 3.12 venv, `llm.py` imports the SDK
   in-process into the hook's interpreter (still 3.9), which raises
   SyntaxError. The existing venv-probe in `ensure_agent_sdk.py` uses
   the venv's own Python (3.12) so it reports NOOP_VENV (healthy) while
   the consumer fails — misleading telemetry on top of silent feature
   degradation.

Per BQ telemetry, 14,073 external macOS users hit
sdk_bootstrap=BUILD_FAILED in the past 4 days (the default-macOS
cohort), out of ~86K total external installed users. Combined with
~20K other users in similar broken-bootstrap states (Windows pre-#2055,
Linux &lt;3.10), about half the installed base has a silently-broken
agentic reviewer.

This PR implements the reporter's items #1, #3, and #4. Item #2
(running the SDK out-of-process) is deferred as a bigger refactor.

Item #1 — hooks/sg-python.sh — prefer &gt;=3.10 binaries via 3-pass probe:

  Pass 1: python3.13 / 3.12 / 3.11 / 3.10 (&gt;=3.10 by name, highest wins)
  Pass 2: bare python3 / python / py -3 (accept only if reported &gt;=3.10)
  Pass 3: bare python3 / python / py -3 (any Python 3, FALLBACK so
          pattern checks still work on macOS-default 3.9 — no regression
          vs today; SDK-dependent paths detect the version mismatch
          inside Python and degrade cleanly via item #4)

Item #4 — ensure_agent_sdk.py — health-check honesty:

Added HOOK_PY_INCOMPATIBLE=6 outcome with short-circuit at top of main():

  if sys.version_info &lt; (3, 10):
      return HOOK_PY_INCOMPATIBLE, "hook_py", f"py_{...}"

Telemetry consequences after rollout: sdk_bootstrap=6 is a new clean
bucket; some users currently miscounted in sdk_bootstrap=3 BUILD_FAILED
(wasted pip cycles) and sdk_bootstrap=1 NOOP_VENV (falsely-healthy)
move to sdk_bootstrap=6. The remaining NOOP_VENV count becomes
trustworthy.

Item #3 — ensure_agent_sdk.py — one-time user-visible notice:

When outcome == HOOK_PY_INCOMPATIBLE and a marker file at
`~/.claude/security/.agentic_unavailable_notice_v&lt;pv&gt;` doesn't exist,
the SessionStart response includes hookSpecificOutput.additionalContext
+ systemMessage explaining the situation. Marker file is plugin-
version-keyed so a future fix (e.g. shipping out-of-process SDK) can
bump pv and re-notify users.

BUILD_FAILED is intentionally excluded from the notice — it covers
transient causes where a permanent banner would mislead.

Verified locally on macOS Python 3.13:
  - py_compile clean on both files.
  - Existing 45-test smoke + extensibility suite: 45/45 PASS in 2.50s.
  - Unit test of simulated 3.9 path: HOOK_PY_INCOMPATIBLE returned with
    correct phase/kind; notice shown on first call, suppressed on
    second, reshown on bumped pv; BUILD_FAILED correctly does NOT
    trigger notice.

NOT verified: actual Python 3.9 behavior end-to-end (would need a 3.9
install). Worth a follow-up smoke test in a 3.9 venv before next
release. The unit test simulating 3.9 covers the logic but not the
runtime invocation through the shim.

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
