rails-controller_skill

This skill helps you scaffold Rails controllers using a TDD workflow, writing red specs first and delivering fully tested actions.

269

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill thibautbaissac/rails_ai_agents --skill rails-controller

  • SKILL.md5.6 KB

Overview

This skill creates Rails controllers using a test-driven workflow: write a failing request spec first, implement the controller, then make the spec pass. It follows project conventions like Pundit for authorization, Pagy for pagination, presenters for view formatting, multi-tenancy via current_account, and Turbo Stream responses for dynamic updates.

How this skill works

I generate a request spec under spec/requests to define expected behavior and multi-tenant isolation. After you run the spec and see RED, I scaffold the controller actions with authorize calls, policy_scope queries, strong params, presenter wrapping, and Turbo Stream responses where applicable. Run the specs again to confirm GREEN, then refactor while keeping tests passing.

When to use it

  • Adding a new controller or resource-backed CRUD endpoints
  • Implementing or changing controller actions for existing resources
  • Creating API endpoints that require multi-tenant scoping and authorization
  • When you want strict TDD: request spec first, implementation next
  • Converting views to Turbo Stream responses for dynamic updates

Best practices

  • Write the request spec first and confirm it fails before coding (RED)
  • Always use policy_scope for queries and authorize every resource/action
  • Ensure created records are assigned to current_account for multi-tenancy
  • Wrap models in presenters for view formatting instead of placing logic in controllers
  • Use Pagy for pagination and return Turbo Stream responses for progressive UX

Example use cases

  • Create a PostsController: spec/requests/posts_spec.rb then implement index, show, create, update, destroy
  • Add an admin namespaced controller under app/controllers/settings/accounts_controller.rb with current_account
  • Implement a create action that returns html and turbo_stream formats with pagy re-rendering
  • Fix an authorization bug: add tests expecting 404 for resources outside current_account
  • Add strong params and presenters while keeping request specs green

FAQ

Yes. The workflow relies on writing a failing request spec to drive the controller implementation.

How are unauthorized accesses handled?

Tests should assert a 404 for resources outside current_account; controllers must use policy_scope to limit finds and authorize on each action.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational