You've written a surefire-hit TV script, and the producer wants you on set. Fun and canapes all the way? Fresh Meat and Peep Show writer Sam Bain shares some advice (and a few regrets)

The relationship between the screenwriter and the filming process is a complicated one. Every production is different, and every writer is different. Some productions don't want the writer around, and some writers don't want to be around the production. Some writers are so keen to be involved that they take the drastic step of becoming directors (I'm looking at you, Graham Linehan).

A writer's status in a production can range from extremely low (a first-timer writing a sketch for an established star) to extremely high (Steven Moffat showrunning Doctor Who). My writing partner Jesse Armstrong and I have run the gamut. On one of the first sitcoms we were hired to write for, we were keen to be involved at every stage. We asked for an office, and the producer obliged by giving us a desk in the photocopying room. The symbolism could only have been clearer if he'd ushered us into a spare cubicle in the gents.

On the shows we have created, however – Peep Show, The Old Guys, Fresh Meat – we have been as involved as we wanted. The upside is that none of the big decisions are made without our input; the downside is that if something doesn't work, there are no scapegoats.

Good relationships with producers and directors are crucial. If the producer and director understand you have the show's interests at heart, rather than a precious desire to get your own way, things will be fine. Unless, that is, you're working with arrogant, incompetent tossers, in which case you and the show are probably screwed. Here are some general rules of engagement.

Script

The moment your script is green-lit, it goes from being a charming tale of theoretical hi-jinks to a practical template for an expensive entertainment product a team of professionals will spend a great deal of time and money attempting to film. If you're keen to engage with this, you need to flip a mental switch and look at your script from their point of view. If you're not, and instead expect the crew to magically make everything come to life despite their impossibly tiny budget, you are, to use an industry term, a dick.

A new currency evolves at this point. How much is that mutant octopus/exploding shed/alien invasion actually worth? If the entire storyline revolves around it, it's worth a lot. If you suddenly remember it's only there to set up a joke you cut in draft two, it's worth a lot less. You will discover neat workarounds which can preserve the important stuff while losing the expensive stuff. (A car crash might be a nightmare to film; the immediate aftermath of a car crash is relatively easy.)

In the end, it comes down to that moment on a frosty winter morning when David Mitchell asks you why it's so important that he jump nearly naked into a freezing lake. You need to have a pretty solid explanation. Mitchell is an expert in Taekwondo; his Peep Show co-star Robert Webb is an expert marksman.

Casting

It's all very well creating Del Boy or Basil Fawlty, but if they cast John Cleese as Del and David Jason as Basil there isn't much point. It's vital for you to be as involved as possible.

One mistake Jesse and I made early on with Peep Show was, out of sheer enthusiasm, attending all the casting sessions. This not only takes up an unbelievable amount of time but is counterproductive. Often an actor who is great in the room is not so great on tape, and what's on screen is what counts. Watching auditions on tape also insulates you somewhat from the reality of the sheer volume of talented actors' time you are wasting.

Rehearsal

Rehearsal might be the first and possibly only time you get to interact with the cast and discuss the script with the director. It's an opportunity to clear up potentially deadly confusions: if an actor has always assumed his character is a repressed homosexual, it's your chance to explain he's just an unfeeling cyborg.

Rehearsal is also a great chance to make final changes: tweaking dialogue, wrapping a part more closely around an actor who has a different accent/gender/take than you had envisaged. The first time you hear your script read by the actors is the first time you really see it; the first read-through is far more significant than the first day of filming.

Filming

My dream, my nightmare. Being a writer on set is like standing next to a photocopier during a seven-week-long printout. It's repetitive and often boring and not the best use of your time, but if you walk away there's always the chance of a catastrophic paper jam.

On the one hand, filming is glamorous and dramatic and the only bit people outside the industry are remotely interested in. On the other hand, it's definitely the least important for the writer. Once you've written and cast the show and have a good director, 90% of your show is locked down.

But you'll find yourself on set at least once and possibly a lot more. Here are a few suggestions as to how to conduct yourself:

Eat as much as you possibly can

The food is free and, on the whole, high quality. Sometimes the only response to an actor randomly changing your lines is spooning down mouthful after mouthful of sticky toffee pudding.

A writer on set is an alien

You are the only person there with no official role. I'm including the nurse who has done nothing but knit jumpers for six weeks or the driver having a snooze in his car. They're both on the call sheet (the list of crew members). So try to convince people you are a peaceful alien who means no harm, like Klaatu from The Day the Earth Stood Still.

Ideally, transform from alien to human by getting your name on the call sheet

As associate producer perhaps, or if your agent is really good, executive producer. This may save you from being mistaken for a runner and sent out for emergency doughnuts and Tampax. (It might also save your life: when writers Graham Linehan and Arthur Mathews were driving to the Father Ted location, they almost died because they weren't on the call sheet and hadn't been told about black ice.)

Your notes require careful judgment

OK, let's not call them notes, let's call them what they really are: interventions. There's a good chance that if you have something to say, you'll be doing it while the actors are in costume, the lights are blazing, the cameras are running and every word is costing money. So make sure it's worth saying.

Your notes require careful timing

The earlier you say something, the better. Mentioning during the on-set rehearsal that you don't think a character should have a moustache is welcome and potentially valuable; mentioning it after the fifth take is neither.

If in doubt, speak up

I have a few regrets about notes I have given on set, but I have a lot more about notes I didn't give. I'd rather say something stupid – "We are going to have a CGI dragon over the guy in the wetsuit covered in ping-pong balls, aren't we?" – than forever regret not speaking up when watching my show on TV, which features a man wearing a wetsuit covered in ping-pong balls.

Editing

Ideally by this stage you won't have burned your bridges with the producer and director by having demanded they keep your gratuitous motorcycle chase, insisted your girlfriend/boyfriend/aunt is given a leading role, given the actors notes by reading out the lines and telling them to copy you, or screamed at the art department for buying the wrong kind of potato. Keep your powder dry and your credit high for the edit.

Editing is far, far more important than filming. No one starting out realises this because, as the great screenwriter William Goldman once said, there are no editing anecdotes – no amazing little stories about the day the editor tried cutting out a reaction shot, then put it back. But in many ways editing is where your script gets written for the second and final time.

If you're lucky enough to be involved, try to limit your time in the edit. The fewer times you watch a cut, the clearer your view of it will be. This is particularly true of genres such as comedy and horror, where it takes effort to imagine the visceral reaction expected of an audience.

Broadcast

The "fun" bit – the final tasting of the dish you've spent months, possibly years, cooking up. Unfortunately, you're the viewer who'll enjoy it least. Even if everything has gone spectacularly well, you'll still be obsessing about the moustache you wish you'd mentioned, or the fact that your character would definitely be eating Maris Piper and not King Edward potatoes. But that's the sacrifice you have to make. And if you're really hating it, just remember it's preferable to the alternative – not being broadcast at all.