What level of knowledge and expertise is usually expected from someone just entering a PhD in computer science? If someone has bad grades and limited programming experience, can they afford to rely on their first year of coursework to come up to speed with the field? Or is it a better idea to take some time off before starting your PhD and improve your skills?
This is phrased as a question about first-year coursework, but it's actually a question about admissions.  Specifically, a department won't offer admission to someone they feel has inadequate preparation, so this situation should not arise (assuming the admissions process works well).

From this perspective, the reformulated question is: if you have bad grades and limited programming experience, is admission to a CS PhD program still possible, or do you need to take some time off to improve your skills?

At this level of detail, there's no way to say for sure.  If your application shows nothing but bad grades and lack of programming experience, then admission is presumably out of the question.  On the other hand, why would you even want to enter a PhD program without some other background that indicates it's a good idea?  In which case the admissions decision comes down to what that background is and whether it outweighs the grades and programming experience.  It would take something impressive, but it's possible in principle.