The primary literary device at work in the poem is the situational irony that is realized in its conclusion. How ironic that Richard Cory, the one man in town who seemed to have everything necessary for happiness and the one man who was envied above all others, is the one who takes his own life in a shocking and violent way.
Another literary device employed is that of hyperbole: Cory is so well dressed and attractive, he "glitters" when he walks in town. Metaphor is found in the first two lines of the final stanza:
So on we worked, and waited for the light,
And went without the meat, and cursed the bread;
The "light" for which the common people wait could be interpreted as relief from poverty. Going "without the meat" metaphorically means doing without the better things in life, those things that poor people in the town cannot enjoy. Cursing "the bread" is a metaphor for their resentment, for being discontented with their poverty.
Finally, the poem employs a first-person narrator who is one of the poor in the town who admires Cory, and there is a strong contrast in the last two lines between the "calm summer night" and Cory's violent death as he "put a bullet through his head."