John Oliver, Joel McHale and Ken Jeong are also among Community's diverse faculty. 'We mess with the structure to keep it interesting,' says creator Dan Harmon

In the UK we've only had the first season of Community, tucked away on Viva. But in the States, where it's won a loyal audience with its sharp gags, wild flights of fancy and love of pop culture, they're already on to the third. (It's also narrowly avoided cancellation, but that's another story). The action centres on a mismatched group of adults who, for various reasons, have returned to education at Greendale Community College in Colorado. There's disbarred lawyer/reluctant-Fonz figure Jeff Winger (Joel McHale, also the host of E!'s TV roundup The Soup); strait-laced Annie (Alison Brie, better known as Pete's wife Trudy in Mad Men); aspirant film-maker and pop culture sponge Abed (Danny Pudi, perhaps the show's greatest find); plus cult stars such as The Hangover's Ken Jeong and The Daily Show's John Oliver among Greendale's faculty. But for many, the entry point will be finding Chevy Chase in his first major sitcom role. As "moist-towelette millionaire" Pierce Hawthorne, he's been given free rein to indulge his masterful style of physical comedy, whether he's falling into drumkits or trying to eat a floppy slice of pizza. It's a performance that makes you wonder where he's been all these years.

A typical episode will take the week's class ("Advanced Criminal Law", "The Politics Of Human Sexuality", "Comparative Religion") as a starting point, with scripts that absorb everything from The Breakfast Club to Dungeons & Dragons, M*A*S*H and zombie movies along the way. It doesn't stick to a rigid format, either: they've made episodes that deal with parallel universes and chaos theory, and a festive puppet special. Community is steeped in the history of sitcoms – everything's resolved in 23 minutes – but the setting is very much a modern one; in one Christmas episode they discover that none of them spend the holidays in the same way – Shirley's a devout Christian, Annie's Jewish, Abed's Muslim, Troy's a Jehovah's Witness, Britta's atheist, Jeff's agnostic and Pierce is a "reformed neo-Buddhist" – but they still find a way to celebrate together (a snow blower helps).

'Sarah Silverman used to send me notes on my scripts. It's completely usual practice but I never took them very well'

Photograph: Patrick Fraser for the Guardian

It's no surprise then to find that Dan Harmon, the man who created Community "wasn't one of those kids with a football on the front lawn. Watching TV was more my thing." His first venture into creating TV came in 1999 when, alongside writing partner Rob Shrab, he approached Ben Stiller and Fox TV to pitch "a kind of super-sitcom", Heat Vision And Jack, the everyday tale of a renegade astronaut (Jack Black) and his talking motorbike (Owen Wilson) taking on "Ron Silver: actor and evil Nasa agent". It was filmed as a pilot, but never made it any further. That job, however, led to another, co-creating The Sarah Silverman Program, which balanced its more surreal moments with likable characters. The show was a cult hit, but not plain sailing for Harmon, who admits, "Sarah used to send me notes on the script and, while this is completely usual practice, I never took them very well."

It wasn't just irritation Harmon felt; he realised that, despite his high ambitions, he was stuck in a rut. "I found myself, in my 30s, with poor people skills," he says. "I knew I had to get my act together."

Fear proved a great motivator, as did boredom. "I'd enrolled in some community college courses, mostly for something to do while my wife took music classes," he says. "I studied biology and found myself in a room with a real variety of people. As I was one of the older ones, the kids would sometimes ask me to explain stuff to them, like cellular mitosis or whatever. I was getting along with people I wouldn't have usually even met."

These classes didn't just allow Harmon to show off his science skills – they also provided a natural device for getting a disparate bunch of people into the same room and giving them no choice but to interact. He had the situation, next he needed the community.

'I went though my address book, looked at all the people I knew and began to list all their character traits'

Community creator Dan Harmon, Photograph: Gregg Segal/Corbis Outline

"I went though my address book," Harmon remembers, "looked at all the people I knew and began to list all their character traits." He even put a little of himself into the mix, giving Abed his encyclopedic knowledge of pop culture, and letting Jeff run with his more arrogant, wisecracking side. Harmon observes similarly harmonious blends among the rest of the cast. "With a character like Jeff Winger," he says, "it's Joel McHale's charm and timing that stops him from being too much of a wiseass. We'd originally written the Troy character as more of a hayseed, typical jock type. But Donald Glover is so versatile and graceful that had to change. And Annie, she was this sort of plain, overlooked girl in high school who's now blossoming into this beautiful woman. She's like a Cylon who's detached from their metallic horde and just seeing what she can do with her power."

As you can tell, Harmon's completely at ease using Battlestar Galactica references such as Cylon in everyday conversation. Which leads us to the final ingredient in Community's successful recipe: its pop culture references. The episode Modern Warfare, for example, is a note-perfect pastiche of every action movie trope and cliche; and it's even directed by Justin Lin, of Fast And Furious fame. Such precise attention to detail makes rewatching episodes a joy: there are subtle changes in the opening titles, and skits in the end credits, like "Troy And Abed In The Morning". These little bits of business are devised by Pudi and Glover (who, outside of Community, is a popular stand-up comedian, has written for 30 Rock and The Daily Show, and even has a major-label rap record out as Childish Gambino).

Does Harmon worry that all these allusions might exclude less TV-literate types? "Not really. We can have a character read three pages of script about how much he loves Cougar Town and you don't need to know that show to get the gag." And if you really don't get that reference, there'll be another one around in a minute. "We're messing with the structure to keep it all interesting for us and the viewers," says Harmon. "Again, it's mostly to prevent boredom."

Community service: a brief who's who (with gags)

1. Jeff Winger (Joel McHale). Sarcastic disgraced lawyer sent back to college to avoid being disbarred. "I'm wearing a $6,000 suit, and you spent three days making cardboard box robot armour."

2. Pierce Hawthorne (Chevy Chase). Bored millionaire. "How long was I out? Is Napster still a thing?"

3. Señor Chang (Ken Jeong). "I did what any man would do. I faked my way into a job teaching Spanish at a community college using phrases from Sesame Street."

4 Annie Edison (Alison Brie). Straight-A student who flunked high school after an addiction to Adderall.

5 Shirley Bennett (Yvette Nicole Brown). Uptight divorcee who has "seen enough episodes of Friends to know that co-habitation leads to sex, drugs, and something Parade magazine calls 'Schwimmer fatigue'".

6 Britta Perry (Gillian Jacobs). Dropped out of college because she thought it would impress Radiohead.

7 Troy Barnes (Donald Glover). Nice-but-dim ex-high school quarterback. "How can something that's delicious make me sick? Unless too much of a good thing is actually a bad thing … My friendship with Abed is a giant cookie!"

8 Abed Nadir (Danny Pudi). Pop culture savant. "I can tell TV from life, Jeff. TV has structure, logic, rules, likable leading men. In life we have this … with you."