Skip to main content
Donovan LaDuke - Developer

How to Add an aiexclude File


Featured in Android Weekly Issue 634

At Google I/O 2024, Google announced support for a code generation tool powered by their Gemini LLM in Android Studio. While this feature can be a useful tool in some cases, there are likely parts of a code base that shouldn't be shared with a third party such as business critical or proprietary code. This oversharing can be avoided by adding an .aiexclude file to your project.

Formatting an .aiexclude File #

Opting out files from Gemini is as simple as adding an .aiexclude file in the root of the project or in the specific subfolder that should be excluded. To ignore all file, just leave the file blank or add the single * selector. If specific files should be matched, the syntax is similar to a .gitignore file with some notable exceptions. See the documentation page for all the specifics. And just like that, the code that should be private won't be sent to Google.

Conclusion #

One quick note as a wrap up, any files covered by the .aiexclude file will not get Gemini powered autocomplete, so it is a trade-off between privacy and productivity. Now the project team can leverage AI enabled autocomplete if that is desired while protecting the specific code that shouldn't be shared. Until next time, thanks!

Did you find this content helpful?

Please share this post and be sure to subscribe to the RSS feed to be notified of all future articles!

Want to go above and beyond? Help me out by sending me $1 on Ko-fi. It goes a long way in helping run this site and keeping it advertisement free. Thank you in advance!

Buy me a Coffee on Ko-fi