You just need a proper .cursorrules file and you have solved 9 out of 10 issues like it uses TurboStream and your styling framework by default. Also if you use a thinking model like openai-03 of claude 3.7 thinking, it will think through the consequences of one change and update multiple files. Your issues are due to settings rather than mistakes the model / software makes.
Here is my .cursorrules, feel free to edit it, include it in your project and try again (and use the cursor extension of VScode).
You are an expert in Ruby on Rails 7, Hotwire (Turbo and Stimulus), and Twitter Bootstrap 5.
Code Style and Structure - Write concise, idiomatic Ruby code with accurate examples. - Follow Rails conventions and best practices. - Use object-oriented and functional programming patterns as appropriate. - Prefer iteration and modularization over code duplication. - Use descriptive variable and method names (e.g., user_signed_in?, calculate_total). - Structure files according to Rails conventions (MVC, concerns, helpers, etc.). - Prevent using gems that are not necessary. For API calls use net/http or open-uri. - Do not delete functional code while adding and deleting the features.
Naming Conventions - Use snake_case for file names, method names, and variables. - Use CamelCase for class and module names. - Follow Rails naming conventions for models, controllers, and views.
Ruby and Rails Usage - Use Ruby 3.x features when appropriate (e.g., pattern matching, endless methods). - Leverage Rails' built-in helpers and methods. - Use ActiveRecord effectively for database operations.
Syntax and Formatting - Follow the Ruby Style Guide (https://rubystyle.guide/) - Use Ruby's expressive syntax (e.g., unless, ||=, &.) - Prefer single quotes for strings unless interpolation is needed.
Error Handling and Validation - Use exceptions for exceptional cases, not for control flow. - Implement proper error logging and user-friendly messages. - Use ActiveModel validations in models. - Handle errors gracefully in controllers and display appropriate flash messages.
UI and Styling - Use Hotwire (Turbo and Stimulus) for dynamic, SPA-like interactions. - Implement responsive design with Twitter Bootstrap 5. - Use Rails view helpers and partials to keep views DRY. - Use glypicons for icons where possible.
Performance Optimization - Use database indexing effectively. - Use eager loading to avoid N+1 queries. - Optimize database queries using includes, joins, or select.
Key Conventions - Follow RESTful routing conventions. - Use concerns for shared behavior across models or controllers. - Implement service objects for complex business logic. - Use background jobs (e.g., Sidekiq) for time-consuming tasks.
Security - Implement proper authentication and authorization (e.g., Devise, Pundit). - Use strong parameters in controllers. - Protect against common web vulnerabilities (XSS, CSRF, SQL injection). - Avoid deprecated npm packages (discard anything not updated in the last two years).
Follow the official Ruby on Rails guides for best practices in routing, controllers, models, views, and other Rails components.
Absolutely! There are definitely ways to help the agent produce different results. My main concern isn’t with the model’s results, but with the “vibe coding” itself. There have been countless stories where people have “vibe coded” an app only for it to be hacked, sensitive keys leaked, or heavy API usage due to lack of optimizations. Using an AI agent isn’t necessarily a bad idea, but realistically, someone who doesn’t understand coding probably won’t be setting up rules or MCP servers either. So, in this example, it was the right decision to not have any rules and just use what came out of the box.
Yes I saw the tag of "april-fools", I just wanted to get it out there (that the tech works). If you do a tutorial with a correct setup it is pretty interesting. Maybe not for million dollar back-end apps but for people with small projects, MVP or side projects it's very interesting.
For sure! AI assisted development can be very powerful. It should not, at least in its current states, replace anyone's development jobs. Even scaling back teams due to AI is a mistake unless those teams were already overpopulated from an over-hiring effort. And to your point,... this would not be vibe coding. If we critique and modify the code that is being generated, regardless of how much code it is, we're outside the scope of vibe coding and now in assisted coding. How much assistance the agent provides is a different discussion too. If we rely on the agent to do most/all of the coding and we simply just tweak it, we're going to be heading down a bad path of messy code that will be more expensive to maintain down the road. I don't think that there's a magic percentage of how much generated code is acceptable either. Nor, the implications of where did it get the knowledge to generate that code and who truly owns it.
Playing Devil's advocate, could you not then tell the agent to use TurboStream instead of a channel and still keep code vibing? - you can also ask it to run Robocop after every edit, which works pretty well. Also try roo-code, it's more customisable and seems to work better, you can also swap out the models, Gemini 2.5 is pretty good, so is o3-mini-high and claude 3.7 - you're definitely using the wrong model. Plus writing specs is what vibe coding is best at! - you just tell it write a spec for the code it just added and more often than not it does a good job.
Absolutely, but I took the approach that has been seen on social media where non-technical people have been using "vibe coding" to create SaaS applications. In that context, they wouldn't know to use TurboStreams and they also may not know the difference between different models if it is producing the results. Claude 3.7 definitely churns out some pretty cool stuff. I haven't looked in to Gemini 2.5 yet.
Ha. That was awesome, David! I spent a full day last week trying to generate workable Swift code for a native component in Hotwire...after spending most of that day climbing the learning curve to understand why the compiler kept complaining, I just threw it all out and wrote it myself having learned what I was trying not to ;-). All that said, I have an ex student who's building a company around using LLMs to generate code. He's using Rails as the framework because the generators already do a ton of heavy lifting. Call me a skeptic for now, but we'll see where things go.
Here is my .cursorrules, feel free to edit it, include it in your project and try again (and use the cursor extension of VScode).