Right-click "Claude AI": Launch Claude Code from Any Folder in One Click

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):

ComponentVersion
Windows10 Pro 19045 (Windows 11 also works, see the end of this article)
Windows Terminal1.26.2734.0 portable (the Store version works too)
Git for Windowsbash 5.3.15 (UCRT64 runtime)
Claude Code2.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:

  1. 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-*)
  2. Git for Windows is installed (C:\Program Files\Git\bin\bash.exe)
  3. 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) Uninstall
powershell -NoProfile -ExecutionPolicy Bypass -File <this directory>\scripts\install-claude-menu.ps1 -Remove

Parameters

ParameterDescription
-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
-NoProfileDon’t pass -p at all (the tab uses the default profile’s look)
-PrintOnly print the detection results and command; don’t write the registry
-RemoveDelete 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).

To manually trust a directory:

1
node "%USERPROFILE%\.claude\bin\trust-workspace.cjs" "D:\some\project"

Permission mode (auto / bypass)

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.sh
CLAUDE_ARGS="--dangerously-skip-permissions"

(In the shared script, CLAUDE_ARGS defaults to empty, i.e. it inherits the global default; enable it as needed.)

To bypass globally, edit ~/.claude/settings.json:

1
"permissions": { "defaultMode": "bypassPermissions" }

Notes:

  • 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)

  1. 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.
  2. 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.
  3. 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).
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. Concurrent writes to ~/.claude.json: Claude sessions also write this file, and overwriting directly may lose settings; use an mtime check + atomic replace.
  9. 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.
  10. 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:

1
explorer.exe → WindowsTerminal.exe → bash.exe (C:\Program Files\Git\bin\bash.exe -l ...)

B. Confirm the trust dialog is skipped

Claude Code supports --debug-file:

1
claude --debug-file C:\temp\dbg.log
  • When untrusted, the log contains: hooks modules not loaded until workspace trust is accepted
  • After pre-writing the trust record, that line disappears and the log is noticeably longer (MCP, memory, and file watching initialize normally)

C. Confirm the permission mode

Check whether the session UI shows “auto mode on”; or check whether the claude process command line contains --dangerously-skip-permissions.

7. Manual registry entries (reference when not using the scripts)

1
2
3
4
5
HKCU\Software\Classes\Directory\shell\ClaudeAI
    (Default) = Claude AI
    Icon      = C:\Program Files\Git\ucrt64\share\git\git-for-windows.ico
HKCU\Software\Classes\Directory\shell\ClaudeAI\command
    (Default) = "<full path to wt.exe>" -p "Git Bash" -d "%V" "C:\Program Files\Git\bin\bash.exe" -l "/c/Users/<you>/.claude/bin/claude-here.sh"

Directory\Background\shell\ClaudeAI has identical content (covering “right-click on empty space”).

Note: the launcher path in the registry command must be in MSYS style (/c/Users/...), while wt.exe and bash.exe use Windows-style paths.

8. Notes for Windows 11

  • Windows 11’s new context menu shows only a trimmed list by default: press Shift+F10 or click “Show more options” to see this menu.
  • Putting the entry into the Win11 new menu requires implementing an IExplorerCommand COM extension, which is beyond the scope of this article.

Appendix: Full scripts

Below are the complete contents of the three scripts under scripts/, ready to save and use.

scripts/install-claude-menu.ps1

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<#
.SYNOPSIS
  Adds an Explorer context-menu entry "Claude AI" that opens Claude Code in
  Windows Terminal, using Git Bash, for the folder you right-clicked.

.DESCRIPTION
  Registers two per-user keys (no admin rights needed):

    HKCU\Software\Classes\Directory\shell\ClaudeAI            (right-click a folder)
    HKCU\Software\Classes\Directory\Background\shell\ClaudeAI  (right-click empty space)

  The menu runs:

    wt.exe [-p <profile>] -d "%V" "bash.exe" -l "<launcher>"

  claude-here.sh pre-trusts the folder, starts claude, and drops to an
  interactive Git Bash when claude exits.

.PARAMETER WtPath
  Full path to wt.exe. Auto-detected when omitted.

.PARAMETER BashPath
  Full path to bash.exe (Git for Windows). Default: %ProgramFiles%\Git\bin\bash.exe

.PARAMETER LauncherPath
  Full path to claude-here.sh.
  Default: %USERPROFILE%\.claude\bin\claude-here.sh
  If it does not exist and claude-here.sh sits next to this script, the
  launcher and trust-workspace.cjs are copied there automatically.

.PARAMETER ProfileName
  Windows Terminal profile used for the tab's icon and appearance.
  Default: "Git Bash". Falls back to no -p if that profile is not found.

.PARAMETER NoProfile
  Do not pass -p to wt.exe at all.

.PARAMETER Print
  Show the detected paths and the final command without touching the registry.

.PARAMETER Remove
  Remove the menu entries.

