How do you write a musical? It’s a question Alanis Morissette and Diablo Cody asked themselves with admirable cluelessness — the kind of blindness to convention that begets the best of artistic invention. Admittedly, the former, a singer-songwriter whose albums defined a generation of smart young people ready to slough off an unrelenting millennium, and the latter, an ascended chronicler of candid teenage life who gave us “Juno,” knew very little of the process.

Their answer became “Jagged Little Pill,” a defiant standalone musical which excavates an original story from the artist’s discography, mining fictional characters from the latent emotional work of Morissette’s music and shattering the narrative form of the bio-musical with the simplicity of a shrug.

Exactly how “Jagged Little Pill,” which opened at the Broadhurst Theatre on Broadway Thursday evening, managed to supersede the jukebox musical stop-gap is a story of simple, honest creativity little seen since Michael Bennett sat in a room with a tape recorder and a box of wine.

“I’ll never forget when we went to Alanis’ house in Malibu, Diablo Cody and I,” Diane Paulus, who Morissette tapped to direct the musical, told Variety on the opening night red carpet. “It was like building a universe around Alanis’ philosophy. We just drew all the names of the characters on a whiteboard, and we analyzed them and drew arrows between them.”

There, in the comfort of Morissette’s Malibu home — with the breeze, one might imagine, sailing off the Pacific — Morissette, Diablo and Paulus built the foundation of their musical. Morissette played them new songs she’d written — ones that would become the emotional center of a story about sexual abuse in a privileged Connecticut town, about addiction and darkness in picturesque America — and lent herself to its careful construction.

“I’ve never done this before, but I don’t think the artist attached to a musical like this is usually as involved as Alanis is,” Cody, still teary from the show’s performance, told Variety Thursday evening. “She was a full-blown member of the creative team. That day, we sat and talked about family systems, about psychology, about addiction. She played us songs we’d never heard before. She played us ‘Smiling.’ We heard ‘Predator.’ It was just this incredibly intense bonding experience, and we learned this wasn’t going to be a normal process.”

Diablo came to Morissette’s home with many of the characters already in mind.

“When I listened to the album,” she said, “the characters emerged from the individual songs, and they were undeniable. I listened to the song ‘Mary Jane,’ and I thought ‘Oh, that’s the protagonist.’ Then, I listened to the song ‘Perfect,’ and I thought ‘Oh, this is Mary Jane’s son, and he’s feeling this pressure to perform and be perfect in the context of his family.’ And ‘All I Really Want’ — this is an activist, this is a rebel. The songs just seemed to do so much of the work for me.”

Morissette, herself concerned that the musical not make the same mistakes of other jukeboxes, pushed that Diablo’s story capture the emotional vulnerability of the album with which it shares a name.

“There were a few topics that some people were scared of, some of the sexual abuse journey,” Morissette confided at the opening night party, held at the Edison Hotel. “They were being very considerate, and they said ‘We want to be careful here.’ And I said, ‘I’ve been through it myself, and I’ll be the person that backs it up. So, don’t worry.’ Diablo and I were crying the whole time, basically; there were tears,” she remembered.

“I leaned in when I needed to, stepped back, supported when they asked. It’s not autobiographical,” she continued. “It’s not about me, but it’s me relating to every character, their subtleties and complexities of what they are as humans coming from the music.”

Even amidst the grandeur of a Broadway opening night — not just a foreign scene for the artist, but one a world away from the comfortable unpretentiousness of her music — Morissette returned to that scene in Malibu, any moment of artistic catharsis imaginably sacred for the singer-songwriter.

“That was the inception, all the characters and their stories,” she said. “They lived — really lived — in that room.”