Configure context sharing with .aiexclude files

You can control which files from your codebase should be kept hidden from Gemini in IDX by including .aiexclude files in your project. Much like a .gitignore file, an .aiexclude file tracks files that shouldn't be shared with Gemini in IDX, including the chat experience as well as AI features that operate in the editor. An .aiexclude file operates on files at or below the directory that contains it.

Files covered by .aiexclude won't be indexed by Gemini when Codebase Indexing is enabled. Additionally, .aiexclude will affect inline assistance for covered files in the following ways:

  • Chat assistance: Gemini won't be able to answer questions or offer suggestions about files covered by .aiexclude.
  • Code completion: Suggested code completions will not be available when editing covered files.
  • Inline assistance: You'll be able to generate new code, but not modify existing code when editing covered files.

Other development environments such as Android Studio may also honor .aiexclude files.

How to write .aiexclude files

An .aiexclude file follows the same syntax as a .gitignore file, with the following differences:

  • An empty .aiexclude file blocks all files in its directory and all sub-directories. This is the same as a file that contains **/*.
  • .aiexclude files don't support negation (prefixing patterns with !).

Examples

Here are example .aiexclude file configurations:

Block all files named apikeys.txt at or below the directory that contains the .aiexclude file:

apikeys.txt

Block all files with the .key file extension at or below the directory that contains the .aiexclude file:

*.key

Block only the apikeys.txt file at the in the same directory as the .aiexclude, but not any subdirectories:

/apikeys.txt

Block all files in the directory my/sensitive/dir and all subdirectories. The path should be relative to the directory that contains the .aiexclude file:

my/sensitive/dir/