TL;DR Start with
claude --add-dir ../lib, accept the trust question, and add a line to yourCLAUDE.mdtelling Claude tocdinto the other repo before running git, nevergit -C. With both,git logandgit statusthere run without a prompt. To make it permanent, open Claude Code once insideliband accept the trust dialog.
Since v2.1.325, Claude Code no longer runs git log, git status or git diff unprompted in a repository that isn't the project's or one you trusted. The prompt itself gives the reason: a repository's settings can make git run programs, and the permissions docs spell it out: running git in another folder can execute that folder's hooks. If you work across two repos at once (an app and its library, a frontend and its API), every time Claude looks at the other one, it stops and waits for you.
The prompt you get
Tested on v2.1.331 in manual mode, with an app project and a library at /tmp/addx/lib listed in additionalDirectories. Claude runs cd into the library, then git log, and the second command stops here:
Bash command
Show last two commits
git log --oneline -2
│ Git would use a repository that Claude Code cannot match to this project or to one you trusted. Its settings can make git run programs. If you trust it, start Claude Code there
│ once and accept the trust dialog, or name it with --add-dir at the start, which also loads its skills and commands. Its folder: "/tmp/addx/lib"
Do you want to proceed?
❯ 1. Yes
2. Yes, and switch to auto mode · auto mode handles these prompts for you
3. No
Notice what's missing: there's no "Yes, and don't ask again". You can't save a rule to make this prompt go away. You get rid of it by telling Claude Code the repo is trusted, and the prompt names both ways to do that.
What removes it and what doesn't
Each case in a fresh interactive session, with Claude running cd /tmp/addx/lib and then git log --oneline -2 as two separate commands:
How lib is set up in the session |
Result |
|---|---|
| Not at all | The cd asks, and even if you approve it the shell snaps back to the project: git log shows app |
In additionalDirectories, repo never opened in Claude Code |
The cd runs; git log asks with the prompt above |
In additionalDirectories, after opening Claude Code once in lib and accepting the dialog |
Both run without asking |
claude --add-dir /tmp/addx/lib at launch |
Both run without asking |
/add-dir /tmp/addx/lib inside the session |
Both run without asking |
The additionalDirectories setting gives Claude the folder, not your trust. With it, Claude can read and cd into lib, but git keeps asking until the repo counts as trusted. --add-dir and /add-dir do count, because both ask the trust question when they add the folder (since v2.1.326, in the terminal):
Adding a new directory:
/tmp/addx/lib
This session hasn't worked here before. Is this a directory you created or one you trust?
Claude Code'll be able to read, edit, and execute files here. Its skills, commands, and agents load and can run commands, and so can the git settings of its repository. Your
answer holds for this session. Starting Claude Code in this directory and trusting it there lasts, and covers its whole repository or everything below it.
❯ No, exit
Yes, add it
The dialog says it plainly: that answer holds for the session. What lasts is opening Claude Code inside the repo and trusting it there.
The case --add-dir doesn't fix: git -C
Even with the folder added the right way, one way of calling git still asks: git -C /tmp/addx/lib log. On v2.1.331 it asked with --add-dir and without it, and even when pointed at the project itself (git -C /tmp/addx/app log). It's also the form Claude picks on its own: in claude -p with --add-dir, asked for "the last two commits of the repo at /tmp/addx/lib", it wrote git -C /tmp/addx/lib log -2 and landed in permission_denials.
That prompt does offer to save a rule, but this is the rule:
❯ 1. Yes
2. Yes, and don’t ask again for: git *
Bash(git *) approves every git command, git push and git reset --hard included. That's far too much to silence a read-only prompt; have Claude change how it calls git instead.
How to stop approving it
1. Name the other repo at launch
claude --add-dir ../lib
Answer Yes, add it to the trust question. Besides git, this loads that repo's skills, commands and agents.
2. Already in a session? Use /add-dir
/add-dir ../lib
It asks twice: the trust question (Yes, add it), then whether to add the folder for this session only or remember it. Remembering keeps the folder for later sessions; the trust from the first question doesn't carry over.
3. Tell Claude to cd before git
Add this line to the project's CLAUDE.md:
To run git in another repository, first run `cd <repo>` as its own command, then run git there. Never use `git -C`.
With that line and --add-dir, the same request in claude -p finished with no denials: Claude ran cd /tmp/addx/lib, then git log -n 2, each on its own. Keeping them separate matters: per the permissions docs, cd other-folder && git log on one line asks even though each part is read-only, for the same hooks reason. It's the same mechanism behind Claude Code asking again for chained commands you already allowed.
4. Make it permanent: trust the repo once
cd ../lib && claude
Pick Yes, I trust this folder and exit. From then on, that repo counts as trusted in every session, and listing it in the project's .claude/settings.local.json saves you typing --add-dir each time:
{
"permissions": {
"additionalDirectories": ["/Users/ana/code/lib"]
}
}
Once the trust was accepted, cd and git log in lib ran without a prompt in a session that only had the setting. You still need the CLAUDE.md line: git -C asks regardless.
Official docs: Working directories · Read-only commands · Changelog, v2.1.325
Requirements
- The git change shipped in v2.1.325, and the trust question for
--add-dirand/add-dirin v2.1.326. Tested on Claude Code v2.1.331 on Linux, with two test repos, in manual mode.