Richard Castle is a best-selling author who has published the final book in his successful series, in which he killed off the main character after writing the books became too much "like work".
At the end of the pilot episode, he becomes Beckett's partner in order to do "research".