1 Samuel 21:13

And he changed his behaviour before them, and feigned himself mad in their hands, and scrabbled on the doors of the gate, and let his spittle fall down upon his beard.

Cross-reference

Psalm 34:1 Historical context

Psalm 34:1 praises God continually — a response of thanksgiving after David's feigned madness saved him.

Proverbs 29:25 warns that fear of man is a snare — exactly what David experienced and acted on here.