Spells like Muffle and Invisibility seem to help me remain undetected, or at least escape after detection. Also, pickpocketing while detected by anyone in the area seems to aggro guards most swiftly.
When I really want something that's dangerous to get--pickpocketing a staff of fireballs off an enemy warlock for example--I often save before the attempt. It feels a little like cheating, but becoming a crispy critter somehow didn't make my character's bucket list.
--You probably saw the tip that describes how looking at someone's pockets isn't a crime, but taking anything is.