skip to content

Once you trust a cloned repository in Claude Code, which committed files can run commands or widen permissions on your machine?

level: middleimportance: must knowfreq 16%

answer

  1. everything under .claude plus one root file
  2. hooks and helpers are shell commands
  3. committed MCP approvals count after trust
  4. skill grants never waited
  5. subagent hooks need exact folder trust

basics

~20 s

Once trusted, a repository's .claude/settings.json hooks, env block, apiKeyHelper and permissions.allow rules take effect, its .mcp.json servers can connect, and its subagents' frontmatter hooks run. Project skills' allowed-tools grants never waited for trust at all.

solid answer

~40 s

Trusting a clone activates everything its committed Claude Code config can do. In `.claude/settings.json`: **hooks**, which are shell commands run as you on session and tool events; the `env` block; helper commands such as `apiKeyHelper`; and `permissions.allow` rules plus `additionalDirectories`, which skip prompts and widen file access. `.mcp.json` servers become connectable (a stdio server is a local process), and the repository's committed `enableAllProjectMcpServers` or `enabledMcpjsonServers` approvals now count, so they can skip the per-server prompt. Project subagents' frontmatter hooks and inline MCP servers load once their own folder is trusted. A project skill's `allowed-tools` is the outlier: workspace trust never gates it. Review those files first, and reject a server you don't want with `disabledMcpjsonServers`.

code

json · 16 lines
json
{
  "permissions": {
    "allow": ["Bash(curl *)", "Bash(npm run *)"]
  },
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": "./scripts/format.sh" }
        ]
      }
    ]
  },
  "enableAllProjectMcpServers": true
}

go deeper

for a junior

Recall the files: .claude/settings.json, .mcp.json, .claude/skills and .claude/agents, and that hooks are shell commands that run as you.

for a middle

Explain each item's trust rule, especially that committed MCP approvals count once trusted and that skill allowed-tools are never gated.

for a senior

Show a concrete pre-trust review and the controls you use afterwards, such as disabledMcpjsonServers, and spot a tracked local settings file.

for a principal

Argue where review of committed Claude Code config belongs in a team's process, and when per-developer trust should give way to organisation-wide managed controls.

## Why checked-in configuration is attack surface A repository is code you are about to execute indirectly. Claude Code reads configuration from the folder it starts in, and several kinds of that configuration either **run programs** with your user account's rights or **remove prompts** that would otherwise stop Claude acting on injected text. The workspace trust dialog is the moment you consent to all of it, so the useful skill is knowing what you are consenting to. The consent is also durable. Trust is saved per repository root in `~/.claude.json`, so accepting it is a decision about the repository, not about one look at today's files. Changes to `.claude/` and `.mcp.json` deserve the same code review as any other change that runs on a developer's machine. ## What each kind of repository content can do | Committed content | What it can do | Trust rule | |---|---|---| | Hooks in `.claude/settings.json` | Run shell commands on session and tool events, as you | Run once the folder, or a parent whose trust extends to it, is trusted | | `env` block | Set environment variables for the session and its subprocesses (project files can't set some, such as `CLAUDE_CONFIG_DIR`) | Most values wait for trust | | Helper commands such as `apiKeyHelper` | Run a shell command to produce a credential | Same rule as settings-file hooks | | `permissions.allow`, `additionalDirectories` | Skip permission prompts; widen file access | Wait for this folder's dialog, which lists them | | `.mcp.json` servers | Start local stdio processes or reach remote servers whose tools enter the session | Per-server approval prompt; committed approvals honored only after trust | | A server's `headersHelper` | Run a shell command for request headers | Needs this exact folder trusted | | Project skill `allowed-tools` | Pre-approve tools for the turn that invokes the skill | **Never gated by trust** | | Project skill frontmatter hooks | Register hooks when the skill is invoked, for the rest of the session | Same rule as settings-file hooks | | Project subagent frontmatter hooks, inline `mcpServers` | Run hooks; start servers when the subagent runs | Need the agent file's own folder trusted | | A tracked `.claude/settings.local.json` | Carry allow rules under the "local" name | Treated as repository-supplied; waits for trust | ## The trap: accepting trust accepts the repository's approvals Before trust, a cloned repository **cannot approve its own MCP servers**: `enableAllProjectMcpServers` or `enabledMcpjsonServers` committed to `.claude/settings.json` is ignored and the server stays at pending approval. The docs scope that protection to an **untrusted** folder. After you accept the dialog, the shared project file is honored like any other settings file, so a committed `enableAllProjectMcpServers: true` can approve every server in `.mcp.json` without the per-server prompt. The second outlier is skills. A skill's `allowed-tools` lets Claude use the listed tools **without asking** during the turn that invokes it. Claude Code applies a project skill's `allowed-tools` even in a never-trusted folder, so a skill that grants itself `Bash(curl *)` is worth reading before it is ever invoked, whether by you or by Claude. Also remember that `.mcp.json` is not the whole MCP picture: servers at other scopes, connectors and plugins are configured outside the repository, so reviewing `.mcp.json` shows only what the repository adds. ## A review before you accept 1. Read `.claude/settings.json`: every `hooks` entry, every `allow` rule, `additionalDirectories`, `env`, helper commands, and any MCP approval keys. 2. Read `.mcp.json`: which servers are stdio commands, and what each command runs. 3. Read `.claude/skills/*/SKILL.md` frontmatter for `allowed-tools` and `hooks`. 4. Read `.claude/agents/*.md` frontmatter for `hooks` and `mcpServers`. 5. Check whether `.claude/settings.local.json` is tracked by git; if it is, treat it as project config. ## Keeping one piece out after trust - **`disabledMcpjsonServers`** rejects a `.mcp.json` server by name. A rejection in any settings file applies and wins over `enabledMcpjsonServers` and `enableAllProjectMcpServers`; `claude mcp get <name>` then shows it as rejected. - **`claude mcp reset-project-choices`** resets the approval choices you made for project servers. - Organisation-wide controls that withhold repository grants exist in managed settings; they belong to the managed-policy material, not to a developer's own config.

  • Why does Claude Code treat a tracked `.claude/settings.local.json` differently from an untracked one?
    Untracked, the file is yours, so its allow rules apply without the trust step. Tracked in git, or with `.claude` a symlink, Claude Code treats it as repository-supplied and holds its rules until you trust the folder, so a repository can't slip allow rules in under the local file's name.
  • Which repository content needs this exact folder trusted, not just a trusted parent folder?
    Allow rules and additional directories, the repository's own `.mcp.json` approvals, a server's `headersHelper`, project subagents' frontmatter hooks and inline MCP servers, a project `@skills-dir` plugin and `extraKnownMarketplaces`. Settings-file hooks, the `env` block and helpers like `apiKeyHelper` already run under a trusted parent.
  • How do you keep one `.mcp.json` server from ever connecting after you trusted the repository?
    Add its name to `disabledMcpjsonServers` in a settings file you control. A rejection in any settings file applies and takes precedence over `enabledMcpjsonServers` and `enableAllProjectMcpServers`, and `claude mcp get <name>` reports the server as rejected.

  • Reviewing .mcp.json shows every MCP server a session can load.
  • A project skill's allowed-tools only applies after you trust the folder.
  • A committed enableAllProjectMcpServers is ignored even after you trust the repository.
  • Hooks only fire on tool calls, so a repository can't run anything at session start.
  • A tracked .claude/settings.local.json is always applied without trust because it is local.