Skip to main content
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:
Qwen Code automatically loads .qwenignore from the project root.

Pattern Syntax

.qwenignore uses the same pattern syntax as .gitignore:

Basic Patterns

Negation Patterns

Directory-Specific Patterns

Comments

Common Examples

Node.js Projects

.qwenignore

Python Projects

.qwenignore

Rust Projects

.qwenignore

Go Projects

.qwenignore

General Development

.qwenignore

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

Configuration Settings

Control how Qwen Code uses ignore files:
~/.qwen/settings.json

Disabling Ignore Files

To disable .qwenignore (not recommended):
To disable .gitignore:

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:
.qwenignore

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:

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