> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/QwenLM/qwen-code/llms.txt
> Use this file to discover all available pages before exploring further.

# Trusted Folders

> Configure workspace trust for secure project isolation

The Trusted Folders feature provides workspace-level security by controlling whether Qwen Code trusts a project directory for executing code and loading project-specific configuration.

## Overview

When enabled, Trusted Folders prevents Qwen Code from:

* Executing tools that require user approval (shell, edit, write\_file) in untrusted folders
* Loading project-level `.env` files from untrusted folders
* Using aggressive approval modes (YOLO, auto-edit) in untrusted folders

This protects you from accidentally running code in unknown or potentially malicious projects.

## Enabling Folder Trust

Folder trust is **disabled by default**. Enable it in your user settings:

```json ~/.qwen/settings.json theme={null}
{
  "security": {
    "folderTrust": {
      "enabled": true
    }
  }
}
```

<Warning>
  Once enabled, all folders are untrusted by default. You'll need to explicitly trust each workspace.
</Warning>

## Trust Levels

Qwen Code supports three trust levels:

<ParamField path="TRUST_FOLDER" type="TrustLevel">
  Trust this specific folder only.

  Example: Trust `~/projects/my-app` but not its parent directory.
</ParamField>

<ParamField path="TRUST_PARENT" type="TrustLevel">
  Trust the parent directory, making all sibling and child folders trusted.

  Example: Trust `~/projects` so all projects within it are automatically trusted.
</ParamField>

<ParamField path="DO_NOT_TRUST" type="TrustLevel">
  Explicitly mark a folder as untrusted, overriding parent trust.

  Example: Untrust `~/projects/suspicious-repo` even though `~/projects` is trusted.
</ParamField>

## Configuration File

Trust rules are stored in `~/.qwen/trustedFolders.json`:

```json ~/.qwen/trustedFolders.json theme={null}
{
  "/Users/username/projects": "TRUST_PARENT",
  "/Users/username/work/client-a": "TRUST_FOLDER",
  "/Users/username/downloads/random-repo": "DO_NOT_TRUST"
}
```

### File Location

* Default: `~/.qwen/trustedFolders.json`
* Override via environment variable:
  ```bash theme={null}
  export QWEN_CODE_TRUSTED_FOLDERS_PATH=/custom/path/trustedFolders.json
  ```

## Managing Trust

### Via Interactive Prompt

When you open an untrusted folder, Qwen Code will prompt you:

```
This folder is not trusted.

Do you trust the authors of the files in this folder?

> Trust Folder
  Trust Parent Folder
  Do Not Trust
  Cancel
```

Select your choice to update the trust configuration.

### Manually Editing trustedFolders.json

You can directly edit `~/.qwen/trustedFolders.json`:

```json theme={null}
{
  "/home/user/projects": "TRUST_PARENT",
  "/home/user/work/safe-repo": "TRUST_FOLDER",
  "/home/user/Downloads/untrusted-code": "DO_NOT_TRUST"
}
```

**Tips:**

* Use absolute paths
* Paths are case-sensitive
* Use forward slashes (`/`) on all platforms
* On Windows, use: `C:/Users/username/projects` (not backslashes)

### Via IDE Integration

When using Qwen Code through VS Code, Zed, or JetBrains IDEs, trust status is inherited from the IDE's workspace trust feature.

## Trust Rules Evaluation

Qwen Code evaluates trust using the following logic:

1. **IDE Trust (highest priority)**: If running in an IDE that provides workspace trust, use that value.

2. **Explicit DO\_NOT\_TRUST**: If the exact path is marked `DO_NOT_TRUST`, the folder is untrusted.

3. **TRUST\_FOLDER**: If the exact path is marked `TRUST_FOLDER`, the folder is trusted.

4. **TRUST\_PARENT**: If any parent directory is marked `TRUST_PARENT`, the folder is trusted.

5. **No matching rule**: If no rule matches, the folder is untrusted (when trust is enabled).

### Example Evaluation

Given this configuration:

```json theme={null}
{
  "/home/user/projects": "TRUST_PARENT",
  "/home/user/projects/suspicious": "DO_NOT_TRUST"
}
```

Results:

* `/home/user/projects/my-app` → **Trusted** (parent is trusted)
* `/home/user/projects/another-app` → **Trusted** (parent is trusted)
* `/home/user/projects/suspicious` → **Untrusted** (explicitly marked)
* `/home/user/Downloads/random` → **Untrusted** (no matching rule)

## Behavior in Untrusted Folders

### Approval Mode Override

In untrusted folders, approval mode is forced to `default` (prompt before execution):

```bash theme={null}
# Even with --yolo, will use default mode in untrusted folder
qwen --yolo
# Output: Approval mode overridden to "default" because the current folder is not trusted.
```

### Tool Execution

