Stevenson claimed to have written The Strange Case of Dr Jekyll and Mr Hyde in just three days, after having a nightmare that presented him with the entire plot:
I had long been trying to write a story on that strong sense of man’s double being … For two days I went about racking my brains for a plot of any sort; and on the second night I dreamed the scene at the window, and a scene afterwards split in two, in which Hyde for some crime, took the powder and underwent the change in the presence of his pursuers.
However, new research suggests he wrote the book whilst being treated for bleeding with a hallucinogenic drug, ergotine, injections of which "led to side-effects that created a 'Mr Hyde-like' transformation in the author". (Or put another way, perhaps the ergotine regime was responsible for a nightmarish experience that inspired the book.)
More how we work.