Overriding menu.html.twig just for the primary menu Drupal 8 Beta 1 has a lot of nice templates to use which can be brought into a custom theme and then customized. I brought in core's menu.html.twig into my custom theme and indeed I can customize markup in there. However, this template overrides all Drupal menus, not just the primary menu which is the one I want to override. 

I tried the Devel module for Drupal 8 figuring I might get some insight about what's going on under the hood. However, the module still looks like it's in a state of flux and I got massive errors. My goto module for template suggestions for Drupal 7 is Devel Themer (Theme Developer) but alas no Drupal 8 version. 

I also tried getting specific with the template name and tried menu--primary.html.twig but that did not work either. 

I then tried within the template wrapping an if around the part that I want to modify as such:

{% if primary_menu %}
   &lt;ul{{ attributes.addClass('foobar-menu') }}&gt;
{% endif %}


... but no joy there either. so I am out of ideas on how to do this.
Answering my own question here, this will probably be useful for those looking to debug twig. 


Activate devel Kint (part of the Devel module) on the modules page or with Drush
In your site /sites/default/services.yml change the following settings:

parameters:
  twig.config:
    debug: true
cache: false
auto_reload: true
Then in the template you want to debug, place this code in it:

{{ kint() }}


Now you get a nice tree of variables that prints out similar to what you would get if you did an old style kpr(get_defined_vars()); in Drupal 7. 




I see from the debug printout that the name of the menu is simply main.
Now I change the overridden template in my custom theme's template folder to menu--main.html.twig
Voila, the template is only specific for the primary main menu now
Customize as a themer to your hearts content.
Throughout this process, don't forget to clear cache and change / remove any debug code when you are done.


In addition to this, with debugging active, Chrome prints out possible template suggestions a la devel_themer so you don't necessarily have to use Kint.