How do clean_class and clean_id work?
clean_class is a filter which invokes the \Drupal\Component\Utility\Html::getClass() method on the string, which:


  Prepares a string for use as a valid class name.


Basically it removes invalid characters from HTML classes in preparation for rendering. clean_id is the equivalent for HTML IDs.

There are other filters registered by core too, see TwigExtension::getFilters for more details.