rails_claude_skills 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
  3. data/.github/ISSUE_TEMPLATE/config.yml +11 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.yml +129 -0
  5. data/.github/ISSUE_TEMPLATE/question.yml +90 -0
  6. data/.github/dependabot.yml +19 -0
  7. data/.github/workflows/ci.yml +77 -0
  8. data/.github/workflows/release.yml +66 -0
  9. data/.rubocop.yml +52 -0
  10. data/CHANGELOG.md +94 -0
  11. data/CLAUDE.md +332 -0
  12. data/CODE_OF_CONDUCT.md +134 -0
  13. data/CONTRIBUTING.md +580 -0
  14. data/LICENSE.txt +21 -0
  15. data/README.md +544 -0
  16. data/Rakefile +8 -0
  17. data/lib/generators/claude/agent/agent_generator.rb +71 -0
  18. data/lib/generators/claude/agent/templates/agent.md.tt +62 -0
  19. data/lib/generators/claude/command/command_generator.rb +50 -0
  20. data/lib/generators/claude/command/templates/command.md.tt +28 -0
  21. data/lib/generators/claude/commands_library/create-pr.md +27 -0
  22. data/lib/generators/claude/commands_library/dbchange.md +19 -0
  23. data/lib/generators/claude/commands_library/quality.md +20 -0
  24. data/lib/generators/claude/commands_library/stimulus.md +19 -0
  25. data/lib/generators/claude/commands_library/turbo-feature.md +17 -0
  26. data/lib/generators/claude/install/install_generator.rb +211 -0
  27. data/lib/generators/claude/install/templates/README.md.tt +59 -0
  28. data/lib/generators/claude/install/templates/USAGE +28 -0
  29. data/lib/generators/claude/install/templates/agents/api-dev.md.tt +46 -0
  30. data/lib/generators/claude/install/templates/agents/fullstack-dev.md.tt +48 -0
  31. data/lib/generators/claude/install/templates/agents/rails-developer.md.tt +40 -0
  32. data/lib/generators/claude/install/templates/settings.local.json.tt +13 -0
  33. data/lib/generators/claude/rule/rule_generator.rb +175 -0
  34. data/lib/generators/claude/rule/templates/rule.md.tt +7 -0
  35. data/lib/generators/claude/rules_library/code-style.md +37 -0
  36. data/lib/generators/claude/rules_library/database.md +47 -0
  37. data/lib/generators/claude/rules_library/hotwire.md +56 -0
  38. data/lib/generators/claude/rules_library/security.md +54 -0
  39. data/lib/generators/claude/rules_library/testing.md +47 -0
  40. data/lib/generators/claude/skill/skill_generator.rb +196 -0
  41. data/lib/generators/claude/skill/templates/SKILL.md.tt +27 -0
  42. data/lib/generators/claude/skills_library/create-task-files/SKILL.md +311 -0
  43. data/lib/generators/claude/skills_library/create-task-files/templates/bug.md +60 -0
  44. data/lib/generators/claude/skills_library/create-task-files/templates/epic.md +47 -0
  45. data/lib/generators/claude/skills_library/create-task-files/templates/issue.md +45 -0
  46. data/lib/generators/claude/skills_library/create-task-files/templates/user-story.md +57 -0
  47. data/lib/generators/claude/skills_library/minitest-testing/SKILL.md +398 -0
  48. data/lib/generators/claude/skills_library/minitest-testing/references/examples.md +889 -0
  49. data/lib/generators/claude/skills_library/plan-feature/SKILL.md +253 -0
  50. data/lib/generators/claude/skills_library/rails-api-controllers/SKILL.md +1041 -0
  51. data/lib/generators/claude/skills_library/rails-api-controllers/references/api-documentation.md +422 -0
  52. data/lib/generators/claude/skills_library/rails-api-controllers/references/serialization.md +456 -0
  53. data/lib/generators/claude/skills_library/rails-auth-with-devise/SKILL.md +191 -0
  54. data/lib/generators/claude/skills_library/rails-auth-with-devise/references/advanced.md +331 -0
  55. data/lib/generators/claude/skills_library/rails-auth-with-devise/references/api-auth.md +266 -0
  56. data/lib/generators/claude/skills_library/rails-auth-with-devise/references/omniauth.md +194 -0
  57. data/lib/generators/claude/skills_library/rails-authorization-cancancan/SKILL.md +603 -0
  58. data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/api-authorization.md +543 -0
  59. data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/complex-permissions.md +572 -0
  60. data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/multi-tenancy.md +373 -0
  61. data/lib/generators/claude/skills_library/rails-controllers/SKILL.md +514 -0
  62. data/lib/generators/claude/skills_library/rails-debugging/SKILL.md +260 -0
  63. data/lib/generators/claude/skills_library/rails-deployment/SKILL.md +437 -0
  64. data/lib/generators/claude/skills_library/rails-deployment/references/examples.md +901 -0
  65. data/lib/generators/claude/skills_library/rails-hotwire/SKILL.md +367 -0
  66. data/lib/generators/claude/skills_library/rails-jobs/MISSION_CONTROL_SETUP.md +639 -0
  67. data/lib/generators/claude/skills_library/rails-jobs/SKILL.md +704 -0
  68. data/lib/generators/claude/skills_library/rails-mailers/SKILL.md +549 -0
  69. data/lib/generators/claude/skills_library/rails-models/SKILL.md +379 -0
  70. data/lib/generators/claude/skills_library/rails-pagination-kaminari/SKILL.md +622 -0
  71. data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/api-pagination.md +523 -0
  72. data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/custom-themes.md +498 -0
  73. data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/performance.md +478 -0
  74. data/lib/generators/claude/skills_library/rails-views/SKILL.md +508 -0
  75. data/lib/generators/claude/skills_library/refine-requirements/SKILL.md +226 -0
  76. data/lib/generators/claude/skills_library/refine-requirements/references/examples.md +344 -0
  77. data/lib/generators/claude/skills_library/refine-requirements/references/reference.md +298 -0
  78. data/lib/generators/claude/skills_library/rspec-testing/SKILL.md +572 -0
  79. data/lib/generators/claude/skills_library/rspec-testing/references/better_specs_guide.md +273 -0
  80. data/lib/generators/claude/skills_library/rspec-testing/references/thoughtbot_patterns.md +407 -0
  81. data/lib/generators/claude/skills_library/tailwindcss/SKILL.md +371 -0
  82. data/lib/generators/claude/views/views_generator.rb +113 -0
  83. data/lib/rails_claude_skills/railtie.rb +16 -0
  84. data/lib/rails_claude_skills/version.rb +5 -0
  85. data/lib/rails_claude_skills.rb +27 -0
  86. data/sig/rails_claude_skills.rbs +4 -0
  87. metadata +199 -0
