A Roman à Clef is a novel with a key, a fictional story by a writer with real people and events fictionalized in a blatant Serial Numbers Filed Off manner. The novel is supposed to serve as a key, a guidebook to understanding some real people with allusions and references to make people guess the real person.
Well two can play that game. You see for most people, the work of the artist is all they know and care about that artist. In some cases, it's all that they will know about that artist, especially if they are Reclusive Artist or if they lived in a time where way too little is knowable about him or her. If people decide to tell the story of that artist's life, they are going to find a way to shoehorn, in some way or form, aspects of his creations into that biography, which ends up making it a metafictional Origins Episode, or in some cases provide Futureshadowing. All biographical works of famous people take Artistic License History and other creative liberties as a given. Different incidents are merged or cut for smoother narrative flow. This happens even when the subject in question has life that is full of excitement, whether its the lives of famous kings, soldiers, lawyers, politicians and other historical worthies. Unlike other biographical subjects, the artist by nature doesn't usually have an exciting life. If he's a poet, a painter, a sculptor, a musician and had a long and successful career, most of that involved thinking in rooms, working hard in a corner, maybe doing some acts of recreation. It's not inherently a very dramatic life. Of course some artists do have exciting and very dramatic lives (Vincent van Gogh for instance) but most artists don't. Their works might be very famous and well known and be adapted in turn but nobody would think that their lives were interesting enough to support a biography. But because the artist is well known, someone decides to make a biographical work anyway and this leaves writers and producers scratching their heads how to make it work.
One way to do it is mix the artist's life with their fiction. Arthur Conan Doyle wrote Detective Fiction, so have him investigate real murders and more or less play Sherlock Holmes. Here's Charles Dickens having a terrible childhood like Oliver Twist, having his pocket picked by The Artful Dodger, or an Expy of him, who makes Dickens think I Should Write a Book About This. Works using this trope vary from being sly and playful, to straight drama to outright Meta Fiction. While examples of this trope do exist in earlier times, it certainly took off big time in the 20th Century, where psychology and other ideas made many people try and analyse works of art as an expression of the artist's personality. Biography à Clef more or less makes that subtext literal.
Overlaps with Sidelong Glance Biopic, Roman à Clef, And You Were There, Artistic License History, Beethoven Was an Alien Spy. Not to be confused with metafictional works or self-reflexive stories where artists deliberately insert a fictional version of themselves into the work (that's Literary Agent Hypothesis), or with Creator Cameo, or Self-Insert Fic. Marginally fictionalized Biopic like Amadeus does not fit because there the reality is fictionalized as opposed to Mozart's own creations shown interacting and influencing the author along the way.
- Alan Moore's Providence is a Sidelong Glance Biopic of H.P. Lovecraft where his many fictional creations (The Church of Starry Wisdom, the Old Ones, Nyarlathothep) are not only presented as real, but as The Man Behind the Man of Lovecraft's own life, covertly influencing him towards creating his famous works, which they see as a prophecy to bring about the Apocalypse.
- Neil Gaiman's Shakespeare episodes in The Sandman features this trope. In the first case, he has Shakespeare present a unique theater production of A Midsummer Night's Dream to The Fair Folk which actually inspired that play, which is here presented as a commission to Shakespeare's company from Morpheus to impress Titania. Earlier folkloric versions of Titania and Puck comment on their fictional representations in Shakespeare's play.
- George Lucas in Love show the young filmmaker finding inspiration all around in creating the Star Wars trilogy, not the least from a beautiful girl with a familiar hairstyle...who turns out to be his long-lost sister.
- Hammett by Wim Wenders (produced by Francis Ford Coppola) has the author of modern detective fiction as a private eye navigating a complex Film Noir plot. Unusual example because Dashiell Hammett really was a Pinkerton detective before he was a novelist but the film is obviously metafictional with Hammett as a Sam Spade type. The cast is also filled with supporting actors from old Film Noir, including Elisha Cook, Jr. (the "gunsel" from John Huston's adaptation of The Maltese Falcon).
- Shakespeare in Love is perhaps the Trope Codifier for mainstream audiences. It directly led to a slew of imitators, and it has William Shakespeare having writer's block, which he fixes when he enters into a Star-Crossed Lovers with Viola, a Sweet Polly Oliver who dresses as an actor and appears in one of his plays. This gives him the experience he needs to make Romeo and Juliet and directly inspiring Twelfth Night.
- Moliere is a 2007 French film patterned on Shakespeare in Love. It mixes Molière's life with that of his fiction, shown as an attempt at Method Acting on the part of the author.
- Kafka by Steven Soderbergh starring Jeremy Irons shows the author as an Unlucky Everydude navigating an absurd system with many characters and tropes drawn from his short stories and novels present as biographical experiences.
- Naked Lunch is about William S. Burroughs shooting his wife and traveling to Interzone on the orders of insects that talk out of their asses. David Cronenberg didn't even attempt to faithfully translate the even more bizarre book to the screen (a virtual impossibility), instead opting to make it an amalgam of Burroughs' work and life.
- Anthony Burgess' Nothing Like the Sun fictionalizes a relationship between Shakespeare and the West-Indian prostitute Lucy Negra, under the theory that the latter is the "Dark Lady" of Shakespeare's famous sonnets, including the famous one that gives the novel its title.
- J. M. Coetzee's The Master of Petersburg features Fyodor Dostoevsky as the hero investigating a conspiracy reeling over the death of his son Pavel, and manipulated by the real-life Sergei Nechayev a la Hannibal Lecter/Clarice. An unusual example in that these are all real-life figures but fictionalized by the author (Pavel did not die, he outlived Dostoevskynote , and Dostoevsky only attended Nechayev's trial and not interview him personally) but it's presented in a fictionalized manner to dramatize how Dostoevsky wrote Demons.
- Vladimir Nabokov was especially contemptuous of tropes of this nature. His novel Pale Fire parodies this mentality via the famous footnotes where the scholar asserts that the fictional poet John Shade based the poem on himself and that his adventurous and surprisingly swashbuckling life is reflected in the poem, and more or less goes mad as the story goes along.
- Doctor Who: "The Shakespeare Code" has William Shakespeare encounter three Carrionites, beings who resemble traditional witches. The story also features the Doctor making various Shakespeare quotes which Shakespeare hasn't written yet. This is inverted when the Doctor quotes Henry V and Shakespeare says he likes that... before realizing its one of his.
- Jacques Offenbach's The Tales of Hoffmann is a famous pre-20th Century version. It presents E. T. A. Hoffmann himself narrating stories from his life, all of them adapted from his own tales The Sandman, Rath Krespell, A New Year Eve's Adventure, but presented as life experiences that he will eventually use to write his fiction.
- Assassin's Creed features this trope when it depicts artists as Historical-Domain Character.
- In Assassin's Creed II and Assassin's Creed: Brotherhood, it presents Leonardo da Vinci's famous drawings and plans of a flying machine/tank/aircraft/machine gun as functional prototypes for war machines that he built for Cesare Borgia. His genius and interest in codes and numbers also shows up in The Da Vinci Disappearance where he's kidnapped by a cult of Hermeticists who are seeking a Pythagorean Temple.
- In the same games, Niccolò Machiavelli is shown getting the inspiration for his ideas about his political philosophy in The Prince by observing the Player Character lead by love and respect and undermine the Borgia who rule entirely by tyranny.
- Assassin's Creed: Syndicate has the "Dreadful Crimes DLC" where little Artie is a supporting character to a Penny Dreadful writer Henry Raymond who engages the player character to solve a series of riddles using deduction and logic. At the end of the adventure little Artie turns out to be a Young Future Famous People version of Arthur Conan Doyle who in the course of the side-missions has met the inspirations for Moriarty and Holmes.
- Metal Fish, an episode of The Little Mermaid has Ariel rescuing a human travelling on a primitive submarine and getting him to land. Said man turns out to be none other than Hans Christian Andersen, the author of the original story which inspired the Disney cartoon. The final scene of the episode has the survivor narrating this story to Danish children.