> ## 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.

# .qwenignore File

> Control which files Qwen Code ignores using .qwenignore patterns

The `.qwenignore` file allows you to specify files and directories that Qwen Code should ignore when searching, reading, or analyzing your project.

## Overview

`.qwenignore` works similarly to `.gitignore` and uses the same pattern syntax. It's useful for:

* Excluding build artifacts and dependencies
* Ignoring sensitive files (credentials, keys, secrets)
* Reducing context size by excluding irrelevant files
* Preventing Qwen Code from reading large binary files

## File Location

Place `.qwenignore` in the root of your project directory:

```
my-project/
├── .qwenignore
├── .gitignore
├── src/
├── dist/
└── node_modules/
```

Qwen Code automatically loads `.qwenignore` from the project root.

## Pattern Syntax

`.qwenignore` uses the same pattern syntax as `.gitignore`:

### Basic Patterns

```gitignore theme={null}
# Ignore specific file
secrets.txt

# Ignore all files with extension
*.log
*.tmp

# Ignore directory
node_modules/
dist/
build/

# Ignore all files in a directory
logs/*

# Ignore files matching pattern anywhere
**/*.min.js
**/*.map
```

### Negation Patterns

```gitignore theme={null}
# Ignore all .txt files
*.txt

# But don't ignore README.txt
!README.txt
```

### Directory-Specific Patterns

```gitignore theme={null}
# Ignore file only in root
/config.local.js

# Ignore test files in any directory
**/test/**
```

### Comments

```gitignore theme={null}
# This is a comment
# Comments start with #

# Ignore build outputs
dist/
build/
```

## Common Examples

### Node.js Projects

```gitignore .qwenignore theme={null}
# Dependencies
node_modules/

# Build outputs
dist/
build/
.next/
.nuxt/
out/

# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment files
.env
.env.local
.env.*.local

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Test coverage
coverage/
.nyc_output/

# Cache
.cache/
.parcel-cache/
```

### Python Projects

```gitignore .qwenignore theme={null}
# Byte-compiled files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
dist/
build/
*.egg-info/
.eggs/

# Virtual environments
venv/
env/
ENV/
.venv/

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# Jupyter Notebook
.ipynb_checkpoints/

# Environment
.env
.env.local

# IDE
.vscode/
.idea/
*.swp
```

### Rust Projects

```gitignore .qwenignore theme={null}
# Build outputs
target/

# Cargo lock (for libraries)
Cargo.lock

# Backup files
**/*.rs.bk

# IDE
.vscode/
.idea/
*.swp
```

### Go Projects

```gitignore .qwenignore theme={null}
# Binaries
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary
*.test

# Output of the go coverage tool
*.out

# Vendor
vendor/

# Go workspace
go.work

# IDE
.vscode/
.idea/
```

### General Development

```gitignore .qwenignore theme={null}
# Dependencies
node_modules/
vendor/
packages/

# Build outputs
dist/
build/
out/
target/
*.min.js
*.min.css

# Logs
*.log
logs/

# Environment
.env
.env.local
.env.*.local
*.key
*.pem

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db
desktop.ini

# Databases
*.db
*.sqlite
*.sqlite3

# Media
*.mp4
*.mov
*.avi
*.mp3
*.wav

# Archives
*.zip
*.tar
*.tar.gz
*.rar
*.7z

# Large data files
*.csv
*.parquet
*.pkl
*.h5
```

## Relationship with .gitignore

Qwen Code respects both `.gitignore` and `.qwenignore`:

1. **`.gitignore`** - Controlled by `context.fileFiltering.respectGitIgnore` setting (default: `true`)
2. **`.qwenignore`** - Controlled by `context.fileFiltering.respectQwenIgnore` setting (default: `true`)

### When to Use Each

**Use `.gitignore` for:**

* Files that shouldn't be in version control
* Build artifacts, dependencies, temporary files
* IDE and OS-specific files

**Use `.qwenignore` for:**

* Files that should be in version control but Qwen Code should ignore
* Large data files that are committed but don't need AI analysis
* Generated documentation that's committed
* Files that are too large or irrelevant for context

**Example:**

```gitignore .gitignore theme={null}
# Don't commit to git
node_modules/
.env
dist/
```

