What is the right style to name a cookbook?

I am not sure where to report this issue, if there is a better place, please tell me. =)

I was reading the Chef Style Guide, and found this paragraph:

Cookbook Naming
Avoid dashes in cookbook names. This is because many custom resources use the cookbook name as part of the resource name, so the method names themselves can become awkward, but also - cannot be part of a symbol in Ruby and the presence of dashes in cookbook names may trigger undesired errors later on in the process.

However, dashes are frequently used in chef offcial cookbooks, here.

It makes me feel a bit confused. Are those cookbooks named by mistake or design? I am wondering which pattern I should follow?


If you have no pressing reason to keep your own style, use underscore-separated, lowercase names. There is some handling for hyphens but there are still a few gotchas that can be confusing to new users so we recommend just not bothering.

Some features in chef auto magically converts/creates methods/classes based on file/directory names. Since in ruby - is not a valid character, _ is preferred. Few examples

  1. LWRP names. They are constructed from cookbook + _ + file name. So , if cookbook name is foo and resource/provider file name is bar, resulting lwrp can be consumed as foo_bar. This gets confusing if the parent cookbook has -.
  2. Attribute names. Chef stores attributes as Mash, which allows accessing them as normal hash construct (node[‘foo’][‘bar’][‘baz’]) or via method chaining (node.foo.bar.baz). Its a common convention to keep the attribute namespace same as the cookbook name. Following this convention, - in cookbook name makes it harder to access attributes by method chaining style.