Output formats

gnaw renders the selected files through a template chosen by --output-format (short -F). The default is Markdown.

gnaw . -F xml
gnaw . --output-format markdown -O context.md
ValueOutput
markdown (default)Path headers with fenced code blocks
xmlXML-tagged structure (below)
jsonSee the caveat below

Markdown

Each file is introduced by its path and wrapped in a fenced code block tagged with the file's extension, preceded by a directory tree. This is the most human-readable form and pastes cleanly into most chats.

XML

The XML form wraps everything in explicit tags, which models like Claude parse precisely โ€” useful when file contents themselves contain Markdown that could blur boundaries. gnaw's tags are:

TagContents
<directory>The absolute project path
<source-tree>The directory tree
<files>Wraps all file entries
<file path="โ€ฆ">One file; its code in a fenced block unless --no-codeblock
<git-diff>Present when a diff was requested (see git context)
FlagEffect
--no-codeblockOmit the fenced code fences around file contents
--token-format raw|formatPrint token counts as 1234 (raw) or 1,234 (format)
-t, --template <NAME_OR_PATH>Use a built-in or custom Handlebars template instead of the format default
-l, --line-numbersPrefix code lines with line numbers

Choosing a format selects gnaw's built-in template for that format; --template overrides it entirely with a named built-in (for example claude-xml) or a path to your own.