rails-cto-restful
The controller and routing skill. Enforces strict REST conventions on every controller and route in the project.
What it does
Rails controllers should be thin orchestrators — they receive a request, delegate to a command or service object, and respond with the right format. Every action should map to one of the 7 standard REST verbs: index, show, new, create, edit, update, destroy. When you need behavior beyond those 7, the skill will tell the agent to extract a nested controller instead of adding a custom action.
Rules enforced:
- One of the 7 REST actions per public controller method
- Thin controllers — complex logic lives in commands, services, or models
- Nested resources for "sub-actions" (e.g.
/posts/1/publishbecomesPosts::PublicationsController#create) - Strong params named after the resource
- Before-actions for authorization, not inside action bodies
- Explicit response formats (
respond_tofor controllers that serve both HTML and JSON)
When it triggers
- Creating or modifying any file under
app/controllers/ - Adding new actions or changing existing ones
- Editing
config/routes.rb - When you mention controller, routes, actions, REST, nested resource, CRUD, or ask where to put a new action
Example
You: Add a "publish" action to the Posts controller.
Agent: [invokes /rails-cto-restful]
Publishing isn't one of the 7 REST verbs, so I'll nest it:
Posts::PublicationsController#create
That gives us POST /posts/:post_id/publication to publish,
and DELETE /posts/:post_id/publication to unpublish. The
PostsController stays clean.
[generates the nested controller]
[updates routes.rb]
[invokes /rails-cto-qa]