A Heart Full of Headstones is the 24th installment in the Inspector Rebus series written by Ian Rankin. The title comes from the song "Single Father" by Jackie Leven, four lines of which are quoted on the last page of the novel. The novel is set during the period when COVID-19 is a threat but lockdown has ended, probably in 2022. 
 The novel is framed by a prologue and epilogue both titled simply "Now." In these, John Rebus is on trial for a crime he commits at the end of "Then,"  the main narrative (divided into 8 days), which takes place not long before.
 In this novel, Rebus, retired since 2007, DI Siobhan Clarke, and DCI Malcolm Fox all pursue their own investigations, though the cases come together around a policeman named Francis Haggard, stationed at Tynecastle in Edinburgh. The three of them frequently exchange information or ask each other for help. Clarke is at first working on the criminal aspect of Haggard's domestic abuse of his wife, which has resulted in their separation; Clarke interviews Haggard and also the wife, Cheryl, and her sister Stephanie Pelham, who has taken Cheryl in. Haggard is threatening to reveal the police corruption at Tynecastle unless the case is dropped. Then Haggard is murdered and Police Scotland sets up a Major Inquiry Team (MIT) which includes both Clarke and Fox. 
 Fox, in his time in Internal Affairs (the "Complaints"), a few years earlier, had wanted badly to convict one Tynecastle cop, Sergeant Alan Fleck, now retired; in Fleck's day, Rebus had helped Fleck, giving him tips and setting up a meeting with the gangster 'Big Ger' Cafferty. Thus Fox's concerns push Rebus to recall how he tried both to fit in and to keep his integrity when dealing with Tynecastle. On the MIT, Fox represents the official concern with the old cases that Haggard, but also Fleck, are bringing up. Fox also represents other interests of Gartcosh, the administrative campus of Police Scotland, including possible links with smuggling of cars for Fleck's dealership and of drugs.
 Rebus, meanwhile, has been assigned by 'Big Ger' Cafferty, whose criminal empire has crumbled, to look for a man named Jack Oram, supposedly so that Cafferty can apologize to him. This turns out to be a careful ploy to get Rebus to stir up trouble for the Mackenzie family: Fraser and Beth (an old flame of Cafferty's) and their daughter Gaby, who owns a nightclub. They have taken over some of Cafferty's old businesses, including apartment rentals and drugs. Haggard was killed in an apartment rented to him by the Mackenzies, so they are also coming to the attention of the MIT. Jack Oram's son Tommy is working for the Mackenzies, and Rebus becomes somewhat friendly with him. Rebus pursues the various leads he turns up, though he doubts Jack Oram is still alive and he is more interested in what Cafferty is trying to accomplish.  
 Clarke and Fox, along with the rest of the MIT, gradually trace Haggard's last day, using phone records, CCTV footage, and file boxes full of old investigations of the Tynecastle police station. Clarke is successful in identifying the murderer, and Fox informally promises her a promotion to DCI. Rebus, however, tries to pursue his investigation with a crowbar, and it does not end well.
 Rankin has said that the story was inspired by several instances of police violence or misbehaviour, such as the 2021 murder of Sarah Everard, rousing him to devise a plot in which "Rebus is trying to clear his name as a bad cop, but Rebus is a bad cop," that is, he is part of the culture that produces bad cops. This is not the first novel where Rebus has an opportunity to think with regret about situations where he made mistakes; he recalls difficult past cases in Black and Blue (1997), Resurrection Men (2002), and Saints of the Shadow Bible (2013). As in those novels, Rebus both fears exposure of past misdeeds and examines his own motives at the time, trying to ascertain whether, in breaking the rules, he also crossed the moral lines he had drawn for himself. In this case, though, he is looking back specifically at situations in which Big Ger Cafferty manipulated him—when he was seen, as he still is by many, as the gangster's puppet. 
 While Malcolm Fox keeps his conscience clean by obeying the rules, Siobhan Clarke understands that Rebus's rule-breaking is usually in the interests of justice. As a woman, she could never be part of the privileged fraternity of old-fashioned policing, herself, but she accepts that sometimes the methods can be used to good ends. She is dismayed and skeptical when Francis Haggard claims that his wife-beating was a result of PTSD, caused by his years as a policeman and his participation in the culture of corruption—bullying, violence, and misogyny—at Tynecastle station.
 Stuart Kelly in The Scotsman comments that "Rebus in a strange way is Edinburgh's guilty conscience, aware of horrors, attempting to do right. Moreover, the gap between injustices and crimes is put into clear light here." Mark Sanderson in The Times calls it "a great crime novel with moral heft."  Joan Smith, of The Sunday Times, says that it is "a superb novel that appears to have reinvigorated the author and his creation."