bash-tool-path
БесплатноБез исполняемых скриптовНе проверенSafely add a directory to Claude Code's Bash tool PATH. Use when a binary runs in your terminal but is "command not found" inside Claude Code's Bash tool…
от drn★ 23 звезды на GitHubОб этом скилле
Context
- Worked example hook: ~/.dots/agents/hooks/session-start-path.sh
- Existing SessionStart hooks (user): !
grep -n SessionStart ~/.claude/settings.json 2>/dev/null | head -10 - env.PATH in user settings (a footgun if present): !
grep -n '"PATH"' ~/.claude/settings.json 2>/dev/null | head -5
When to use this skill
Use this when a command that works in an interactive terminal fails with "command not found" inside Claude Code's Bash tool, or when the user wants to add a directory (a go/bin, cargo, asdf shim, or custom tool dir) to the PATH that Claude Code's Bash tool sees.
Why the obvious fixes do not work
Three footguns make this harder than it looks. State them plainly so nobody re-discovers them by hand.
settings.json
envvalues are set literally. Claude Code does not expand$VARor${VAR}in them. So"PATH": "${PATH}:/x/bin"sets PATH to that literal, broken string, not to the inherited PATH plus a directory.env.PATHreplaces the inherited PATH wholesale. It cannot append, and replacing it drops the directories Claude Code already needs (for example plugin bin dirs). Soenv.PATHis the wrong tool for adding a dir.The Bash tool sources
~/.zshrc(or~/.bashrc/~/.profile) at session start only to capture aliases, functions, and shell options. PATHexportlines in~/.zshrcor~/.zshenvare not captured. Claude Code builds the Bash tool PATH from the process that launched it (often a daemon), not from your interactive shell, so daemon-launched sessions can lack go/bin and similar dirs even though they resolve fine in your terminal.
The supported fix: a SessionStart hook that writes to CLAUDE_ENV_FILE
Claude Code sources the file named by $CLAUDE_ENV_FILE before every Bash
command. Because the file is sourced, $PATH expands at source time, so you
can prepend a directory and preserve the inherited PATH. Populate that file
from a SessionStart hook. $CLAUDE_ENV_FILE is available to the
SessionStart, Setup, CwdChanged, and FileChanged hooks.
A static alternative exists — point CLAUDE_ENV_FILE at a fixed shell script
before launching Claude Code — but the SessionStart hook is the portable,
dynamic choice and is what this repo ships.
Steps
Write (or extend) a SessionStart hook script that appends an
exportline per directory to$CLAUDE_ENV_FILE. Read the worked, tested reference first:~/.dots/agents/hooks/session-start-path.sh. It is idempotent, guards that each directory exists, and prepends rather than clobbers. Mirror its shape rather than writing a new pattern from scratch. The core line is:export PATH="/your/dir:$PATH"Keep
$PATHliteral (escaped or single-quoted in the heredoc/printf) so it expands when the env file is sourced, not when the hook runs.Make the hook a no-op when
$CLAUDE_ENV_FILEis unset, and append each export only if the file does not already contain it (the file persists across repeated SessionStart fires within a session).Register the hook in settings.json under
hooks.SessionStart, invoked viabash. In this repo, registration is handled bydots install agents; for a standalone setup, add the SessionStart entry to~/.claude/settings.json. Use the/update-configskill for the settings.json edit mechanics.Verify in a fresh session: run the bare command name in the Bash tool and confirm it resolves.
What NOT to do
- Do not set
env.PATHin settings.json to add a directory (it replaces, and is not variable-expanded — see footguns 1 and 2). - Do not add the PATH export only to
~/.zshrc/~/.zshenvand expect the Bash tool to pick it up (footgun 3).
References
- Bash tool behavior (what gets sourced at session start): https://code.claude.com/docs/en/tools
- Persisting environment variables across Bash commands via CLAUDE_ENV_FILE and SessionStart hooks: https://code.claude.com/docs/en/hooks
- Worked reference implementation in this repo: ~/.dots/agents/hooks/session-start-path.sh
Установить bash-tool-path в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл bash-tool-path?
Safely add a directory to Claude Code's Bash tool PATH. Use when a binary runs in your terminal but is "command not found" inside Claude Code's Bash tool, when adding a directory to PATH for Claude Code, when configuring CLAUDE_ENV_FILE, or when settings.json env.PATH did not work. Explains why env.PATH replaces rather than appends PATH and is not variable-expanded, why ~/.zshrc PATH exports are dropped, and the supported SessionStart hook fix.
Как установить скилл bash-tool-path?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bash-tool-path запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic