SPOILER ALERT: Do not read if you have not yet watched “Living With Yourself,” streaming now on Netflix.

When writer and producer Timothy Greenberg was a child, he used to have a recurring nightmare. In it, he was sitting at his family’s kitchen table when the doorbell would ring and suddenly he would feel terrified, with his heart racing. His father would open the door, and there was another young Greenberg at the door. Something about that concept scared him then and stuck with him enough throughout the years that he revisited it in multiple story ideas, finally selling it as “Living With Yourself,” an eight-episode comedy for Netflix that stars Paul Rudd.

“I think that central question of identity and if you really could sit with another you, how would that make you feel, what would you think about seeing yourself from the outside is really interesting,” Greenberg tells Variety. “But it’s taking that magical thought and applying it to much more mundane, daily life concerns: How am I doing at work? What am I like with my family and my loved ones? A lot of what the story is about is these very real-world, grounded things. It’s the kind of things that hopefully we can all relate to, with just one magical twist.”

“Living With Yourself” centers on Rudd as a man named Miles who is somewhat complacent in his job and marriage. He visits a wellness spa on a tip from a friend, told he will come out of it feeling like a new man — only when he awakens after his treatment, he is buried nearly naked in the woods. He claws out of the dirt and runs home, only to find there is another version of himself — “Miles Plus or New Miles,” as the team behind the show calls him — in the house with his wife. The spa treatment he underwent was really a cloning process, during which the original person usually dies and is buried and the clone replaces him or her. But Miles bucked the system and has to contend with a version of himself that comes with far less baggage than he does.

“I’m not comparing myself to Charlie Kauffman, but tonally, it exists in the world of things that he does,” Greenberg says, noting that “Eternal Sunshine of the Spotless Mind” was an added inspiration for the project. “It’s about a character going through an existential crisis, and I think the humor grows out of that.”

Greenberg admits he didn’t want to go too broad with any of the jokes or other situationally comical moments within “Living With Yourself” because he wanted to immerse the audience first in Miles’ newfound reality and then shift the focus to New Miles’ perspective.

“There is a concern that if you just watch the first episode you go, ‘Oh I get it. It’s about a guy and his clone and they’re going to have some high jinx.’ But then when you get to the second episode, you realize, ‘Oh s—, it’s also about this other guy’s perspective, and I didn’t even think about what he was going through.’ And then you get to the third episode and, ‘Oh God, now they’ve just blown up the whole sneaking around thing,'” Greenberg points out. “Maybe you thought that was going to be the whole season, but you want to get past what the audience might expect and get to the next interesting thing for the story. I think the different perspectives helped enrich that a lot. By seeing everything from each character’s perspective, there’s a lot more story.”

However, there was some freedom to embrace lighter moments through New Miles, who Rudd notes is experiencing things for the first time. “There’s something childlike in every move he makes, like sticking his head out of the window of a moving car and feels the wind on his face. There’s something that isn’t jaded or judgemental about other people because he’s seeing how interesting everything is. In his own mind it’s not the first day he’s been alive, but in a way it is,” he says.

“Living With Yourself” packs a lot of story into the eight episodes because the show first considers sending New Miles off on his own but then pulls him back quickly to keep Miles’ world complicated. And then rather than keep this secret between himself and his clone, Miles starts to let others in on the truth, including the friend who referred him to the spa in the first place, which creates a second existential conversation with the show. Miles and New Miles confront the spa owners, and eventually Miles’ wife learns the truth, as well. All along the way, Miles grapples with what to do with this other version of himself while New Miles learns all of his memories are planted and begins to struggle with what that means for who he is separately.

“He hasn’t sat through all of the fights with his wife through the years and experienced all of the negativity, and so he’s able to see her in a fresh, positive way. He remembers having those fights, but it doesn’t mean that much because he’s not weighed down by the pain and the fear and the nicks and cuts and bruises you get as you go through life,” Greenberg says of New Miles. “When he does experience pain finally, he’s unprepared for it, and he reacts almost a little child-like and goes to a darker place than Miles would because Miles has defenses against it.”

In order to differentiate Miles from New Miles, Rudd shares that he started with the hair style and the physicality of both men. “The expression is different. My voice would get a little different just by nature of somebody who’s sitting up straight, versus someone with the weight of the world on their shoulders. Clothes would fit differently; clothes were bigger on the old Miles. Old Miles always missed a belt loop. Even though I thought nobody would see this, I always made sure to miss a belt loop,” he explains.

But he was always cognizant of not distancing the two men so much that “if you were going to run into one on the street, you were going to be thrown.”

Many projects that feature one actor playing opposite themselves rely on body doubles off of whom to work. But that is not what “Living With Yourself” did. Instead, Rudd audio-recorded the dialogue for each side of the conversation and wore an earwig during shooting to hear his own voice played back in the scenes, but he had no one physically in front of him, preferring instead to imagine himself in that space and the interaction that would take place.

“If Miles was driving the scene, that’s who I would start with, and if New Miles was driving it, I would start with that one,” he says. “I would go through the entire scene solo, and when we figured out the take we liked, I’d watch it during the change-over, try to memorize my movements so I would respond on the same lines.”

Four-and-a-half years ago when Greenberg was first working on this script, Rudd was at the top of the list for who he’d want to play both versions of Miles, in part because it was easy for him to imagine Rudd playing New Miles with that sense of “optimism and bright, loveableness that [Rudd’s] famous for.” But above that, he felt Rudd has “immense charisma” that lends itself to making the original version of Miles, who is “darker and more questioning and depressed,” more engaging.

“Early on when he was still debating doing it, we would read through the scripts together and Paul understood things about these characters and touchstones from his life,” Greenberg says. “Imagine Paul Rudd as a 15-year-old: He’s already bright and optimistic, but when he’s 15 everything is magnified. He had a ‘Why be normal?’ bumper sticker and he put it on his parents’ car, but he put it upside down because that’s even cooler. And then years later, he looked at it and he was like, ‘That’s so corny.’ So I think that was a great and funny example right off the bat about the pros and cons about somebody who was so open and willing to experience joy, and somebody who’s older and cynical and eye-rolling and is going to say, ‘Well that’s just ridiculous.’ I think he understood really early on who the characters were and what they wanted to be, and he brought all of that himself.”

Over the course of the first season of “Living With Yourself,” Miles and New Miles were often in competition with each other and even attempted to kill each other, but by the end they came to a sense of acceptance of themselves and their situation and appear to be ready to be an extended family with their wife (Aisling Bea), who announced she was pregnant.

“I think you kind of have to think of it in terms of accepting yourself and appreciating yourself and loving yourself for the things about yourself that you don’t like. That’s how you form a full-formed human being that has good parts and bad parts, and maybe the bad parts are actually good parts, and we probably need to accept ourselves for who we are and continually work on changing the things that can get better,” says Rudd.

While this first season has an arc that does come to a close, Greenberg admits that when it comes to the central question of how we live with ourselves, let alone our loved ones and the world, “this only scratches the surface.

“They’re not killing each other, but I wouldn’t say they’ve reached enlightenment yet,” Greenberg says. “They’ve solved the immediate problem, but I think there’s a lot more meaningful things to be dug into in the future about how they need to grow and learn.”

Greenberg’s longer-term plan for the show, should Netflix renew it, is not only to see more from these three essential characters but also to expand the world around them. “I imagine things happening in very different countries, in different time periods — things happening that really are connected to our central story but that you couldn’t possibly imagine now,” he says.