<feed xmlns='http://www.w3.org/2005/Atom'>
<title>claude-plugins-official.git/plugins/security-guidance/hooks/sg-python.sh, branch main</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: say which Python failed when none works</title>
<updated>2026-11-23T21:11:46+00:00</updated>
<author>
<name>Claude</name>
<email>noreply@anthropic.com</email>
</author>
<published>2026-11-23T21:11:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=10b5aa1b457a22481f377db18b131b16e228abb4'/>
<id>10b5aa1b457a22481f377db18b131b16e228abb4</id>
<content type='text'>
When every interpreter the launcher tried failed, its message was the same
as with no Python at all, so a version manager's shim with no version set
read as Python not being installed.

The first line now names python3, python and py -3 with what they did,
because Claude Code's terminal shows only the first line of a failed hook.
A later line has all of them. The interpreters' own output is not
repeated. Nothing changes in which interpreter is started, in the exit
code or in the number of processes.

See anthropics/claude-code#86709.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When every interpreter the launcher tried failed, its message was the same
as with no Python at all, so a version manager's shim with no version set
read as Python not being installed.

The first line now names python3, python and py -3 with what they did,
because Claude Code's terminal shows only the first line of a failed hook.
A later line has all of them. The interpreters' own output is not
repeated. Nothing changes in which interpreter is started, in the exit
code or in the number of processes.

See anthropics/claude-code#86709.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: keep the interpreter check working through a .bat shim</title>
<updated>2026-11-19T19:34:17+00:00</updated>
<author>
<name>Claude</name>
<email>noreply@anthropic.com</email>
</author>
<published>2026-11-19T19:33:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=4fa3475d3a7f58ffe75930c6aa8ae56e80496447'/>
<id>4fa3475d3a7f58ffe75930c6aa8ae56e80496447</id>
<content type='text'>
pyenv-win's python names end in a batch file. In its released version
(3.1.1) cmd.exe read the "&gt;=" in the check as a redirect: every hook left
an empty "(3" file in the project, and the interpreter was rejected. With
no other Python no hook ran.

The check now uses only characters that arrive unchanged. On Windows a
name that loses the argument counts as unable to read the hook script, so
the launcher goes on to its real interpreter.

See #7172.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
pyenv-win's python names end in a batch file. In its released version
(3.1.1) cmd.exe read the "&gt;=" in the check as a redirect: every hook left
an empty "(3" file in the project, and the interpreter was rejected. With
no other Python no hook ran.

The check now uses only characters that arrive unchanged. On Windows a
name that loses the argument counts as unable to read the hook script, so
the launcher goes on to its real interpreter.

See #7172.

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: edit hook no longer waits on App Installer's python alias</title>
<updated>2026-11-13T00:02:54+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-11-13T00:02:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=c7b7669ca7813f139450726852e1183ba3309606'/>
<id>c7b7669ca7813f139450726852e1183ba3309606</id>
<content type='text'>
On Windows without a packaged Python, python3 under WindowsApps is App
Installer's alias, which is not a Python. The launcher started it on every
hook. Starting it waits for Windows' package services, so while those are
stuck every hook in every session waits with them, and the edit hook had no
time limit of its own: each Edit or Write then took 600 seconds.

- The launcher tells that alias by where its link leads and does not start
  it. Which interpreter runs the hook is unchanged. Aliases of a packaged
  Python are still probed.
- The edit hook gets a 60 second limit.

Refs #6348, #3870, #6315

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Windows without a packaged Python, python3 under WindowsApps is App
Installer's alias, which is not a Python. The launcher started it on every
hook. Starting it waits for Windows' package services, so while those are
stuck every hook in every session waits with them, and the edit hook had no
time limit of its own: each Edit or Write then took 600 seconds.

- The launcher tells that alias by where its link leads and does not start
  it. Which interpreter runs the hook is unchanged. Aliases of a packaged
  Python are still probed.
- The edit hook gets a 60 second limit.

Refs #6348, #3870, #6315

Co-authored-by: mhegazy &lt;mhegazy@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<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>
</feed>
