How to Control Which Files Repomix Includes or Ignores

Updated

Repomix gives you two glob-pattern fields for file selection — Include Patterns and Ignore Patterns — plus a set of file-processing toggles that change what actually lands in the packed output. Use Include Patterns when you want to narrow the pack down to a specific slice of the repo (for example, only src/**/*.ts); use Ignore Patterns when you want the whole repo minus certain paths (for example, **/*.test.ts or dist/**). If you only need to shrink token count rather than change which files appear, reach for the processing options instead: Compress Code, Remove Comments, and Remove Empty Lines.

Include vs. Ignore: which one to reach for

Goal Option to use Example pattern
Pack only part of the repo Include Patterns src/**/*.ts
Pack everything except certain paths Ignore Patterns **/*.test.ts, dist/**
Both — a narrow slice with exceptions Include + Ignore together Include src/**, ignore src/**/*.spec.ts

Both fields accept glob patterns, so the same syntax style works in each. The practical difference is the starting set: Include Patterns define what qualifies, Ignore Patterns subtract from what would otherwise be packed.

Setting Include Patterns

Include Patterns act as a filter — only files matching at least one pattern are considered for packing.

  1. Open the Repomix interface for your local or remote repository.
  2. Find the Include Patterns field (it sits alongside Ignore Patterns in the packing controls).
  3. Enter one or more glob patterns, e.g. src/**/*.ts to capture TypeScript sources under src, or **/*.py for all Python files.
  4. Run the pack and check the output: the file summary and directory structure should list only matching files.

Expected result: the packed XML, Markdown, JSON, or plain-text output contains just the files your patterns matched, which usually means a smaller token count and less irrelevant context for the model.

A common snag: an over-narrow include pattern (for example src/index.ts alone) drops the imports and helpers the model needs to understand that file. Start broad (src/**) and tighten only if the output is still too large.

Setting Ignore Patterns

Ignore Patterns remove files from the pack. This is the better choice when most of the repo is relevant and only a few paths are noise.

  1. Open the Ignore Patterns field.
  2. Add glob patterns for what to exclude — typical candidates are build output (dist/**), dependencies (node_modules/**), test fixtures, lockfiles, or generated code.
  3. Pack and verify the excluded paths no longer appear in the file summary or directory structure.

Expected result: the same repo, minus the excluded paths, in your chosen output format.

Because Repomix is described as Git-Aware, it already respects repository conventions to some degree, so you generally don't need to re-list everything a .gitignore already covers. Add Ignore Patterns for the extra exclusions specific to your AI workflow — for example, large snapshot files that are tracked in Git but useless as context.

File-processing options that change the content, not the file list

These toggles don't add or remove files; they change how much of each file is written into the pack. They're the main lever for token count once your file selection is right.

  • Compress Code — uses Tree-sitter to extract essential code signatures and structure while removing implementation details. This is the biggest token reducer, but it also removes the bodies of functions, so it's best when you want the model to understand architecture rather than edit logic.
  • Remove Comments — strips comments from the packed output.
  • Remove Empty Lines — strips blank lines.

Each of these trades fidelity for size. If you're asking a model to review or rewrite specific functions, leave Compress Code off and rely on Include/Ignore patterns to keep the pack focused instead.

Output-shaping switches worth knowing

Alongside file selection, Repomix exposes switches that affect how the packed content is presented:

  • Include File Summary — adds a summary of the files included.
  • Include Directory Structure — adds the repo's directory tree.
  • Show Line Numbers — numbers lines in the output.
  • Output Parsable Format — escapes the output according to the chosen style schema; the page notes this can increase token count.

The directory structure and file summary are cheap in tokens and often help a model orient itself, so they're usually worth leaving on. Line numbers help when you want the model to cite specific locations; turn them off if you're optimizing purely for size.

A worked example

Suppose you want an AI to review the TypeScript source of a repo, ignoring tests and build artifacts:

  • Include Patterns: src/**/*.ts
  • Ignore Patterns: **/*.spec.ts, dist/**
  • Compress Code: off (you want full function bodies for review)
  • Remove Comments: off (comments may carry intent)
  • Include Directory Structure: on
  • Include File Summary: on

The result is a pack containing only your source files, with enough structural context for the model to navigate, and no test or build noise. If the token count is still too high, the next step is turning on Compress Code or narrowing the include pattern to a subdirectory.

Quick decision guide

  • Wrong files in the pack? Fix Include/Ignore patterns first.
  • Right files, too many tokens? Use Compress Code, Remove Comments, Remove Empty Lines.
  • Model can't find things? Turn on Include Directory Structure and Include File Summary.
  • Need citations? Turn on Show Line Numbers.