[FEATURE] A user-scope setting to pre-trust directories, for scripted `claude --bg`

Status Open
Reported on v2.1.232
Maintainer reply None cached
Activity 1 comment · opened Sep 28, 2026

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)

Problem Statement

Since v2.1.281, claude --bg checks workspace trust for the session's directory, and where no dialog can appear it exits with Workspace not trusted (documented). A git repository nested in a trusted directory, such as a clone, needs its own trust entry (changelog, 2.1.232).

Any script that clones a repo and runs claude --bg in it therefore fails on every fresh clone, because no one is there to accept the dialog. claude -p never shows the trust dialog, but --bg refuses to run without it.

Proposed Solution

A user-scope (or managed) setting, for example a trusted-paths list accepting globs such as ~/work/*, that counts as workspace trust, including for the nested-repo and --bg checks. It has to be user or managed scope, since a repository must not be able to trust itself. A flag on --bg alone would not cover restarting a session, which runs the same trust check.

Alternative Solutions

Tried on 2.1.284 (Linux), in a fresh nested repo, with claude --bg "reply ok" </dev/null:

| Attempt | Result |
|---|---|
| no setting | Workspace not trusted |
| permissions.defaultMode: "bypassPermissions", or --dangerously-skip-permissions | same error |
| trustedDirectories (named in earlier requests, absent from the docs; parent, exact path, /*, /**) in user settings | same error |
| hasTrustDialogAccepted = true for the repo path in ~/.claude.json | session starts |

The documented hand-edit (permissions) works, and I run it from a git init.templateDir post-checkout hook after every git clone. It edits a file that concurrent sessions also write, and the --bg error page only suggests running claude interactively.

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

  1. An agent running in a container clones a repo into a work directory.
  2. It runs claude --bg "<task>" in the clone.
  3. Today: Workspace not trusted. With a trusted-paths setting covering the work directory, the session starts.

Additional Context

Related: #79707 (open) asks for a non-interactive way to trust a workspace, framed around claude -p. This request is specific to --bg, which is gated even though -p is not. Earlier requests for a pre-trust setting or flag (#12737, #29285, #42805, #45298) were closed as duplicates; no such setting or flag has shipped.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