Use when creating, scaffolding, or refactoring a Rails engine. Covers engine types (Plain, Railtie, Engine, Mountable), namespace isolation, host-app contract definition, and recommended file structure.
84
78%
Does it follow best practices?
Impact
91%
1.49xAverage score across 3 eval scenarios
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./rails-engine-author/SKILL.mdUse this skill when the task is to create, scaffold, or refactor a Rails engine.
Favor maintainability over cleverness. A good engine has a narrow purpose, a clear host-app integration story, and a small public API.
Keep this skill focused on structure and design. Use adjacent skills for installer details, deep test coverage, release workflow, or documentation work.
| Engine Type | When to Use |
|---|---|
| Plain gem | No Rails hooks or app directories needed; pure Ruby library |
| Railtie | Needs Rails initialization hooks but not models/controllers/routes/views |
| Engine | Needs Rails autoload paths, initializers, migrations, assets, jobs, or host integration |
| Mountable engine | Needs its own routes, controllers, views, assets, and namespace boundary |
| Mistake | Reality |
|---|---|
| Starting with mountable when plain gem suffices | Use the lightest option; mountable adds routes, controllers, views — only when you need them |
Missing isolate_namespace | Mountable and public-facing engines must isolate to avoid constant collisions with host |
| No host contract defined | Without a documented contract, integration becomes guesswork and breaks across host apps |
If the user does not specify the engine type, infer it from the requested behavior and say which type you chose.
Use the lightest option that fits:
Prefer a regular engine for shared framework behavior and a mountable engine for reusable product areas with UI.
isolate_namespace for mountable engines and public-facing engines.config.to_prepare only for reload-sensitive integration code such as decorators.Use a structure close to this:
my_engine/
lib/
my_engine.rb
my_engine/version.rb
my_engine/engine.rb
generators/
app/
controllers/
models/
jobs/
views/
config/
routes.rb
locales/
db/
migrate/
spec/ or test/
dummy/Keep the root module small:
lib/my_engine.rb: requires version, engine, and public configuration entrypoints.lib/my_engine/engine.rb: engine class, initializers, autoload/eager-load behavior, asset/config hooks.lib/my_engine/version.rb: version only.Before implementation, define:
Prefer one explicit configuration surface, for example:
MyEngine.configure do |config|
config.user_class = "User"
config.audit_events = true
endDo not scatter configuration across unrelated constants and initializers.
Use rails-engine-installers for generator-heavy setup work, rails-engine-testing for dummy-app and regression coverage, and rails-engine-reviewer for findings-first audits.
Always include tests that prove the engine works when mounted or loaded by a host app.
Minimum coverage:
Use the dummy app to verify real integration, not just isolated classes.
Minimal mountable engine class:
# lib/my_engine/engine.rb
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
config.generators do |g|
g.test_framework :rspec
g.fixture_replacement :factory_bot
end
end
endRoutes namespaced under engine:
# config/routes.rb
MyEngine::Engine.routes.draw do
root to: 'dashboard#index'
resources :widgets, only: %i[index show]
endWhen asked to create or refactor an engine:
If a real-world engine corpus is available, inspect comparable engines before making structural decisions. Prefer matching successful patterns from mature engines over inventing new conventions.
For a reusable starter layout and file stubs, read reference.md.
| Skill | When to chain |
|---|---|
| rails-engine-testing | Dummy app setup, integration tests, regression coverage |
| rails-engine-reviewer | Findings-first audits, structural review |
| rails-engine-docs | README, installation guide, host-app contract documentation |
| rails-engine-installers | Generator-heavy setup, install scripts, copy migrations |
| api-rest-collection | When the engine exposes HTTP endpoints (generate/update Postman collection) |
ae8ea63
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.