 English comedian Ricky Gervais contributed to the writing of the episode and guest starred in it as Charles. As a big fan of The Simpsons, he felt it was "a dream come true." He was given the offer to write and guest star by The Simpsons creator Matt Groening, who was a fan of Gervais' British comedy series The Office. After meeting Groening and executive producer Al Jean in early 2004, Gervais set out to come up with the storyline for the episode. He was inspired by the British reality show Wife Swap. Though Gervais contributed a large part to the episode, the script was a joint effort with the regular writing staff of the show.
