So what’s it like to date as a former spy? “You sort of have to get through the questions that come up, like ‘Can you kill me with your pinkie finger?’ and you’re like, ‘No, it’s not like that,’” Ms. Fox said.

She has been thinking a lot about the Hollywood portrayal of her former profession now that Apple is developing a TV series based on the book that will star Brie Larson. Ms. Fox is an executive producer on the series and has mostly served as a sounding board for Ms. Larson .

In an email, Ms. Larson called Ms. Fox “the definition of strength and bravery” and said they had discussed not just Ms. Fox’s experiences in the C.I.A., “many of which defy comprehension when you think about the risks she’s taken and the gender barriers she’s broken,” but also “food, travel and even breastfeeding.”

Ms. Fox shares plenty of made-for-Hollywood secrets in the book, including scrawling signal marks on bricks with Rolaids (“it’s less incriminating than chalk”) and communicating with sources via Starbucks gift cards.

“If you need to see me, buy a coffee,” Ms. Fox tells sources. She checks the balance on the cards each day at different cybercafes. Need an alternative to sending emails? “Write a message, save it to drafts, ensure that the recipient has the account’s email address and password, and wait for him or her to log in and read it.”

But she also tried to counter the cat-and-mouse depictions of C.I.A. officers sprinting through crowds of hijab wearers in Arab markets. “There’s no scene in the book where people are jumping off rooftops,” Ms. Fox said. (In real life, her cover would be blown by a single chase.) “I specifically chose interactions from my past that were very calm and soulful.”

In one of the more soulful scenes in “Life Undercover,” Ms. Fox tries to negotiate with the leader of a Qaeda terrorist cell planning an attack in Pakistan as his infant daughter wheezes in the background.