The noun клепка means "one of the convex staves, planks of which a barrel, a cask is made" and the Ukrainian Language Dictionary in 11 volumes lists several idioms of the same meaning, "to be foolish, out of one's mind", they all have the remark зневажл[иве], "derogatory":
Клепки розсохлись - "[somebody's] staves have cracked from dryness"
Клепку загубити - "to loose a stave"
Немає (не вистачає, бракує) однієї (третьої, десятої і т. ін.) клепки [в голові] - "[somebody] lacks one (the third, the tenth, etc.) stave [in the head]"
And one more:
- Клепку вставляти (вставити) - "to insert a stave [into somebody's head]" - "to edify somebody, to give a lesson to somebody". This last idiom has the "ironic" remark.
So, if you say that to a person you barely know, it can be taken as an offense, but while talking with friends and said jokingly, it will be taken with a smile. Still, those idioms are about somebody's mental abilities, so use them reasonably. ))