.EXAMPLE
  powershell -NoProfile -ExecutionPolicy Bypass -File install-claude-menu.ps1 -Print

.EXAMPLE
  powershell -NoProfile -ExecutionPolicy Bypass -File install-claude-menu.ps1

.EXAMPLE
  powershell -NoProfile -ExecutionPolicy Bypass -File install-claude-menu.ps1 -Remove
#>
param(
    [string]$WtPath,
    [string]$BashPath,
    [string]$LauncherPath,
    [string]$ProfileName = 'Git Bash',
    [switch]$NoProfile,
    [switch]$Print,
    [switch]$Remove
)

$ErrorActionPreference = 'Stop'
$menuName = 'Claude AI'
$keys = @(
    'HKCU:\Software\Classes\Directory\shell\ClaudeAI',
    'HKCU:\Software\Classes\Directory\Background\shell\ClaudeAI'
)

if ($Remove) {
    foreach ($k in $keys) {
        if (Test-Path $k) { Remove-Item -Path $k -Recurse -Force }
        Write-Host "removed: $k"
    }
    exit 0
}

function Find-Exe {
    param([string]$Explicit, [string[]]$Candidates, [string]$What)
    if ($Explicit) {
        if (-not (Test-Path $Explicit)) { throw "$What not found: $Explicit" }
        return (Resolve-Path $Explicit).Path
    }
    foreach ($c in $Candidates) {
        if ($c -and (Test-Path $c)) { return (Resolve-Path $c).Path }
    }
    throw "$What not found. Pass the full path explicitly."
}

# --- wt.exe ---------------------------------------------------------------
$wtCandidates = @()
$wtCmd = Get-Command wt.exe -ErrorAction SilentlyContinue
if ($wtCmd) { $wtCandidates += $wtCmd.Source }
$wtCandidates += (Join-Path $env:LOCALAPPDATA 'Microsoft\WindowsApps\wt.exe')
$wtCandidates += (Join-Path $env:ProgramFiles 'WindowsTerminal\wt.exe')
$portable = Get-ChildItem -Path 'C:\' -Filter 'wt.exe' -Depth 1 -ErrorAction SilentlyContinue |
    Where-Object { $_.DirectoryName -like 'C:\terminal-*' } |
    Sort-Object LastWriteTime -Descending |
    Select-Object -First 1
if ($portable) { $wtCandidates += $portable.FullName }
$wt = Find-Exe -Explicit $WtPath -Candidates $wtCandidates -What 'wt.exe'

# --- bash.exe -------------------------------------------------------------
$bashCandidates = @(
    (Join-Path $env:ProgramFiles 'Git\bin\bash.exe'),
    (Join-Path ${env:ProgramFiles(x86)} 'Git\bin\bash.exe')
)
$bash = Find-Exe -Explicit $BashPath -Candidates $bashCandidates -What 'bash.exe (Git for Windows)'

# --- launcher -------------------------------------------------------------
$targetDir = Join-Path $env:USERPROFILE '.claude\bin'
if (-not $LauncherPath) { $LauncherPath = Join-Path $targetDir 'claude-here.sh' }
if (-not (Test-Path $LauncherPath)) {
    foreach ($f in 'claude-here.sh', 'trust-workspace.cjs') {
        $src = Join-Path $PSScriptRoot $f
        if (Test-Path $src) {
            New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
            Copy-Item $src (Join-Path $targetDir $f) -Force
            Write-Host "copied: $src -> $targetDir"
        }
    }
}
if (-not (Test-Path $LauncherPath)) {
    throw "launcher not found: $LauncherPath (copy claude-here.sh and trust-workspace.cjs there first)"
}
$trustScript = Join-Path (Split-Path $LauncherPath) 'trust-workspace.cjs'
if (-not (Test-Path $trustScript)) {
    Write-Warning "trust-workspace.cjs not found next to the launcher; the trust pre-seed will be skipped."
}

