After Bart's latest act of vandalism on the Springfield Elementary Puma statue lands him in trouble, Principal Skinner decides to deal with him and the rest of the school's troublemakers by taking them to "Scared Spitless", which is held in Springfield State Prison and is intended to scare kids into shaping up. Bart, Nelson, Jimbo, Dolph, Kearney, and Milhouse attend a seminar hosted by Snake as he explains what prison life is like. then Chief Wiggum decides that all the kids attending the seminar should spend an hour in an actual prison cell. As Bart and Milhouse are placed in a cell, a very familiar inmate approaches it... Sideshow Bob.
Desperate to avoid being caught and killed by his longtime enemy, Bart climbs through the bars and into a van, which ends up in a prison workcamp. The supervisor assumes that Bart is an extra inmate and has him chained up next to Bob, and the two of them are made to clean the highways as part of a chaingang. Eventually, Bob makes a break for it and escapes on a passing train, with Bart still attached to his chain.
Now free of the workcamp, Bob prepares to kill Bart, but is stopped when Bart points out that Bob will be too slowed down from having to carry his corpse. Postponing his plan to kill Bart until he can break the chain, Bob walks through the swamp with Bart until they reach a hardware store. However, Chief Wiggum is inside the store as he locked his keys in the poilce car and needs it opened, so Bob disguises himself by putting on a Krusty hat (much to his disgust) and enters the store to obtain a hacksaw. Fortunately, his plan is foiled when Bart uses a vacuum cleaner to yank the hat off of Bob in front of Wiggum's eyes. Bob is arrested again, Wiggum apologizes to Bart for the chaingang mix-up, and all the kids go home happily... except for Milhouse, who has been forgotten about as he sits in his cell.