Although it is forbidden to cut one’s fingernails and toenails on Shabbat, one is permitted to remove a hanging piece of nail, which is mostly detached from the rest of the nail, if it causes him discomfort. As long as most of the piece of nail has already become detached, and the person experiences discomfort, such as if the hanging nail limits the use of his hand, or it is difficult for him to concentrate on his activities because of the nail, he may remove it. However, he must remove it with either his hand or his teeth; one may not use nail scissors to remove the hanging nail. This is the ruling of the Shulhan Aruch (Orah Haim 328:38), and of the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909), in Parashat Ki-Tisa (Year 2, 16).
The Gemara addresses the related issue of cuticles – pieces of skin around the nail that become detached. The rule established in this regard is that if the piece of skin is mostly detached, and it is "facing upward," then one may remove it on Shabbat. The Rishonim (Medieval Halachic authorities) disagree in explaining precisely what this means, and therefore the Shulhan Aruch rules that one should not remove cuticles under any circumstances on Shabbat. Since the conditions for allowing the removal of cuticles is subject to debate, we must be stringent and avoid removing cuticles under all circumstances, even if the skin is mostly detached and one experiences discomfort. However, Rabbi Moshe Halevi (Israel, 1961-2001), in his Menuhat Ahaba (vol. 12, Siman 11), writes that in such a case, where the skin is mostly detached and one experiences discomfort, he may ask a gentile to remove it for him.
Summary: One may remove on Shabbat a piece of fingernail that is already mostly detached if it causes him discomfort or distress. Cuticles may not be removed on Shabbat, though if it is mostly detached and causes distress one may ask a gentile to remove it for him.