As I understand it, detection comes in one of two ways, either suspicious behavior, or directly detecting that your game has been tampered with. For the former, quality scripts are important. Lots of free scripts do little to nothing to hide themselves. It's especially bad for click-intensive tasks, like mining, as Juggles said. As for the latter, the only way of avoiding that to my knowledge is to use mirror mode.