.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:
.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:
.gitignore- Controlled bycontext.fileFiltering.respectGitIgnoresetting (default:true).qwenignore- Controlled bycontext.fileFiltering.respectQwenIgnoresetting (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
.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
.gitignore
.qwenignore
Configuration Settings
Control how Qwen Code uses ignore files:~/.qwen/settings.json
Disabling Ignore Files
To disable.qwenignore (not recommended):
.gitignore:
How Ignore Patterns Are Applied
Qwen Code applies ignore patterns when:-
File Search (
glob,lstools)- Respects both
.gitignoreand.qwenignore - Excluded files won’t appear in search results
- Respects both
-
Content Search (
greptool)- Respects both
.gitignoreand.qwenignore - Won’t search content of ignored files
- Respects both
-
File Reading (
readtool)- Prevents reading ignored files directly
- Returns error: “File path ‘X’ is ignored by .qwenignore pattern(s).”
-
Workspace Context
- Ignored files are excluded from automatic workspace analysis
- Reduces token usage and improves performance
-
@ References
- Attempting to reference ignored files with
@file.txtwill show a warning
- Attempting to reference ignored files with
Ignoring Sensitive Files
Always ignore files containing sensitive information:.qwenignore
Best Practices
- Start with common patterns - Use templates above as a starting point
- Add project-specific patterns - Customize for your project’s needs
- Ignore generated files - Don’t let AI analyze auto-generated code
-
Keep both files - Use
.gitignorefor version control,.qwenignorefor AI exclusions - Document special cases - Use comments to explain non-obvious patterns
-
Test patterns - Use
lsorglobtools to verify patterns work as expected - Update regularly - Add new patterns as your project evolves
- 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
- Check file location -
.qwenignoremust be in project root - Verify syntax - Use
.gitignoresyntax - Check for typos - Pattern matching is exact
- Test with
lsorglobtools - Ensure
respectQwenIgnoreistruein settings
Files Still Being Read
- Check if file matches a negation pattern (
!pattern) - Verify pattern is correctly formatted
- Check if
.qwenignoreis being loaded (should be in project root) - Ensure settings allow
.qwenignoreto be respected
Too Many Files Ignored
- Review patterns for overly broad wildcards
- Use negation patterns (
!) to un-ignore specific files - Be more specific with directory paths
