It is said that the secret of good writing is to write about what you know. As such, you might expect the writers of Channel 4's Peep Show (which is definitely good writing) to be two miserable, socially inept losers holed up in a rather depressing flat, bickering relentlessly. It's something of a surprise, then, to find that they are a cheerful, seemingly well-adjusted duo, who work from of a Thameside office with glorious views to the Palace of Westminster.

Another thing that separates them from their comic creations, Mark and Jeremy, is the phenomenal success they have enjoyed, both together and individually. Of their myriad hit comedy works, though, Peep Show remains the jewel in the crown, winner of awards, a favourite of the critics, and lauded by the likes of Ricky Gervais. They are currently putting the finishing touches to the show's seventh series, which will transmit on Channel 4 this autumn.

Why do so many comedy writers work in pairs? Why does it work for you guys?

Jesse: Your aim is very clear when you're writing comedy. You're trying to make people laugh. (That's a useful insight there for people.)

Sam (incredulous): You're trying to make people laugh?

J (laughs): And writing as a team is particularly amenable to that. There's room for debate about what's working and what isn't. If you have a similar sense of humour, then it's pretty easy to work as a pair, and it's incredibly helpful, because you cook up those comedic moments more easily in a pair or a group scenario. And also in terms of plotting, plotting is hard, and with two people you get from idea A to idea D a lot quicker than you do if you're on your own.

S: Idea D was one of mine.

Why did you decide to go down a writing route as opposed to performing? Bearing in mind that you write very funny stuff, why were you not drawn to stand-up, for example?

S: The simple answer to that is I have no interest or talent in performing. It never really occurred to me. I know some people go from doing performing, or writing and performing, to doing sketches and then they do a sitcom. We sort of came the other way, we did fiction, short stories, I wrote a novel, and then we went straight into sitcom narrative. We always wanted to write narrative, we always thought of ourselves as writers. I mean, Jesse's a good actor, but I never really had any talent or interest in performing.

J: Yeah, I'm not a good actor. That's a nice thing for you to say. I was once an extra in one of our shows, I had to come round a corner and shake someone's hand. I did it about five times, and then the nice director said 'Yeah, that's brilliant, we've got you now. Let's get someone else who's just a bit taller to do it as well, just so we have that option', which was a very nice way of saying I couldn't walk around a corner successfully on camera.

How does the writing process work? When you sat down to write series seven, how do you get started?

S: This series was actually relatively easy in that sense, because we knew we had three episodes that we wanted to do. The first one is the birth of the child - that's a given. And then the scheduling was very fortuitous - the last episodes are going out at Christmas and New Year, so it gave us the obvious options of doing a Christmas and a New Year's episode. So half the series was taken care of.

J: Now we're coming to the end of working on series seven, when new ideas come up, we start adding them into a little document in case we do series eight, so that document grows and grows, and we just chuck in anything from half a line to whole characters or plots or situations. So we always have that to start the series with, and we mix that in with where Mark and Jeremy are in their relationship, and we have a bunch of other narrative ideas which we'll try and hit. For example, we've got a nice episode in this series where Mark and Jeremy get somewhat trapped somewhere, and that's an idea we've had knocking around in that big document for years, and have finally found a place where it fits in with the narrative.

Does one of you automatically write more for one character? Do you divide it like that?

S: No, not at all. I think that's probably more of a writer-performer thing, I'd imagine. We've got Simon Blackwell writing an episode, which he's done in the last two series as well, and he writes the characters just as well as us. I think that's a very encouraging sign that the characters have a life of their own. But we always share the work equally for each character.

Is it part of the writing process to have disagreements? How do you resolve those?

S: We never disagree on anything! I think there's a very healthy approach you can take - as long as you're always constructive in criticism, and you always offer up solutions, it's great. You're always working on topping each other's ideas, which is a great way of ensuring that the show hopefully keeps getting better.

J: Yeah, there's no magic formula, you just have to have a good working relationship whereby you can say when you don't like an idea. You want to be able to say 'Yeah, I can see why you'd suggest that', rather than 'That's not funny, you're a dick'. Sometimes it might be a line that Sam's written that is really good, and I'll suggest we end a scene with it, and he might have gone off it. We're on our third read-through just now, so we have the ability to road test things. When you hear it with a room full of people, it can be quite sobering about your brilliant idea to end a scene with a six-minute pause while somebody looks into the camera weeping.

You knew Robert and David before you started writing Peep Show. Did you then write it with them in mind to play the characters?

S: Yeah, that was one of the great advantages of doing that pilot. We knew them, we knew what they were good at, and we knew them as people. It's a huge advantage, because you don't have that worry about casting, and you know the voice and the face of the person you're writing for.

J: And we talked to them a lot about the show and what their characters would be like. They still write a bit of additional material - they used to, when they were a bit less busy, write even more. Their sense of humour infused the show from the start. We were both admirers of their comedy as performers and writers, and so their sensibility has always been part of the show.

You can't help but be aware that Mark is quite close to David's persona. Has he noticed?

S (laughs): He gets asked that a lot, I think. 'Are you Mark Corrigan?' He isn't.

J: The thing about David Mitchell, as a person, is that he's incredibly funny. Mark Corrigan isn't a wit in a way that David is, and it means that David is an utterly different person from Mark Corrigan. He's just a much more rounded person - much better-written than we'd ever be able to manage! Although people like to imagine him as a sort of stock character, he's constantly surprising, as well as being the persona he has on TV. So there are similarities between the two people, but I never think 'My God, it's brilliant, we can just write what you say because you are Mark Corrigan, you pathetic nerd'. He's a long way from that.

S: Yeah, he's also incredibly successful, whereas Mark's a total loser.

There's an element of the comedy that works because we can all see ourselves in Mark and Jeremy. Do you put a lot of yourselves or your own experiences in there?

S: We do occasionally create plots based on real life anecdotes - things that have happened to us, or people we know.

J: For example, the storyline in this series where they're trapped. It did happen to us a bit, but it happened to us for 20 minutes, whereas it happens to them for a lot longer. It's like all writing - it's all us, things we've thought, or things it's possible for us to imagine other people thinking.

S: But it's also none of us. It's all made up.

I read that one of you did once actually sit on a burglar, as Mark famously did.

S: Yeah, that's on Wikipedia now! It's a matter of record. It did happen to me. I was working at a video shop, and apprehended a burglar and sat on him.

Once you've finished all the writing and rewriting, do you guys hand over the scripts and move on to the next project, or do you go on set for the shoot?

J: One of us goes down every day, to be with Phil, our long-time producer, and Becky Martin, our long-time director, and we make a nice gang of people behind the monitor to discuss what's going on.

Do you tweak lines when you're there?

J: We're not massive rewriters on set. Partly because we do three read-throughs and then rehearsal as well, so by that point we tend to leave the script alone unless there's an unforeseeable issue. We very rarely write a new funny line. But we also have another round of writing, which comes during the edit, because of the voiceovers.

All the voiceovers in the scripts we like to think of as finished, but when it comes to the edit you realise that they were only temporary holding versions, and everything is up for grabs again. You could rewrite the story totally from what people think in their heads. It's a good freedom, and it means we get more jokes per minute into the show than you would do on another show. So we're sitting here now in August, but because of the voiceovers, we'll be writing until November. And we've been writing it since January. So there's a lot of jokes in there.

Peep Show is basically about two guys who spend a lot of time together, and are mutually dependent, but at times hate each other and dread each other's success...

J: You don't need to finish the question! It's us.

S: (Laughs) I love Jesse, and I like to spend time with him. I just feel very grateful to have someone like him in my life. I feel like Mark and Jeremy don't really have that level of affection.

J: Yes, that's true. But it is true also that we've written a lot of shows about men spending too much time together.

S: I guess you write what you know!

When you started out, did you ever think you'd be writing series seven?

J: Yes, we had it all planned out from the beginning, so it's been very simple for us...

S: We actually wrote series seven first. We've been working up to it ever since...

J: No, it's an utter dream. I remember very well waiting for the first reviews to come out, and thinking 'Is this going to get hammered?' in the way that some new comedy shows do. It seems like a dream to have got this far. We've worked on shows where they haven't even put out every episode in that series let alone done another one. When we got the second series, that was a really big deal for us. 'This, officially, hasn't been a disaster'.

S: That would probably be the biggest moment for us apart from the show being commissioned in the first place.

J: When you're doing the second series, you occasionally joke about 'when we're doing series four...'

How much longer do you think it can go on?

J: I don't know. I don't think we could think about it stopping, but on the other hand, right in the middle of production now it feels like I think we might both throw up if we had to think about writing the next series right away.

S: We need a break. But I think when you have a show that works, it's such a rare, extraordinary event, and so difficult - to make sure you've got the right producer, director, the right writers, the right actors, all working together, and once you have that, you sort of feel like breaking it up would be such vandalism, because the next show you start might be a disaster for any number of reasons - there are so many reasons a show can fail, from having the wrong cast to being in the wrong slot to being on the wrong channel to the person who commissioned it leaving and someone else coming in... There are so many ways a show can't work that when it does work, you feel like you've got to cherish it.

As well as your own successes, you've seen the cast all go on to great things. Is that quite satisfying for you?

S: Yeah, it's great. Obviously Dave and Rob are these ubiquitous comedy legends, which is wonderful. But also people like Matt King has got his own show now filming.

J: It's called Whites, it's going to be on in the summer on the BBC. He used to work in a restaurant as a chef, and he's co-written the show, based in a restaurant, and I think it's going to be brilliant. And Colly - Olivia Colman - we first had her in the show because Dave and Rob suggested her for the role, and she was obviously immediately brilliant, and probably always under-served in the show. We've never written her a part as funny as she is able to do. But she goes from strength to strength, and is such a talent. So it's lovely to see that, it's a really nice aspect of the show.

And you've even now managed to get a member of the cast into the royal family.

J: We're trying to place everyone in positions of power. It's like some kind of cultish thing.

S: We're trying to get Dobby in the government.

Will Sophie still be available to do the series? And is it acceptable to have a member of the royal family making jokes about things like masturbation?

S: Well, we don't tend to write those sort of jokes for her anyway.

J: There's a royal warrant now which says that we can't. As for whether she'll still be in the show, at the moment there may be availability issues, but she's meant to be in the show, and she's a very good comedy actress, and she likes doing funny lines, so we've never had a content issue with her.

The last series ended on a knife edge, with Sophie in labour driving herself to hospital. Any hints about what we can expect from this series?

J: We thought long and hard about whether we should join the show three months down the line or whether we should directly continue it. And in the end we decided that we've seen a lot of tense moments in Mark's life, but seeing him at the birth of his child felt like something we just couldn't afford to miss. So that's the opening episode.

S: And there will be a new love interest for Jeremy as well. We haven't cast that yet, though.

How would you rate the health of British sitcoms at the moment? What do you particularly enjoy?

J: I think it's worryingly healthy, isn't it? It's annoyingly good.

S: I enjoyed Rev.

J: Yeah, Rev was good. The IT Crowd is on a roll, and is very strong. Great Outdoors is on at the moment and seems to be good.

S: Pete versus Life looks like it's going to be good. There's quite a lot actually. Miranda's funny. Psychoville I loved. The Thick of It - I'm allowed to say that (Jesse wrote it). I'm looking forward to Sharon Horgan's new sitcom about prisoners. That looks fun.

J: And then there's Todd Margaret, with her and David Cross in it as well. And The Inbetweeners.

S: Oh yeah, I love The Inbetweeners.

J: All in all, then, a worrying amount of good stuff.