לַמְנַצֵּ֥חַ בִּנְגִינֹ֗ת מַשְׂכִּ֥יל לְדָוִֽד׃
Midrash Tehillim
To the chief musician, with instrumental music. When the wicked came against [David] to seize him. This refers to what is written in (Proverbs 29:12), "If a ruler listens to lies, all his officials become wicked." When Saul's followers saw that he was inclined to listen to slanderous words about David, they immediately came to him and said, "Who is David? Who is the son of Jesse?" (Shmuel Aleph 25:10) Similarly, when Doeg the Edomite came, and when the Ziphites came to Saul and reported on David's whereabouts, they did so with the intention of causing harm to David.
Midrash Tehillim
"A Psalm of David, when he was in the wilderness of Judah." This is the one that the scripture says (Isaiah 26:16), "Lord, in trouble have they visited thee, they poured out a prayer when thy chastening was upon them." When do the Israelites seek the Lord? When they are in distress, as it says (Psalms 18:7), "In my distress, I called upon the Lord." When they are in trouble, they seek the Lord, as it says (Psalms 3:1), "A Psalm of David, when he fled from Absalom his son." And it says (Psalms 142:1), "A prayer of David, when he was in the cave." And it says (Psalms 54:1), "A Psalm of David, when the Ziphims came and said to Saul, Doth not David hide himself with us?" And it says (Psalms 57:1), "A Michtam of David, when he fled from Saul in the cave." And likewise, here when he was in the wilderness of Judah. And it also says (Psalms 18:7), "In my distress, I called upon the Lord, and cried unto my God: he heard my voice out of his temple, and my cry came before him, even into his ears." And it says (Psalms 118:5), "I called upon the Lord in distress: the Lord answered me, and set me in a large place." Therefore, it is said in the wilderness of Judah....