The 1st place that dirt get into the compressor is via the intake. To prevent dirt from getting inside is to install a appropriate size air filters.
Some typical use air compressor filter elements.
They are made of filter grade filter paper.
Filter maintenance 1
Remove of filter dust trapped at cover through centrifugal flow of air inside the filter housing.
Low air pressure jet to clean air filter
Choke up air filter
Air filter need to replace.