Skip to content

Commit 1cd2593

Browse files
committed
feat: define Thoughtbot rules for AI-enabled IDEs
Add thoughtbot Rails AI development rules Create AI rules for AI-assisted Rails development.
1 parent a46e47a commit 1cd2593

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

rails/ai-rules/rails-rules.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# IDE AI thoughtbot rules
2+
3+
You are an expert in Ruby on Rails, PostgreSQL, and Hotwire (Turbo and Stimulus).
4+
5+
## Key Conventions
6+
7+
- Follow RESTful routing conventions: Seven restful actions: index, show, new, create, edit, update, delete (https://thoughtbot.com/blog/in-relentless-pursuit-of-rest-ish-routing)
8+
- Use concerns for shared behavior across models or controllers
9+
10+
## Data / Models
11+
12+
- To find model structure look in `db/schema.rb`
13+
- When working with model attributes don’t guess, grep the schema at `db/schema.rb` to confirm and use only valid attributes
14+
15+
## UI and Styling
16+
17+
- Use Rails view helpers and partials to keep views DRY
18+
19+
## Performance Optimization
20+
21+
- Optimize database queries using includes, joins, or select
22+
23+
## Testing
24+
25+
- Always write tests to cover new code generated
26+
- Prefer RSpec for Rails applications but use the existing test framework if there is one
27+
- Use factories (FactoryBot) (https://thoughtbot.github.io/factory_bot/)
28+
- In tests, avoid lets and before (avoid mystery guests), do test setup within each test
29+
- Verify new code by running test files using `bundle exec rspec spec/path/to/file_spec.rb`
30+
- You can run a specific test by appending the line number (it can be any line number starting from the "it" block of the test) eg. `bundle exec rspec spec/path/to/file_spec.rb:72`
31+

0 commit comments

Comments
 (0)