A new thiophene derivative corrosion inhibitor (CI) was developed to functionalize the layered double hydroxide (LDH) primer on Mg alloy to enhance corrosion protection. Compared with bare LDH coating, the composite coatings consisting of a MgAl-LDH primer and an outer CI layer showed highly compact surface structures without large pores and gaps, thereby indicating the enhanced capability to resist the penetration of corrosive species. Electrochemical tests revealed that the MgAl-LDH film modified with the newly synthesized CI exhibited higher charge transfer resistance and lower corrosion current density than films modified with commercial CIs. The highest enhancement in corrosion resistance was linked to the film's ability to repair phys...