Configuration
Prerequisites
Ensure you have gnaw installed. Familiarity with
TOML syntax is helpful but not required.
What is .gnawconfig?
The .gnawconfig file is a configuration file written in TOML format. When
you run gnaw, it automatically searches for this file in your current working
directory.
It allows you to define:
- Filtering Rules: persistent include/exclude patterns.
- Output Formats: default to JSON, Markdown, or XML.
- Template Context: pre-define variables for your Handlebars templates.
Quick Start
Create a file named .gnawconfig at the root of your project:
default_output = "stdout" # Options: stdout, clipboard, file
include_patterns = ["src/**/*.rs", "Cargo.toml"]
exclude_patterns = ["**/target/**", "tests/fixtures/**"]
line_numbers = true
output_format = "markdown"
[user_variables]
project_name = "MyAwesomeProject"
author = "Developer"
Configuration Reference
| Key | Type | Description |
|---|---|---|
path | String | Default path to codebase (usually .). |
include_patterns | Array | Glob patterns of files to include. |
exclude_patterns | Array | Glob patterns of files to exclude. |
line_numbers | Boolean | If true, adds line numbers to code blocks. |
absolute_path | Boolean | Use absolute paths instead of relative paths. |
full_directory_tree | Boolean | Generate the full tree even for excluded files. |
output_format | String | markdown, json, or xml. |
sort_method | String | name_asc, name_desc, date_asc, date_desc. |
encoding | String | Tokenizer: cl100k, p50k, o200k. |
diff_enabled | Boolean | Include git diff (HEAD vs Index). |
token_map_enabled | Boolean | Display a hierarchical token usage map. |
Understanding Precedence
Example: The "Review-Ready" Config
default_output = "clipboard"
line_numbers = true
token_map_enabled = true
exclude_patterns = [
"tests/**",
"**/migrations/**",
"*.md"
]
[user_variables]
review_focus = "Check for DRY principle violations and complexity."
Next Steps
Explore Custom Templates to see how to use
user_variables effectively, and the Filtering Guide
for advanced glob pattern syntax.