The series was created by Shawn Ryan. Ryan served as an executive producer for all seven seasons and was the series head writer and showrunner throughout its run. Prior to creating the series Ryan had been working as a producer and writer for the supernatural detective series "Angel". He began his television career as a writer for the crime drama "Nash Bridges". "Nash Bridges" was a more up-beat show, and Ryan was required to scripts that showed the hero succeeding in a positive way, and Ryan sought to write something far different to get that out of his system. He had considered what a cop drama would be like on a premium cable network like HBO and Showtime, taking into account the edge that shows like "" and "NYPD Blue" had brought to the genre. While trying to decide a direction, the Rampart scandal within the LAPD was exposed, and Ryan took inspiration from those events to craft out a pilot script. He also recently became a father, and wrote into the script his concerns about raising a child in a crime-ridden world. The pilot script had ended with Mackey shooting Crowley; Ryan had the idea of an alternate ending to "Donnie Brasco", of where Al Pacino's mobster character would have shot Johnny Depp's undercover FBI character, revealing that the mobster had known his identity all along. He used this ending idea in the pilot for "The Shield", not expecting to have to worry about any consequences as he wasn't sure the script would be picked up. Ryan later commented in 2017 that if he had known how long "The Shield" would have run for, he would have had a few more episodes to help establish Crowley's character before having Mackey kill him off.