Sharon Horgan turns up for our interview, in a London editing suite, wearing a short floral dress that looks like it comes from Top Shop. This isn’t a bad thing, it’s just testament to her considerable beauty and youthfulness that she can wear a dress designed for a 17 year-old better than most 17 year-olds could – at the age of 42. It’s also apt because this very talented comedian’s most famous show, the wickedly funny BBC Three sitcom Pulling, was about women refusing to grow old gracefully.

Horgan is here to talk about her new programme, Dead Boss, which begins on 16 June on BBC Three. It’s a dark comedy focusing on a woman, Helen (Horgan), who is imprisoned for a murder she didn’t commit. A born optimist, Helen makes her best efforts to appeal and get out of prison, but little does she know that all her supposed friends and allies in the outside world are conspiring to keep her behind bars for their own convenience.

Other characters in the series, which Horgan has co-written with stand-up comic Holly Walsh, include: Helen’s paranoid-arsonist cellmate, Christine; the prison’s chief thug and bully, Top Dog, who turns out to have been Helen’s teacher at school; and a prison governor Horgan conceived as “a cross between the Queen and Margaret Thatcher – but sexy”, played by Jennifer Saunders.

“It’s the hardest thing I’ve ever done because I’ve never done anything as stupid as this,” says Horgan. “Everything I normally do has a large basis in reality.” Pulling followed the travails of three flatmates in their thirties; Angelo’s, her 2007 Channel 5 series, was set in a café; Free Agents, the Channel 4 black comedy in which she co-starred with Stephen Mangan, was about talent agents. But Dead Boss has a rather different tone.

“I really wanted to write something that everyone can watch, so there’s no swearing in it,” says Horgan. “I want to write something the way Graham Linehan [creator of Father Ted] does. He writes exactly what he wants to write and everyone seems to watch it.” This, then, is her stab at the mainstream. “And I don’t think there are too many adult themes…”

The thing is, Dead Boss still seems pretty dark to me. Top Dog sports the disfiguring scars of a violent assault. In the first episode, her gang of heavies corner Helen and Christine in the showers and scrub their faces with pumice stones. Another of the inmates has “Will Kill Again” tattooed on her forehead. The dark subject matter may be moderated by a certain goofiness but, nevertheless, it’s hardly Gavin and Stacey.

The fact is that, among her peers, Horgan’s comic taste is always going to be closer to that of Julia Davis than Olivia Colman. Intriguingly, all three women are going to be in a hilarious-sounding Dynasty spoof called Bad Sugar, written by the duo behind Peep Show, the pilot of which is coming up on Channel 4 later this year (although the full series doesn’t start filming until 2013).

Davis wrote Nighty Night, one of the meanest sitcoms ever made, about a sociopathic beautician who tries to steal the husband of a wheelchair-bound MS sufferer. Olivia Colman admittedly made her name with her own fine take on dark deadpan in Peep Show, but is now best known as the wife in Rev, Tom Hollander’s ultimately feel-good comedy about the travails of an inner-city vicar.

Horgan, who was born in England but grew up in County Meath, Ireland, before returning here in her late teens, puts her preference for darker stuff down to “just taste, really” but then admits she does find it more true to life. That was the appeal of Pulling, which she co-wrote with the playwright Dennis Kelly (who went on to find huge West End success with Matilda). The show was mystifyingly cancelled by the Beeb in 2009 after only two series and one special. In it, the three anti-heroines spend their days getting leglessly drunk and having one-night stands, which is not how thirtysomethings are traditionally portrayed on telly but is a lot closer to the truth than many may like to admit.

One of Donna’s pronouncements in Pulling’s first ever episode was, “I was lying there the other night in bed with Carl [her fiancé] looking at him, and he was snoring, and he had a little fleck of saliva in the corner of his lip, and I just found myself wondering what it would be like to chop his head off.” According to Horgan, Donna is “just an incredibly selfish character... which is sort of based on me.”

Horgan is what you might call a late developer. She spent much of her twenties in dead-end pursuits, training at not-very-good acting schools and taking jobs waitressing and in call centres, before she sobered up and did an English degree at 27. She met her future husband, Jeremy Rainbird, an advertising exec, at 34, and her two daughters rapidly followed, which calmed her down further and gave her space to develop some ambition – and write.

Does she still consider herself to be selfish now, I ask. “Possibly less selfish,” she says. “You have to be when you have kids don’t you? The thing is, when you’re an actor you’re never going to have the selfishness taken away fully.” Because there’s an inherent narcissism to the business? “Yes and because you need a certain amount of drive.”

Horgan has already explored these subjects in the public arena in a Channel 4 documentary on motherhood that went out last year to very good reviews. So good in fact that there are two more programmes in the pipeline: one on “how to be married” and another on “how to have a midlife crisis”.

The matter of midlife crises will, she says, “definitely be easy to relate to”. Why, is she having one now? “The ageing thing, and working in this industry – that alone would give you a midlife crisis,” she says. “But seriously, I’ve spoken to a lot of women my age and it’s kind of hard. You feel you can pretend to be young until you’re 50, but after that, what happens and how do you approach it?

“I’m sure the reason I’ve lived around Hackney [in trendy east London] for years is so that I can pretend I’m still young.” I tell her that I went out in Hackney recently but, finding the bars packed full of twentysomethings, the experience only made me feel older. “Oh, you find out where those pubs that just have young people are and you don’t go to them,” she advises.

Horgan is effervescent, entertainingly rather than offensively swear-y, and seems willing to talk about anything. She also asks me some questions, and I can count on the fingers of one hand the number of interviewees who have done this. Perhaps it’s her way of being deflective but it still makes me want to be her friend.

Dead Boss, in truth, is unlikely to make mainstream viewing: it’s much too bonkers for that, even if you ignore the scene where Henry, Helen’s admirer, pleasures himself over a lottery ticket. But the programme comes with Jennifer Saunders’s stamp of approval – courtesy of her very funny turn as the governor – and no doubt represents a stepping stone in Horgan’s irresistible, richly-deserved rise to eventual prime-time glory.