We came up with convinient Rails generators to create new engines and local gems. You can use them as an example (they are too opinionated for general use).
Copy the contents of the generators/
folder to you lib/generators
to add them to your app.
That would add two generators:
rails g engine <name>
rails g gem <name>
.