Redshirts by John Scalzi
The new crew members of the Intrepid realize there's something funny going on with away missions: someone always dies, but never any of three bridge officers, one of whom frequently gets severely injured. They meet someone who tells them about the Narrative, and his theory is that there is a TV show out there using their ship as a focus of its plot, like that old show Star Trek.
This is a humorous (though I rarely laughed out loud or did more than quirk my lips in an "I see what you did there") look at the tropes of science fiction TV shows like ST. It is extremely meta, and parts of it dive into philosophy. It's fun--I liked The Box and the officer tracking system--and fairly light-hearted.
The scheme Dahl comes up with to get the Narrative to stop taking over and killing off random people was clever, though I had trouble following the logic of it. That may have been purposeful, because it was extremely convoluted logic based on meta and plot.
Scalzi also uses the tale to criticize lazy writing, like killing a crew member simply to increase dramatic tension or "raise the stakes." This is explicitly addressed in the first coda. Like, "I have been a lazy writer all this time." Very explicit, very meta.
I was only sort of the intended audience for this book. I've seen a lot of Star Trek episodes, mostly TNG, but I've never really been a fan, and I don't watch a lot of TV. (Though I watch anime a lot, and they also have some of the same lazy writing problems.) I caught a lot of the jokes, but probably not all of them. I recognized many or most of the tropes he was poking at.
I enjoyed it on the whole, but I think someone who is more of a Star Trek fan than I would enjoy it more.