Comprehensive quantification of >200,000 energetic interactions between a PDZ domain and its disordered ligand reveals that binding specificity is encoded through six spatially clustered, largely independent modules of 17 residues that control recognition of different ligand positions via both direct contacts and local allostery, with dynamic ligand residues contributing additively to affinity and communicating with structured regions to enable specificity changes, thereby allowing quantitative reprogramming of the domain to recognize completely redesigned ligands through predictable combination of mutations in each specificity module.