Born in Milan, Castelli began his comic book career at an early age, creating the strip Scheletrino, a humor series for Italian comic book Diabolik, when he was only 16 years old.

In 1966, with Paolo Sala, he created Comics Club 104, the first Italian fanzine dedicated to comics. A year later Castelli started writing scripts for several Italian comic books, including Pedrito el Drito and Piccola Eva published by Universo, Cucciolo and Tiramolla for Edizioni Alpe, and Topolino for Mondadori.

Castelli then expanded into television, writing several advertisements as well as the series Cappuccetto a Pois with Maria Perego and the screenplay for the movie Il tunnel sotto il mondo. In 1969 he contributed to the humor magazine Tilt. A year later, together with Pier Carpi, Castelli created Horror magazine, in which he published his strip Zio Boris. He then joined the staff of Il Corriere dei Ragazzi as editor/artist/writer. For this magazine he created L'Ombra, a personal take on The Invisible Man drawn by Ferdinando Tacconi; Gli Aristocratici, a group of gentlemen thieves, again with art by Tacconi; Otto Kruntz, a mad scientist drawn by Daniele Faragazzi; and L'Omino Bufo, an absurdist humor strip that Castelli drew himself.

In 1978 Castelli wrote for Supergulp magazine the adventures of Allan Quatermain, an explorer specializing in archaeological mysteries that foreshadowed Castelli's most famous creation.

In the same year Castelli began his cooperation with publisher Sergio Bonelli, writing stories for Zagor and Mister No. Two years later, he submitted the idea for a new series to Bonelli based on a New York researcher who investigated scientific mysteries: after two years of gestation, in 1982 he created Martin Mystère. The series, initially drawn by Giancarlo Alessandrini, marked a turning point in Italian popular comics history, introducing modern and sophisticated themes in a market dominated by traditional adventures aimed at a younger audience. Martin Mystère opened the door to many other new course characters, both from Bonelli and other publishers.

In 1983 Castelli and Guido "Silver" Silvestri resurrected Eureka magazine. However, it folded after only 12 issues. In 1992 Castelli launched the new series Zona X, a spin-off of Martin Mystère, that ran until 1999.

Castelli also wrote a book on the first 25 years of American newspaper comics (1895–1919), entitled Eccoci ancora qui.