# Windows path -> MSYS path (C:\a\b -> /c/a/b) for the Git Bash argument.
function ConvertTo-MsysPath {
    param([string]$Path)
    $p = (Resolve-Path $Path).Path.Replace('\', '/')
    if ($p -match '^([A-Za-z]):(.*)$') { return '/' + $Matches[1].ToLower() + $Matches[2] }
    return $p
}
$launcherMsys = ConvertTo-MsysPath $LauncherPath

# --- verify the WT profile exists ----------------------------------------
function Test-TerminalProfile {
    param([string]$Name)
    $settings = Join-Path $env:LOCALAPPDATA 'Microsoft\Windows Terminal\settings.json'
    if (-not (Test-Path $settings)) { return $true }   # cannot verify: keep it
    try {
        $st = Get-Content $settings -Raw -ErrorAction Stop | ConvertFrom-Json
        $list = @()
        if ($st.profiles -and $st.profiles.list) { $list = @($st.profiles.list) }
        elseif ($st.profiles -is [array]) { $list = @($st.profiles) }
        foreach ($p in $list) {
            if ($p.name -eq $Name -or $p.guid -eq $Name) { return $true }
        }
    } catch { return $true }
    return $false
}

$profileArg = ''
if (-not $NoProfile -and $ProfileName) {
    if (Test-TerminalProfile $ProfileName) {
        $profileArg = " -p `"$ProfileName`""
    } else {
        Write-Warning "Windows Terminal profile '$ProfileName' not found; the tab will use the default profile's look. Pass -ProfileName <name>, or -NoProfile to silence this."
    }
}

$command = "`"$wt`"$profileArg -d `"%V`" `"$bash`" -l `"$launcherMsys`""

$icon = $wt
$gitIcon = Join-Path $env:ProgramFiles 'Git\ucrt64\share\git\git-for-windows.ico'
if (Test-Path $gitIcon) { $icon = $gitIcon }

if ($Print) {
    Write-Host "wt.exe   : $wt"
    Write-Host "bash.exe : $bash"
    Write-Host "launcher : $LauncherPath"
    Write-Host "profile  : $(if ($profileArg) { $ProfileName } else { '(default look)' })"
    Write-Host "icon     : $icon"
    Write-Host "command  : $command"
    exit 0
}

foreach ($k in $keys) {
    New-Item -Path $k -Force | Out-Null
    New-ItemProperty -Path $k -Name '(Default)' -Value $menuName -PropertyType String -Force | Out-Null
    New-ItemProperty -Path $k -Name 'Icon' -Value $icon -PropertyType String -Force | Out-Null
    New-Item -Path "$k\command" -Force | Out-Null
    New-ItemProperty -Path "$k\command" -Name '(Default)' -Value $command -PropertyType String -Force | Out-Null
    Write-Host "registered: $k"
}
Write-Host ""
Write-Host "command: $command"
Write-Host ""
Write-Host "Right-click a folder (or empty space inside one) and pick '$menuName'."

scripts/claude-here.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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=1
CLAUDE_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 || true
fi

claude $CLAUDE_ARGS
echo
echo "[Claude exited] This is now a login Git Bash shell."
exec bash --login -i

scripts/trust-workspace.cjs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env node
// ---------------------------------------------------------------------------
// Pre-accept the Claude Code workspace trust dialog for one directory.
//
// Usage: node trust-workspace.cjs <dir>
//
// Writes projects[<canonical dir>].hasTrustDialogAccepted = true into the
// global config (~/.claude.json, or $CLAUDE_CONFIG_DIR/.claude.json).
// This is exactly the record Claude Code's own "Yes, I trust this folder"
// answer writes, so the trust dialog is skipped on the next launch.
//
// Files are written with an mtime check + rename so a Claude session that
// happens to write the same config concurrently is not silently clobbered.
// ---------------------------------------------------------------------------
'use strict';
const fs = require('fs');
const path = require('path');

function canonical(p) {
  let out = p;
  try { out = fs.realpathSync.native(p); } catch (e) {
    try { out = fs.realpathSync(p); } catch (e2) { out = path.resolve(p); }
  }
  out = out.replace(/\\/g, '/');
  if (out.length > 1) out = out.replace(/\/+$/, '');
  return out;
}

const dir = process.argv[2];
if (!dir) process.exit(0);

const configDir = process.env.CLAUDE_CONFIG_DIR;
const configPath = configDir
  ? path.join(configDir, '.claude.json')
  : path.join(process.env.USERPROFILE || process.env.HOME || '', '.claude.json');
const key = canonical(dir);

for (let attempt = 0; attempt < 5; attempt++) {
  let raw, statBefore;
  try {
    statBefore = fs.statSync(configPath);
    raw = fs.readFileSync(configPath, 'utf8');
  } catch (e) { process.exit(0); }

  let cfg;
  try { cfg = JSON.parse(raw); } catch (e) { process.exit(0); }

  if (!cfg.projects || typeof cfg.projects !== 'object') cfg.projects = {};
  const entry = (cfg.projects[key] && typeof cfg.projects[key] === 'object')
    ? cfg.projects[key] : {};
  if (entry.hasTrustDialogAccepted === true) process.exit(0);
  cfg.projects[key] = Object.assign({}, entry, { hasTrustDialogAccepted: true });

  const tmp = configPath + '.trusttmp.' + process.pid;
  try {
    fs.writeFileSync(tmp, JSON.stringify(cfg, null, 2) + '\n', 'utf8');
    const statAfter = fs.statSync(configPath);
    if (statAfter.mtimeMs !== statBefore.mtimeMs) { fs.unlinkSync(tmp); continue; }
    fs.renameSync(tmp, configPath);
    process.exit(0);
  } catch (e) {
    try { fs.unlinkSync(tmp); } catch (e2) { /* ignore */ }
    continue;
  }
}
process.exit(0);

9. References

CC BY-NC-ND 4.0