Right-click "Claude AI": Launch Claude Code from Any Folder in One Click
15 mins read
3078 words
Right-click any folder in File Explorer → Claude AI → Windows Terminal (Git Bash) opens automatically, enters that directory, auto-accepts the workspace trust check, and starts Claude Code. When Claude exits, the window stays open as a Git Bash shell.
Tested environment (2026-11):
Component
Version
Windows
10 Pro 19045 (Windows 11 also works, see the end of this article)
Windows Terminal
1.26.2734.0 portable (the Store version works too)
Git for Windows
bash 5.3.15 (UCRT64 runtime)
Claude Code
2.1.332 (installed via npm)
1. How it works
1
2
3
4
5
6
7
8
9
10
Right-click in Explorer
│ registry verb HKCU\Software\Classes\Directory\shell\ClaudeAI
▼
wt.exe -p "Git Bash" -d "<right-clicked directory>" "bash.exe" -l "<launcher>"
│
▼
Git Bash (claude-here.sh)
├─ ① write projects[<directory>].hasTrustDialogAccepted into ~/.claude.json (skip the trust dialog)
├─ ② run claude
└─ ③ after claude exits, exec bash --login -i (window stays open)
Key points:
Only HKCU (current user) is written — no admin rights needed and it can be removed at any time.
Two keys cover “right-click a folder icon” and “right-click empty space inside a folder” respectively.
%V is replaced by Explorer with the target directory, and it works in both places (verified on Windows 10).
The logic (multiple steps) lives in the launcher script so the registry command stays simple, sidestepping Windows Terminal’s ; command separator.
2. Files
1
2
3
4
5
6
<this directory>\
├─ README.md
└─ scripts\
├─ install-claude-menu.ps1 install/uninstall the context menu (auto-detects wt.exe / bash.exe)
├─ claude-here.sh launcher: pre-trust the directory → claude → keep Git Bash
└─ trust-workspace.cjs pre-write the workspace trust record (equivalent to clicking "Yes, I trust this folder")
(<this directory> means the directory this file lives in, e.g. C:\Users\A\claude-portable\ai-start-right-click.)
After installation, claude-here.sh and trust-workspace.cjs should be in the same directory (default: %USERPROFILE%\.claude\bin\); the launcher looks for trust-workspace.cjs relative to its own location. The full contents of the three scripts are in the appendix at the end.
3. Installation
Prerequisites:
Windows Terminal is installed (either the Store or portable version; it’s fine if the portable version’s wt.exe is not on PATH — the install script looks for it under C:\terminal-*)
Git for Windows is installed (C:\Program Files\Git\bin\bash.exe)
claude is available on PATH (you can run claude directly in Git Bash)
Steps:
1
2
3
4
5
6
7
8
# 1) Dry run first — confirm the detected paths and final command are correct (no registry writes)powershell -NoProfile -ExecutionPolicy Bypass -File <this directory>\scripts\install-claude-menu.ps1 -Print
# 2) Install for real (copies claude-here.sh / trust-workspace.cjs to %USERPROFILE%\.claude\bin\)powershell -NoProfile -ExecutionPolicy Bypass -File <this directory>\scripts\install-claude-menu.ps1
# 3) Uninstallpowershell -NoProfile -ExecutionPolicy Bypass -File <this directory>\scripts\install-claude-menu.ps1 -Remove
Parameters
Parameter
Description
-WtPath <path>
Specify wt.exe. When omitted, it tries PATH, %LOCALAPPDATA%\Microsoft\WindowsApps, %ProgramFiles%\WindowsTerminal, then C:\terminal-*\wt.exe in order
-BashPath <path>
Specify Git for Windows’ bash.exe
-LauncherPath <path>
Launcher location, defaults to %USERPROFILE%\.claude\bin\claude-here.sh
-ProfileName "Git Bash"
Which Windows Terminal profile’s look (icon/colors) to use. Falls back to the default look with a warning if it doesn’t exist
-NoProfile
Don’t pass -p at all (the tab uses the default profile’s look)
-Print
Only print the detection results and command; don’t write the registry
-Remove
Delete both menu keys
Disabling auto-trust
Edit claude-here.sh and change TRUST_ON_OPEN=1 at the top to 0.
After that, opening a new directory still shows one trust confirmation each time (this is Claude Code’s default behavior).
Newer Claude Code versions (e.g. 2.1.332) may default to auto permission mode (the classifier auto-approves/blocks), and the session UI shows “auto mode on”. If the launcher runs a bare claude, the session inherits that default.
To make only sessions opened via right-click bypass all permission prompts:
1
2
# at the top of claude-here.shCLAUDE_ARGS="--dangerously-skip-permissions"
(In the shared script, CLAUDE_ARGS defaults to empty, i.e. it inherits the global default; enable it as needed.)
It must be under permissions; valid values are acceptEdits / auto / bypassPermissions / manual (or its alias default) / dontAsk / plan.
Writing "defaultMode": "bypass" at the top level does nothing (wrong level and wrong value) and is silently ignored, so it falls back to the default auto mode — this is the most common reason for “why isn’t it bypass?”.
--dangerously-skip-permissions usually requires a one-time disclaimer confirmation; setting "skipDangerousModePermissionPrompt": true skips that confirmation.
4. Why pre-write the trust record
Every time Claude Code starts in an untrusted directory, it asks: “Is this a project you created or one you trust?” (the default option is No, exit).
Trust state is recorded by canonical path in ~/.claude.json at projects[<path>].hasTrustDialogAccepted (forward slashes, no trailing slash, real case);
Trust for the home directory is not saved when you click “Yes” in the UI, so launching from the home directory asks every time; yet pre-writing this record still works (verified by this solution);
Claude Code 2.1.332 has no official “global default trust” switch: neither --dangerously-skip-permissions nor the bypassPermissions mode skips this dialog; CLAUDE_CODE_SANDBOXED does cause auto-trust, but it’s an internal variable that changes many other behaviors and is not recommended;
So this solution writes the exact same record as clicking “Yes” before launching. This is the approach given in Claude Code’s own error message (“set projects[].hasTrustDialogAccepted: true in ”).
Write details: read → modify → write a temp file → verify ~/.claude.json’s mtime hasn’t changed → atomic rename; if the mtime changed, retry up to 5 times, so a running Claude session isn’t silently clobbered.
Please note: auto-trust means the .claude settings, hooks, and MCP servers in that directory are loaded at startup. Only use it on your own/trusted directories; you can disable it at any time with TRUST_ON_OPEN=0.
5. Pitfalls we hit (worth learning from)
Don’t relay through cmd.exe. In Git Bash, cmd //c "..." adds backslashes to quotes and mangles the arguments. Call wt.exe / bash.exe directly to avoid multiple layers of quoting.
In Git Bash, reg add’s /d and /ve get rewritten by MSYS path conversion (/d → D:\), reporting “invalid syntax”. Write the registry with PowerShell (New-ItemProperty), or add MSYS_NO_PATHCONV=1 to the reg arguments.
PowerShell 5.1 reads BOM-less UTF-8 Chinese comments as mojibake, which may fail to parse at all. Keep .ps1 files pure ASCII (or use a UTF-8 BOM).
Windows Terminal treats ; in the command line as a tab/pane separator, so a construct like claude; exec bash must go in a script file, not in the wt arguments.
Without -p <profile>, WT runs your command with defaultProfile’s look (often Windows PowerShell), so the icon/colors resemble cmd and are easy to misjudge; passing -p "Git Bash" matches the profile’s icon. Note this is only the look — the process itself is always Git Bash.
The portable Windows Terminal’s wt.exe is not on PATH (the Store version has a WindowsApps alias), so an absolute path is required; the install script auto-detects C:\terminal-*\wt.exe.
Home directory trust is not persistent (see section 4); clicking Yes via the UI for C:\Users\<you> is only valid for the current session.
Concurrent writes to ~/.claude.json: Claude sessions also write this file, and overwriting directly may lose settings; use an mtime check + atomic replace.
When the profile given to -p doesn’t exist, WT errors out/falls back and the menu may fail to open the terminal. The install script reads %LOCALAPPDATA%\Microsoft\Windows Terminal\settings.json to check whether the profile exists, and omits -p automatically if it doesn’t.
Edge case: when the directory path contains ;, the -d argument may get split by WT (rare; if it happens, use cd inside the script instead).
6. How to verify
A. Confirm you’re really in Git Bash (not cmd)
Check the tab prompt or $BASH_VERSION; the process chain measured by this solution:
#!/usr/bin/env bash
# ---------------------------------------------------------------------------# Launcher used by the "Claude AI" Explorer context-menu entry.## Runs Claude Code in the current directory, then drops to an interactive# login Git Bash so the window does not close when Claude exits.## Copy this file next to trust-workspace.cjs (default location:# %USERPROFILE%\.claude\bin\).## TRUST_ON_OPEN=0 -> do not auto-accept the workspace trust dialog.# CLAUDE_ARGS -> extra flags for claude. Newer Claude Code versions# default to "auto" permission mode; put# "--dangerously-skip-permissions" here to bypass all# permission prompts instead (opt-in, review the risk).# ---------------------------------------------------------------------------TRUST_ON_OPEN=1CLAUDE_ARGS=""SCRIPT_DIR="$(cd"$(dirname "${BASH_SOURCE[0]}")"&&pwd)"if["$TRUST_ON_OPEN"="1"]&&command -v node >/dev/null 2>&1; then node "$SCRIPT_DIR/trust-workspace.cjs""$PWD" >/dev/null 2>&1||trueficlaude $CLAUDE_ARGSechoecho"[Claude exited] This is now a login Git Bash shell."exec bash --login -i