How can AI help developer to develop things
An umbrella term for the application of heuristic techniques to software development is 'Search Based Software Engineering' (SBSE).

SBSE emerged as a distinct activity around the turn of the century, with a strong initial focus on automating the generation/prioritization of test cases.

With respect to some of your specific queries:

1.2 Paper on Automated refactoring


Automatically choosing screen colour to minimize energy consumption.
This sort of thing is not usually done heuristically, since it needs platform-specific code.
Automated refactoring to patterns.
AFAIK, penetration testing has yet to be successfully automated.
As stated, this doesn't really require AI. More generally, I don't know of any specific work automating for HCI preferences, but something like 'Interactive Genetic Algorithms' could be used.
There's a lot of SBSE literature on testing. See this paper for a general overview.