Simple way to add a class to the body when creating/editing an entity In Drupal 8.4, I am trying to add a class to the body (like Drupal 7 had) when the page viewed is a node (or entity for that matter), something like [entity]-[create or edit], so that, when a user is editing or creating a node, a class like page-node-edit gets added to the body classes array.
You can use hook_preprocess_page and check the current route:

function mymodule_preprocess_page(&amp;$vars) {

  $route_name = \Drupal::routeMatch()-&gt;getRouteName();

  // This would add a class based on the route.  You'd need the 
  // pathauto module enabled.
  $vars['page_classes'][] = \Drupal::service('pathauto.alias_cleaner')-&gt;cleanString($route_name);

  // This would add the classes asked for in the question.
  if ($route_name == 'entity.node.edit_form') {
    $vars['page_classes'][] = 'entity-edit';
  }
  elseif ($route_name == 'node.add') {
    $vars['page_classes'][] = 'entity-create';
  }
}