# How to pass flags to the LaTeX compiler with AUCTeX?

Consider the following two excerpts.

1. The imakeidx package's user manual states (version v1.3e, 2016/10/15, Section 1 Introduction, p. 2):

depending on the distribution and the shell editor that is being used to work on a specific document, it is necessary to add -shell-escape (or --enable-write18 for MiKTEX) to the command with which the typesetting program is launched, possibly through the shell editor.

2. The tcolorbox package's user manual states (version 4.03, 2017/04/25, Chapter 22 Library external, p. 427):

To use the externalization options, the compiler has to be called with the -shell-escape permission to authorize potentially dangerous system calls.

In both cases using a certain package, or activating some of its options, requires passing some flag(s) to the typesetting engine. For example, compiling the following LaTeX document:

\documentclass{article}
\usepackage[all]{tcolorbox}
\begin{document}
Hello, world!
\end{document}


results in the following error message:

ERROR: Package minted Error: You must invoke LaTeX with the -shell-escape flag.

How can flags be passed to the typesetting engine using AUCTeX?

Use TeX-command-extra-options (and check out the manual before asking questions ;-)
AUCTeX handles in a special way most of the main options that can be given to the TeX processors. When you need to pass to the TeX processor arbitrary options not handled by AUCTeX, you can use the file local variable TeX-command-extra-options.
User Option: TeX-command-extra-options
%%% TeX-command-extra-options: "-shell-escape"