@@ -0,0 +1,398 @@
1
+ ---
2
+ name: minitest-testing
3
+ description: Write, review, and improve Minitest tests for Ruby on Rails applications. Covers model tests, controller tests, system tests, fixtures, and best practices from Rails Testing Guide.
4
+ allowed-tools: Read, Grep, Glob, Edit, Write, Bash
5
+ ---
6
+
7
+ # Minitest Testing for Rails
8
+
9
+ Write comprehensive, maintainable Minitest tests following Rails conventions and best practices. This skill provides patterns for model tests, controller tests, system tests with Capybara, and fixture usage.
10
+
11
+ <when-to-use>
12
+ - Writing new tests for models, controllers, or system workflows
13
+ - Reviewing existing test coverage and improving quality
14
+ - Fixing failing tests or debugging test issues
15
+ - Setting up test fixtures and test helpers
16
+ - Writing system tests for end-to-end user workflows
17
+ - Testing Hotwire/Turbo behavior in system tests
18
+ </when-to-use>
19
+
20
+ <benefits>
21
+ - **Built-in Framework** - No additional gems needed, part of Rails
22
+ - **Fast Execution** - Lightweight and performant test suite
23
+ - **Rails Integration** - First-class support in Rails framework
24
+ - **Fixture Support** - Simple YAML-based test data
25
+ - **System Tests** - Built-in Capybara integration for browser testing
26
+ - **Parallel Testing** - Run tests in parallel with `bin/rails test:parallel`
27
+ </benefits>
28
+
29
+ <verification-checklist>
30
+ Before completing testing work:
31
+ - ✅ Tests follow Minitest naming convention: `test "descriptive name"`
32
+ - ✅ Fixtures used appropriately for test data
33
+ - ✅ System tests cover critical user workflows
34
+ - ✅ Assertions are specific and descriptive
35
+ - ✅ Tests are independent and can run in any order
36
+ - ✅ All tests passing: `bin/rails test`
37
+ </verification-checklist>
38
+
39
+ <standards>
40
+ - Use descriptive test names: `test "creates post with valid attributes"`
41
+ - One assertion concept per test (may use multiple assert calls)
42
+ - Use specific assertions: `assert_equal`, `assert_redirected_to`, not just `assert`
43
+ - Reference fixtures with symbols: `posts(:published_post)`
44
+ - Use `setup` and `teardown` for test lifecycle management
45
+ - Use `assert_difference` for counting changes
46
+ - System tests for critical workflows, controller/model tests for details
47
+ - Run tests before committing code
48
+ </standards>
49
+
50
+ ---
51
+
52
+ ## Core Testing Principles
53
+
54
+ ### 1. Test Structure
55
+ Organize tests with clear phases:
56
+
57
+ ```ruby
58
+ test "creates article with valid attributes" do
59
+ # Arrange - set up test data
60
+ user = users(:alice)
61
+
62
+ # Act - perform the action
63
+ article = Article.create(
64
+ title: "Test Article",
65
+ body: "Content here",
66
+ user: user
67
+ )
68
+
69
+ # Assert - verify the outcome
70
+ assert article.persisted?
71
+ assert_equal "Test Article", article.title
72
+ end
73
+ ```
74
+
75
+ ### 2. Test Independence
76
+ Each test should be independent and able to run in any order. Use `setup` for common initialization:
77
+
78
+ ```ruby
79
+ class ArticleTest < ActiveSupport::TestCase
80
+ setup do
81
+ @user = users(:alice)
82
+ @article = articles(:published)
83
+ end
84
+
85
+ test "publishes article" do
86
+ @article.publish!
87
+ assert @article.published?
88
+ end
89
+ end
90
+ ```
91
+
92
+ ### 3. Single Responsibility
93
+ Each test verifies one behavior, though it may use multiple assertions to fully verify that behavior.
94
+
95
+ ---
96
+
97
+ ## Test Types
98
+
99
+ ### Model Tests (`test/models/`)
100
+ Test business logic, validations, associations, and custom methods.
101
+
102
+ **File location:** `test/models/article_test.rb`
103
+
104
+ ```ruby
105
+ class ArticleTest < ActiveSupport::TestCase
106
+ test "validates presence of title" do
107
+ article = Article.new(body: "Content")
108
+ assert_not article.valid?
109
+ assert_includes article.errors[:title], "can't be blank"
110
+ end
111
+
112
+ test "belongs to user" do
113
+ article = articles(:published)
114
+ assert_instance_of User, article.user
115
+ end
116
+
117
+ test "#published? returns true when status is published" do
118
+ article = articles(:published)
119
+ assert article.published?
120
+ end
121
+ end
122
+ ```
123
+
124
+ ### Controller Tests (`test/controllers/`)
125
+ Test HTTP responses, redirects, authentication, and parameter handling.
126
+
127
+ **File location:** `test/controllers/articles_controller_test.rb`
128
+
129
+ ```ruby
130
+ class ArticlesControllerTest < ActionDispatch::IntegrationTest
131
+ setup do
132
+ @user = users(:alice)
133
+ sign_in_as(@user) # helper method
134
+ end
135
+
136
+ test "GET index returns success" do
137
+ get articles_path
138
+ assert_response :success
139
+ end
140
+
141
+ test "POST create with valid params creates article" do
142
+ assert_difference("Article.count", 1) do
143
+ post articles_path, params: {
144
+ article: { title: "New Article", body: "Content" }
145
+ }
146
+ end
147
+
148
+ assert_redirected_to article_path(Article.last)
149
+ end
150
+
151
+ test "POST create with invalid params renders new" do
152
+ assert_no_difference("Article.count") do
153
+ post articles_path, params: {
154
+ article: { title: "", body: "" }
155
+ }
156
+ end
157
+
158
+ assert_response :unprocessable_entity
159
+ end
160
+ end
161
+ ```
162
+
163
+ ### System Tests (`test/system/`)
164
+ Test end-to-end user workflows with browser simulation.
165
+
166
+ **File location:** `test/system/article_creation_test.rb`
167
+
168
+ ```ruby
169
+ class ArticleCreationTest < ApplicationSystemTestCase
170
+ test "user creates new article" do
171
+ visit root_path
172
+ click_on "New Article"
173
+
174
+ fill_in "Title", with: "My Test Article"
175
+ fill_in "Body", with: "This is the content"
176
+ select "Published", from: "Status"
177
+
178
+ click_on "Create Article"
179
+
180
+ assert_text "Article was successfully created"
181
+ assert_text "My Test Article"
182
+ end
183
+
184
+ test "article updates with Turbo Frame" do
185
+ article = articles(:draft)
186
+ visit article_path(article)
187
+
188
+ click_on "Edit"
189
+ fill_in "Title", with: "Updated Title"
190
+ click_on "Update Article"
191
+
192
+ # Turbo Frame update - no full page reload
193
+ assert_text "Updated Title"
194
+ assert_no_text article.title
195
+ end
196
+ end
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Detailed Patterns & Examples
202
+
203
+ For comprehensive Minitest patterns and examples, see **[examples.md](examples.md)**.
204
+
205
+ ### Pattern Categories
206
+
207
+ **examples.md contains:**
208
+ - **Fixtures** - YAML fixtures, associations, and fixture access
209
+ - **Model Testing** - Validations, associations, scopes, callbacks, enums
210
+ - **Controller Testing** - CRUD actions, authentication, authorization
211
+ - **System Testing** - Capybara selectors, form interactions, JavaScript behavior
212
+ - **Turbo/Hotwire Testing** - Turbo Frames, Turbo Streams, Stimulus controllers
213
+ - **Background Jobs** - Testing ActiveJob and SolidQueue jobs
214
+ - **Mailers** - Testing ActionMailer delivery and content
215
+ - **Test Helpers** - Custom assertions and helper methods
216
+ - **Mocking/Stubbing** - When and how to use mocks with Minitest
217
+
218
+ Refer to examples.md for complete code examples.
219
+
220
+ ---
221
+
222
+ ## Common Assertions
223
+
224
+ ```ruby
225
+ # Equality
226
+ assert_equal expected, actual
227
+ assert_not_equal unexpected, actual
228
+
229
+ # Truth/Falsehood
230
+ assert value
231
+ assert_not value
232
+ assert_nil value
233
+ assert_not_nil value
234
+
235
+ # Predicates
236
+ assert article.valid?
237
+ assert_not article.persisted?
238
+ assert articles.empty?
239
+
240
+ # Collections
241
+ assert_includes array, item
242
+ assert_empty collection
243
+ assert_not_empty collection
244
+
245
+ # Differences (counting changes)
246
+ assert_difference "Article.count", 1 do
247
+ Article.create!(title: "New", body: "Content")
248
+ end
249
+
250
+ assert_no_difference "Article.count" do
251
+ Article.create(title: "", body: "") # invalid
252
+ end
253
+
254
+ # HTTP Responses
255
+ assert_response :success
256
+ assert_response :redirect
257
+ assert_response :not_found
258
+ assert_redirected_to articles_path
259
+
260
+ # Errors
261
+ assert_raises ActiveRecord::RecordInvalid do
262
+ Article.create!(title: nil)
263
+ end
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Fixtures
269
+
270
+ ### Fixture Files (`test/fixtures/*.yml`)
271
+
272
+ ```yaml
273
+ # test/fixtures/users.yml
274
+ alice:
275
+ email: alice@example.com
276
+ name: Alice Smith
277
+ role: admin
278
+
279
+ bob:
280
+ email: bob@example.com
281
+ name: Bob Jones
282
+ role: member
283
+ ```
284
+
285
+ ```yaml
286
+ # test/fixtures/articles.yml
287
+ published:
288
+ user: alice
289
+ title: Published Article
290
+ body: This article is live
291
+ status: published
292
+ published_at: <%= 1.day.ago %>
293
+
294
+ draft:
295
+ user: bob
296
+ title: Draft Article
297
+ body: Work in progress
298
+ status: draft
299
+ ```
300
+
301
+ ### Using Fixtures in Tests
302
+
303
+ ```ruby
304
+ test "finds published articles" do
305
+ published = articles(:published)
306
+ draft = articles(:draft)
307
+
308
+ results = Article.published
309
+
310
+ assert_includes results, published
311
+ assert_not_includes results, draft
312
+ end
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Test Helpers
318
+
319
+ ### Authentication Helper
320
+
321
+ ```ruby
322
+ # test/test_helper.rb
323
+ class ActionDispatch::IntegrationTest
324
+ def sign_in_as(user)
325
+ post login_path, params: { email: user.email, password: "password" }
326
+ end
327
+ end
328
+ ```
329
+
330
+ ### Custom Assertions
331
+
332
+ ```ruby
333
+ # test/test_helper.rb
334
+ module ActiveSupport
335
+ class TestCase
336
+ def assert_valid(record)
337
+ assert record.valid?, "Expected #{record.class} to be valid, errors: #{record.errors.full_messages}"
338
+ end
339
+ end
340
+ end
341
+ ```
342
+
343
+ ---
344
+
345
+ <testing>
346
+
347
+ ## Running Tests
348
+
349
+ ```bash
350
+ # Run all tests
351
+ bin/rails test
352
+
353
+ # Run specific test file
354
+ bin/rails test test/models/article_test.rb
355
+
356
+ # Run specific test by line number
357
+ bin/rails test test/models/article_test.rb:12
358
+
359
+ # Run tests by pattern
360
+ bin/rails test test/models/*_test.rb
361
+
362
+ # Run system tests only
363
+ bin/rails test:system
364
+
365
+ # Run tests in parallel
366
+ bin/rails test:parallel
367
+
368
+ # Run with verbose output
369
+ bin/rails test -v
370
+
371
+ # Run and show coverage
372
+ COVERAGE=true bin/rails test
373
+ ```
374
+
375
+ </testing>
376
+
377
+ ---
378
+
379
+ <related-skills>
380
+ - rails-models - ActiveRecord patterns for database models
381
+ - rails-controllers - Controller patterns and RESTful design
382
+ - rails-hotwire - Testing Turbo Frames/Streams and Stimulus
383
+ - rails-jobs - Testing background jobs with SolidQueue
384
+ - rails-mailers - Testing email delivery with ActionMailer
385
+ </related-skills>
386
+
387
+ <resources>
388
+
389
+ **Official Documentation:**
390
+ - [Rails Testing Guide](https://guides.rubyonrails.org/testing.html) - Comprehensive Rails testing guide
391
+ - [Minitest Documentation](https://docs.seattlerb.org/minitest/) - Minitest framework docs
392
+ - [Capybara Cheat Sheet](https://devhints.io/capybara) - System test selectors
393
+
394
+ **Tools:**
395
+ - [SimpleCov](https://github.com/simplecov-ruby/simplecov) - Code coverage for Ruby
396
+ - [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers) - Additional matchers for Rails
397
+
398
+ </resources>