Tools requiring approval will always prompt:

* `bash` / `run_shell_command` - Always requires approval
* `edit` - Always requires approval
* `write_file` - Always requires approval

Read-only tools work normally:

* `read` - Works without approval
* `glob` - Works without approval
* `grep` - Works without approval
* `ls` - Works without approval

### Environment Variables

Project-level `.env` files are **not loaded** in untrusted folders:

* `.qwen/.env` in project - **Not loaded**
* `.env` in project - **Not loaded**
* `~/.qwen/.env` (user-level) - **Always loaded**
* `~/.env` (home directory) - **Always loaded**

### Workspace Settings

Project-level settings are **ignored** in untrusted folders:

* `.qwen/settings.json` in project - **Ignored**
* `~/.qwen/settings.json` (user-level) - **Always applied**

## Use Cases

### Trust All Personal Projects

```json theme={null}
{
  "/Users/username/projects": "TRUST_PARENT"
}
```

All folders under `~/projects` are trusted.

### Trust Specific Work Projects

```json theme={null}
{
  "/Users/username/work/project-a": "TRUST_FOLDER",
  "/Users/username/work/project-b": "TRUST_FOLDER"
}
```

Only specific projects are trusted.

### Trust Everything Except Downloads

```json theme={null}
{
  "/Users/username": "TRUST_PARENT",
  "/Users/username/Downloads": "DO_NOT_TRUST"
}
```

Home directory is trusted, but Downloads folder is explicitly untrusted.

### Trust Per-Organization

```json theme={null}
{
  "/Users/username/company-a": "TRUST_PARENT",
  "/Users/username/company-b": "TRUST_PARENT",
  "/Users/username/oss-projects": "TRUST_PARENT"
}
```

Organize projects by company/purpose and trust at that level.

## Security Best Practices

1. **Enable folder trust** if you work with code from unknown sources.

2. **Use TRUST\_PARENT** for directories where you manage all projects:
   ```json theme={null}
   {
     "~/my-projects": "TRUST_PARENT"
   }
   ```

3. **Use DO\_NOT\_TRUST** for directories where you clone external code:
   ```json theme={null}
   {
     "~/Downloads": "DO_NOT_TRUST",
     "~/external-repos": "DO_NOT_TRUST"
   }
   ```

4. **Review trust before using YOLO mode** - Check if the folder is trusted before enabling auto-approval.

5. **Combine with .qwenignore** - Use `.qwenignore` to prevent Qwen Code from reading sensitive files even in trusted folders.

## Checking Trust Status

You can check if the current folder is trusted by attempting a privileged operation. Qwen Code will indicate if the folder is untrusted:

```bash theme={null}
cd ~/Downloads/unknown-repo
qwen --yolo  # Will show override message if untrusted
```

Or check programmatically by inspecting the trust configuration.

## Disabling Folder Trust

To disable folder trust:

```json ~/.qwen/settings.json theme={null}
{
  "security": {
    "folderTrust": {
      "enabled": false
    }
  }
}
```

When disabled:

* All folders are treated as trusted
* `trustedFolders.json` is ignored
* Project `.env` files are loaded from all directories
* Approval mode settings work as configured

## IDE Integration

### VS Code

Qwen Code respects VS Code's workspace trust:

* If the workspace is trusted in VS Code, Qwen Code trusts it
* If the workspace is untrusted in VS Code, Qwen Code does not trust it
* IDE trust takes precedence over `trustedFolders.json`

### Zed

Similar to VS Code, Qwen Code inherits trust status from Zed's workspace trust.

### JetBrains IDEs

Qwen Code inherits trust status from JetBrains' trusted projects feature.

## Troubleshooting

### Folder Not Trusted Despite Configuration

1. Check the path in `trustedFolders.json` is absolute and correct:
   ```bash theme={null}
   pwd  # Get current directory
   ```

2. Ensure paths use forward slashes:
   ```json theme={null}
   // Correct
   "/Users/username/projects": "TRUST_PARENT"

   // Incorrect on Windows
   "C:\\Users\\username\\projects": "TRUST_PARENT"
   ```

3. Verify JSON syntax is valid:
   ```bash theme={null}
   cat ~/.qwen/trustedFolders.json | jq
   ```

### Can't Load Project .env

If project `.env` files aren't loading:

1. Check if folder trust is enabled
2. Verify the folder is trusted
3. Move sensitive keys to `~/.qwen/.env` (always loaded)

### Tools Always Require Approval

In untrusted folders, tools will always require approval. Either:

1. Trust the folder in `trustedFolders.json`
2. Use `--approval-mode default` explicitly
3. Work with read-only tools that don't require approval

## See Also

* [Settings.json Reference](/configuration/settings)
* [Environment Variables](/configuration/environment-variables)
* [.qwenignore File](/configuration/qwenignore)