```gitignore .qwenignore theme={null}
# Don't read with Qwen Code (but can be in git)
package-lock.json
yarn.lock
*.min.js
*.map
CHANGELOG.md
LICENSE
```

## Configuration Settings

Control how Qwen Code uses ignore files:

```json ~/.qwen/settings.json theme={null}
{
  "context": {
    "fileFiltering": {
      "respectGitIgnore": true,    // Respect .gitignore (default: true)
      "respectQwenIgnore": true,   // Respect .qwenignore (default: true)
      "enableRecursiveFileSearch": true,
      "enableFuzzySearch": true
    }
  }
}
```

### Disabling Ignore Files

To disable `.qwenignore` (not recommended):

```json theme={null}
{
  "context": {
    "fileFiltering": {
      "respectQwenIgnore": false
    }
  }
}
```

To disable `.gitignore`:

```json theme={null}
{
  "context": {
    "fileFiltering": {
      "respectGitIgnore": false
    }
  }
}
```

## How Ignore Patterns Are Applied

Qwen Code applies ignore patterns when:

1. **File Search** (`glob`, `ls` tools)
   * Respects both `.gitignore` and `.qwenignore`
   * Excluded files won't appear in search results

2. **Content Search** (`grep` tool)
   * Respects both `.gitignore` and `.qwenignore`
   * Won't search content of ignored files

3. **File Reading** (`read` tool)
   * Prevents reading ignored files directly
   * Returns error: "File path 'X' is ignored by .qwenignore pattern(s)."

4. **Workspace Context**
   * Ignored files are excluded from automatic workspace analysis
   * Reduces token usage and improves performance

5. **@ References**
   * Attempting to reference ignored files with `@file.txt` will show a warning

## Ignoring Sensitive Files

Always ignore files containing sensitive information:

```gitignore .qwenignore theme={null}
# Credentials
.env
.env.local
.env.*.local
*.key
*.pem
*.p12
*.pfx
credentials.json
secrets.yaml
auth.json

# SSH keys
id_rsa
id_rsa.pub
id_ed25519
id_ed25519.pub

# API keys and tokens
.api-keys
.tokens
api-config.json

# Database
*.db
*.sqlite
*.sqlite3
database.yml

# Cloud credentials
.aws/
.gcloud/
.azure/
terraform.tfstate
terraform.tfvars
```

## Best Practices

1. **Start with common patterns** - Use templates above as a starting point

2. **Add project-specific patterns** - Customize for your project's needs

3. **Ignore generated files** - Don't let AI analyze auto-generated code

4. **Keep both files** - Use `.gitignore` for version control, `.qwenignore` for AI exclusions

5. **Document special cases** - Use comments to explain non-obvious patterns

6. **Test patterns** - Use `ls` or `glob` tools to verify patterns work as expected

7. **Update regularly** - Add new patterns as your project evolves

8. **Be specific** - Use specific patterns rather than overly broad wildcards

## Testing Ignore Patterns

Test your `.qwenignore` patterns using Qwen Code tools:

```bash theme={null}
# Start Qwen Code
qwen

# Test file listing
ls

# Test file search
glob "**/*.js"

# Test content search
grep "pattern" --include="*.ts"

# Try reading an ignored file
read ignored-file.log
# Should see: "File path 'ignored-file.log' is ignored by .qwenignore pattern(s)."
```

## Debugging Issues

### Pattern Not Working

1. Check file location - `.qwenignore` must be in project root
2. Verify syntax - Use `.gitignore` syntax
3. Check for typos - Pattern matching is exact
4. Test with `ls` or `glob` tools
5. Ensure `respectQwenIgnore` is `true` in settings

### Files Still Being Read

1. Check if file matches a negation pattern (`!pattern`)
2. Verify pattern is correctly formatted
3. Check if `.qwenignore` is being loaded (should be in project root)
4. Ensure settings allow `.qwenignore` to be respected

### Too Many Files Ignored

1. Review patterns for overly broad wildcards
2. Use negation patterns (`!`) to un-ignore specific files
3. Be more specific with directory paths

## See Also

* [Settings.json Reference](/configuration/settings)
* [Trusted Folders](/configuration/trusted-folders)
* [Context Settings](/configuration/settings#context-settings)
* [File Filtering Settings](/configuration/settings#context-settings)
