How do I know if an NPC is hostile?
Shoot an arrow near the target while sneaking. If they are hostile to you, they'll start searching for you and you can see your stealth eye open a little bit. If they are not hostile, then they'll ignore your shot.
Courtesy of agent86:
The Detect Life spell conveniently color codes the creatures it detects. Red creatures are hostile, while creatures which appear blue will not attack you.
In my game, it has saved the life of the maid in Fort Greymoor. Also, it works through walls :)
The spell is available from merchants (at least in the College of Winterhold) once your Alteration skill is at least 50.
I think I read somewhere that there is an equivalent dragon shout, but I do not know what it is or if it also has the color-coding of Detect Life.
Try the PC console command getav
` -to enter console
target NPC with mouse, then:
getav aggression
will return 0-2 with 2 being hostile.