[FEATURE] Trusted workspace patterns to skip trust prompt for git worktrees
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Note: This was previously reported in #993 and #21283, both auto-closed without resolution. A comment on #993 suggestedadditionalDirectoriesas a workaround — I've tested this and confirmed it does not skip the workspace trust prompt (tested with absolute paths,~expansion, and wildcard patterns).
Problem Statement
When using git worktrees, every new worktree creates a new directory that Claude Code has never seen before. This triggers the workspace trust prompt ("Quick safety check: Is this a project you created or one you trust?") every single time.
For developers who use worktrees heavily (one worktree per feature branch), this becomes repetitive friction. The parent repository is already trusted, and all worktrees are derived from it — there's no security benefit in re-prompting for each one.
Proposed Solution
Add a trustedWorkspacePatterns (or similar) setting in ~/.claude/settings.json that accepts glob patterns for directories that should be automatically trusted:
{
"trustedWorkspacePatterns": [
"~/worktrees/my-project/*",
"~/repos/**"
]
}
When Claude Code launches in a directory matching any of these patterns, the trust prompt would be skipped.
Alternative Solutions
additionalDirectories: Tested all of the following in global~/.claude/settings.json— none skip the trust prompt:- Absolute path:
/Users/me/worktrees/my-project - Tilde path:
~/worktrees/my-project - Absolute with wildcard:
/Users/me/worktrees/my-project/* - Tilde with wildcard:
~/worktrees/my-project/*
This setting only controls file access scope from within an already-trusted session — it does not affect the initial workspace trust prompt.
--dangerously-skip-permissions: Disables all permission checks, not just the trust prompt. Overkill for this use case.-pflag: Skips trust but only works in non-interactive mode.- Manually confirming each time: Current workaround, but adds unnecessary friction on every new worktree.
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
- Developer works on a monorepo at
~/repos/my-project/ - They create worktrees via
git worktree add ~/worktrees/my-project/feature-xyz feature-xyz - They run
claudein the new worktree directory - Currently: trust prompt appears every time for each new worktree
- With this feature: directories under
~/worktrees/my-project/*would be auto-trusted via a glob pattern
Additional Context
- #993 — Original request for this feature, auto-closed after 60 days of inactivity
- #21283 — Related report about trust prompt not persisting, closed as duplicate
- The
additionalDirectoriessuggestion from #993 has been independently verified as not solving this problem across multiple path formats
Showing cached comments. Read the full discussion on GitHub ↗
11 Comments
Upvoting, this would be a great feature.
though minor, this is a very real point of friction for any serious worktree-heavy workflows. big +1!
Workaround: Parent directory trust cascading
The trust state is stored in
~/.claude.jsonunder theprojectskey per directory path. Crucially, Claude Code walks parent directories when checking trust — so if a parent is trusted, all subdirectories inherit that trust.One-liner fix — add your home directory (or any common root) as trusted:
This works for the home directory bug (#18942), git worktrees, and any new directory you open — no prompt ever again.
Found by reverse-engineering the compiled binary: the check function (
checkHasTrustDialogAccepted) iterates up the directory tree viawhile(!0) { if(T.projects?.[_]?.hasTrustDialogAccepted) return true; ... }.That said, a proper
trustedWorkspacePatternssetting as proposed in this issue would be the clean solution — the workaround above is a blunt "trust everything" approach.Upvote, as this would make it possible to do
bash -c 'claude --new-flag /usage'. Or rather it would be cool if it was exposed such.+1 — I frequently launch Claude Code from my home directory and get this prompt every single session, even with
bypassPermissionsalready set in settings.json. AtrustedDirectoriessetting (or respecting the existing permission mode as implicit trust) would be a great quality-of-life improvement.+1 on this. My use case is slightly different from worktrees but the core problem is the same.
I run Claude Code from my home directory (
~) because I frequently need to edit dotfiles and system-level config files. Every single session, I get the trust prompt, and selecting "Yes, I trust this folder" does not persist — it asks again on the next launch.Environment:
~/.claude/settings.jsonhasbypassPermissionsmode enabledObserved behavior:
~/.claude.jsonafter confirming trusttrustedDirectoriesfile is created anywhere under~/.claude/A
trustedWorkspacePatternssetting (or even a simpletrustedDirectorieslist) would solve this for both worktree users and home-directory users alike.A PreToolUse hook can implement trusted workspace patterns:
Store patterns in a config file:
Read dynamically:
No, this won't work. The workspace trust dialog happens before the session starts — it's a pre-session prompt, not a tool call. PreToolUse hooks only fire once you're already inside a session and Claude is about to use a tool.
The trust dialog is at a different layer entirely:
So the hook would never get a chance to intercept the trust prompt. It's like trying to use an in-app setting to bypass the app's login screen.
~/.claude.json
It works for subdirectories.
Update: This is the same as what was said above, only more straightforward.
+1 on this, and one extension worth considering: the same "trusted workspace" decision should also suppress bash safety heuristics inside that workspace — not just the launch dialog.
Concretely, today's escape valves are all-or-nothing:
bypassPermissions— kills every prompt including ones I actually want (npm install, rm -rf, MCP tool calls)cd <path> && git ..."untrusted hooks" warning (#30435), which fires regardless of what's inpermissions.allowIf trust were a real scope rather than a one-shot dialog dismissal, the harness could:
cd && gitwhen both the source and target paths are trusted repos — which is exactly the worktree → main-repo merge flowPath-glob trust (
~/git/my-org/*) works, but remote URL as the trust key is more robust — worktrees inherit the same remote, so trust follows the code rather than the directory. Something like:Prior art: VS Code Workspace Trust, git's
safe.directory. Both treat trust as a scoped, repo-level concept — which is what's missing here.2.1.232 made this considerably more painful: the changelog entry "Fixed nested git repositories inheriting trust from a parent directory; each repository now requires its own trust confirmation" removed the one thing that was making worktree-heavy workflows bearable — a worktree under an already-trusted parent used to just work. Understood as a deliberate security fix, but it landed with no accompanying mitigation (no path pattern, no
additionalDirectories-equivalent for trust, nothing), so now everygit worktree addunder a trusted repo re-triggers the full trust dialog with zero workaround. Given this issue has been open and asking for exactly that mitigation, it'd be good to see the trust-pattern feature ship alongside — or before — security tightenings like this one that remove existing (if imperfect) affordances.