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.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
- data/.github/ISSUE_TEMPLATE/config.yml +11 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yml +129 -0
- data/.github/ISSUE_TEMPLATE/question.yml +90 -0
- data/.github/dependabot.yml +19 -0
- data/.github/workflows/ci.yml +77 -0
- data/.github/workflows/release.yml +66 -0
- data/.rubocop.yml +52 -0
- data/CHANGELOG.md +94 -0
- data/CLAUDE.md +332 -0
- data/CODE_OF_CONDUCT.md +134 -0
- data/CONTRIBUTING.md +580 -0
- data/LICENSE.txt +21 -0
- data/README.md +544 -0
- data/Rakefile +8 -0
- data/lib/generators/claude/agent/agent_generator.rb +71 -0
- data/lib/generators/claude/agent/templates/agent.md.tt +62 -0
- data/lib/generators/claude/command/command_generator.rb +50 -0
- data/lib/generators/claude/command/templates/command.md.tt +28 -0
- data/lib/generators/claude/commands_library/create-pr.md +27 -0
- data/lib/generators/claude/commands_library/dbchange.md +19 -0
- data/lib/generators/claude/commands_library/quality.md +20 -0
- data/lib/generators/claude/commands_library/stimulus.md +19 -0
- data/lib/generators/claude/commands_library/turbo-feature.md +17 -0
- data/lib/generators/claude/install/install_generator.rb +211 -0
- data/lib/generators/claude/install/templates/README.md.tt +59 -0
- data/lib/generators/claude/install/templates/USAGE +28 -0
- data/lib/generators/claude/install/templates/agents/api-dev.md.tt +46 -0
- data/lib/generators/claude/install/templates/agents/fullstack-dev.md.tt +48 -0
- data/lib/generators/claude/install/templates/agents/rails-developer.md.tt +40 -0
- data/lib/generators/claude/install/templates/settings.local.json.tt +13 -0
- data/lib/generators/claude/rule/rule_generator.rb +175 -0
- data/lib/generators/claude/rule/templates/rule.md.tt +7 -0
- data/lib/generators/claude/rules_library/code-style.md +37 -0
- data/lib/generators/claude/rules_library/database.md +47 -0
- data/lib/generators/claude/rules_library/hotwire.md +56 -0
- data/lib/generators/claude/rules_library/security.md +54 -0
- data/lib/generators/claude/rules_library/testing.md +47 -0
- data/lib/generators/claude/skill/skill_generator.rb +196 -0
- data/lib/generators/claude/skill/templates/SKILL.md.tt +27 -0
- data/lib/generators/claude/skills_library/create-task-files/SKILL.md +311 -0
- data/lib/generators/claude/skills_library/create-task-files/templates/bug.md +60 -0
- data/lib/generators/claude/skills_library/create-task-files/templates/epic.md +47 -0
- data/lib/generators/claude/skills_library/create-task-files/templates/issue.md +45 -0
- data/lib/generators/claude/skills_library/create-task-files/templates/user-story.md +57 -0
- data/lib/generators/claude/skills_library/minitest-testing/SKILL.md +398 -0
- data/lib/generators/claude/skills_library/minitest-testing/references/examples.md +889 -0
- data/lib/generators/claude/skills_library/plan-feature/SKILL.md +253 -0
- data/lib/generators/claude/skills_library/rails-api-controllers/SKILL.md +1041 -0
- data/lib/generators/claude/skills_library/rails-api-controllers/references/api-documentation.md +422 -0
- data/lib/generators/claude/skills_library/rails-api-controllers/references/serialization.md +456 -0
- data/lib/generators/claude/skills_library/rails-auth-with-devise/SKILL.md +191 -0
- data/lib/generators/claude/skills_library/rails-auth-with-devise/references/advanced.md +331 -0
- data/lib/generators/claude/skills_library/rails-auth-with-devise/references/api-auth.md +266 -0
- data/lib/generators/claude/skills_library/rails-auth-with-devise/references/omniauth.md +194 -0
- data/lib/generators/claude/skills_library/rails-authorization-cancancan/SKILL.md +603 -0
- data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/api-authorization.md +543 -0
- data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/complex-permissions.md +572 -0
- data/lib/generators/claude/skills_library/rails-authorization-cancancan/references/multi-tenancy.md +373 -0
- data/lib/generators/claude/skills_library/rails-controllers/SKILL.md +514 -0
- data/lib/generators/claude/skills_library/rails-debugging/SKILL.md +260 -0
- data/lib/generators/claude/skills_library/rails-deployment/SKILL.md +437 -0
- data/lib/generators/claude/skills_library/rails-deployment/references/examples.md +901 -0
- data/lib/generators/claude/skills_library/rails-hotwire/SKILL.md +367 -0
- data/lib/generators/claude/skills_library/rails-jobs/MISSION_CONTROL_SETUP.md +639 -0
- data/lib/generators/claude/skills_library/rails-jobs/SKILL.md +704 -0
- data/lib/generators/claude/skills_library/rails-mailers/SKILL.md +549 -0
- data/lib/generators/claude/skills_library/rails-models/SKILL.md +379 -0
- data/lib/generators/claude/skills_library/rails-pagination-kaminari/SKILL.md +622 -0
- data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/api-pagination.md +523 -0
- data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/custom-themes.md +498 -0
- data/lib/generators/claude/skills_library/rails-pagination-kaminari/references/performance.md +478 -0
- data/lib/generators/claude/skills_library/rails-views/SKILL.md +508 -0
- data/lib/generators/claude/skills_library/refine-requirements/SKILL.md +226 -0
- data/lib/generators/claude/skills_library/refine-requirements/references/examples.md +344 -0
- data/lib/generators/claude/skills_library/refine-requirements/references/reference.md +298 -0
- data/lib/generators/claude/skills_library/rspec-testing/SKILL.md +572 -0
- data/lib/generators/claude/skills_library/rspec-testing/references/better_specs_guide.md +273 -0
- data/lib/generators/claude/skills_library/rspec-testing/references/thoughtbot_patterns.md +407 -0
- data/lib/generators/claude/skills_library/tailwindcss/SKILL.md +371 -0
- data/lib/generators/claude/views/views_generator.rb +113 -0
- data/lib/rails_claude_skills/railtie.rb +16 -0
- data/lib/rails_claude_skills/version.rb +5 -0
- data/lib/rails_claude_skills.rb +27 -0
- data/sig/rails_claude_skills.rbs +4 -0
- metadata +199 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
|
|
5
|
+
module Claude
|
|
6
|
+
module Generators
|
|
7
|
+
class RuleGenerator < Rails::Generators::NamedBase
|
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
|
9
|
+
|
|
10
|
+
class_option :paths, type: :string, default: nil,
|
|
11
|
+
desc: "Comma-separated paths where this rule applies (e.g., 'app/models/**/*,db/**/*')"
|
|
12
|
+
class_option :template, type: :string, default: "generic",
|
|
13
|
+
desc: "Template type (generic, testing, security, performance)"
|
|
14
|
+
|
|
15
|
+
def create_rule_file
|
|
16
|
+
template "rule.md.tt", rule_path
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def show_instructions
|
|
20
|
+
say "\nRule '#{file_name}' created successfully!", :green
|
|
21
|
+
say "\nLocation: #{rule_path}", :blue
|
|
22
|
+
say "\nScope: #{rule_scope}", :yellow
|
|
23
|
+
say "\nNext steps:", :yellow
|
|
24
|
+
say " 1. Edit #{rule_path} to add your project rules"
|
|
25
|
+
say " 2. The rule will be auto-loaded by Claude"
|
|
26
|
+
say " 3. Claude will follow these rules when working in the specified paths\n"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def rule_path
|
|
32
|
+
".claude/rules/#{file_name}.md"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def rule_scope
|
|
36
|
+
options[:paths] || "All files"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def paths?
|
|
40
|
+
options[:paths].present?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def rule_content
|
|
44
|
+
case options[:template]
|
|
45
|
+
when "testing"
|
|
46
|
+
testing_template_content
|
|
47
|
+
when "security"
|
|
48
|
+
security_template_content
|
|
49
|
+
when "performance"
|
|
50
|
+
performance_template_content
|
|
51
|
+
else
|
|
52
|
+
generic_template_content
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def generic_template_content
|
|
57
|
+
<<~CONTENT
|
|
58
|
+
Add your project rules and guidelines here.
|
|
59
|
+
|
|
60
|
+
## Overview
|
|
61
|
+
|
|
62
|
+
Describe the purpose of these rules and when they apply.
|
|
63
|
+
|
|
64
|
+
## Guidelines
|
|
65
|
+
|
|
66
|
+
- Add specific guidelines
|
|
67
|
+
- Include best practices
|
|
68
|
+
- Document conventions
|
|
69
|
+
- Provide examples
|
|
70
|
+
|
|
71
|
+
## Common Patterns
|
|
72
|
+
|
|
73
|
+
Show examples of correct patterns to follow.
|
|
74
|
+
|
|
75
|
+
## Anti-Patterns
|
|
76
|
+
|
|
77
|
+
Show examples of what to avoid.
|
|
78
|
+
CONTENT
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def testing_template_content
|
|
82
|
+
<<~CONTENT
|
|
83
|
+
Guidelines for writing and maintaining tests in this project.
|
|
84
|
+
|
|
85
|
+
## Test Structure
|
|
86
|
+
|
|
87
|
+
- One test file per source file
|
|
88
|
+
- Use descriptive test names
|
|
89
|
+
- Group related tests together
|
|
90
|
+
- Keep tests focused and independent
|
|
91
|
+
|
|
92
|
+
## Best Practices
|
|
93
|
+
|
|
94
|
+
- Write tests before or alongside code
|
|
95
|
+
- Use appropriate test types (unit, integration, system)
|
|
96
|
+
- Mock external dependencies
|
|
97
|
+
- Keep tests fast and reliable
|
|
98
|
+
|
|
99
|
+
## Coverage Requirements
|
|
100
|
+
|
|
101
|
+
- Aim for high test coverage
|
|
102
|
+
- Focus on critical paths
|
|
103
|
+
- Test edge cases and error conditions
|
|
104
|
+
CONTENT
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def security_template_content
|
|
108
|
+
<<~CONTENT
|
|
109
|
+
Security guidelines and requirements for this project.
|
|
110
|
+
|
|
111
|
+
## Input Validation
|
|
112
|
+
|
|
113
|
+
- Always validate and sanitize user input
|
|
114
|
+
- Use strong parameters in controllers
|
|
115
|
+
- Never trust external data
|
|
116
|
+
|
|
117
|
+
## Authentication & Authorization
|
|
118
|
+
|
|
119
|
+
- Implement proper authentication
|
|
120
|
+
- Enforce authorization for sensitive actions
|
|
121
|
+
- Use secure session management
|
|
122
|
+
|
|
123
|
+
## Common Vulnerabilities
|
|
124
|
+
|
|
125
|
+
Protect against:
|
|
126
|
+
- SQL Injection
|
|
127
|
+
- XSS (Cross-Site Scripting)
|
|
128
|
+
- CSRF (Cross-Site Request Forgery)
|
|
129
|
+
- Mass Assignment
|
|
130
|
+
- Insecure Direct Object References
|
|
131
|
+
|
|
132
|
+
## Dependencies
|
|
133
|
+
|
|
134
|
+
- Keep dependencies up to date
|
|
135
|
+
- Run security audits regularly
|
|
136
|
+
- Review security advisories
|
|
137
|
+
CONTENT
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def performance_template_content
|
|
141
|
+
<<~CONTENT
|
|
142
|
+
Performance optimization guidelines for this project.
|
|
143
|
+
|
|
144
|
+
## Database Queries
|
|
145
|
+
|
|
146
|
+
- Avoid N+1 queries (use eager loading)
|
|
147
|
+
- Add appropriate indexes
|
|
148
|
+
- Limit data returned from queries
|
|
149
|
+
- Use database-specific optimizations
|
|
150
|
+
|
|
151
|
+
## Caching
|
|
152
|
+
|
|
153
|
+
- Cache expensive operations
|
|
154
|
+
- Use fragment caching for views
|
|
155
|
+
- Implement HTTP caching headers
|
|
156
|
+
- Consider background jobs for slow tasks
|
|
157
|
+
|
|
158
|
+
## Asset Optimization
|
|
159
|
+
|
|
160
|
+
- Minimize and compress assets
|
|
161
|
+
- Use CDN for static assets
|
|
162
|
+
- Implement lazy loading where appropriate
|
|
163
|
+
- Optimize images and media files
|
|
164
|
+
|
|
165
|
+
## Monitoring
|
|
166
|
+
|
|
167
|
+
- Track performance metrics
|
|
168
|
+
- Monitor query performance
|
|
169
|
+
- Set up alerts for slowdowns
|
|
170
|
+
- Profile code regularly
|
|
171
|
+
CONTENT
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Code Style Rules
|
|
2
|
+
|
|
3
|
+
This project follows Rails conventions and Ruby best practices.
|
|
4
|
+
|
|
5
|
+
## Key Principles
|
|
6
|
+
|
|
7
|
+
- **Convention over Configuration**: Prefer Rails defaults and conventions
|
|
8
|
+
- **Readability**: Code should be clear and self-documenting
|
|
9
|
+
- **Consistency**: Follow established patterns in the codebase
|
|
10
|
+
|
|
11
|
+
## Ruby Style
|
|
12
|
+
|
|
13
|
+
- Use 2 spaces for indentation (not tabs)
|
|
14
|
+
- Prefer double quotes for strings
|
|
15
|
+
- Use modern Ruby syntax (Ruby 3.0+)
|
|
16
|
+
- Prefer `&.` safe navigation over conditional checks
|
|
17
|
+
- Use trailing commas in multi-line arrays and hashes
|
|
18
|
+
|
|
19
|
+
## Rails Conventions
|
|
20
|
+
|
|
21
|
+
- Follow RESTful routing patterns
|
|
22
|
+
- Keep controllers skinny, models organized
|
|
23
|
+
- Use `before_action` callbacks for common controller setup
|
|
24
|
+
- Prefer strong parameters for mass assignment protection
|
|
25
|
+
- Use ActiveRecord query methods over raw SQL
|
|
26
|
+
|
|
27
|
+
## Naming
|
|
28
|
+
|
|
29
|
+
- Use snake_case for variables, methods, and file names
|
|
30
|
+
- Use PascalCase for class and module names
|
|
31
|
+
- Be descriptive: `user_signed_in?` not `signed_in?`
|
|
32
|
+
- Prefix predicate methods with `?` (e.g., `published?`)
|
|
33
|
+
- Prefix dangerous methods with `!` (e.g., `publish!`)
|
|
34
|
+
|
|
35
|
+
## Auto-Fixing
|
|
36
|
+
|
|
37
|
+
Run `bundle exec rubocop -a` to automatically fix style violations before committing.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths: db/**/*,app/models/**/*
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Database Rules
|
|
6
|
+
|
|
7
|
+
Guidelines for working with the database and ActiveRecord models.
|
|
8
|
+
|
|
9
|
+
## Migration Best Practices
|
|
10
|
+
|
|
11
|
+
- Always make migrations reversible
|
|
12
|
+
- Add indexes for foreign keys
|
|
13
|
+
- Use `change` method instead of up/down when possible
|
|
14
|
+
- Add null/default constraints at database level
|
|
15
|
+
- Include comments for complex migrations
|
|
16
|
+
|
|
17
|
+
## Migration Safety
|
|
18
|
+
|
|
19
|
+
- Never modify migrations that have been deployed to production
|
|
20
|
+
- Use background migrations for large data changes
|
|
21
|
+
- Consider downtime for destructive changes
|
|
22
|
+
- Test migrations in development first
|
|
23
|
+
- Keep migrations focused on one change
|
|
24
|
+
|
|
25
|
+
## Model Design
|
|
26
|
+
|
|
27
|
+
- Keep business logic in models
|
|
28
|
+
- Use concerns for shared behavior
|
|
29
|
+
- Implement proper associations
|
|
30
|
+
- Add database-level validations
|
|
31
|
+
- Use scopes for common queries
|
|
32
|
+
|
|
33
|
+
## Query Optimization
|
|
34
|
+
|
|
35
|
+
- Use `includes` to avoid N+1 queries
|
|
36
|
+
- Add appropriate indexes
|
|
37
|
+
- Use `select` to limit columns when needed
|
|
38
|
+
- Leverage database-specific features when appropriate
|
|
39
|
+
- Monitor query performance
|
|
40
|
+
|
|
41
|
+
## Schema Integrity
|
|
42
|
+
|
|
43
|
+
- Use foreign key constraints
|
|
44
|
+
- Add appropriate indexes
|
|
45
|
+
- Set null constraints appropriately
|
|
46
|
+
- Use enums for fixed sets of values
|
|
47
|
+
- Maintain referential integrity
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths: app/views/**/*,app/controllers/**/*
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Hotwire Rules
|
|
6
|
+
|
|
7
|
+
Guidelines for using Turbo and Stimulus in this Rails application.
|
|
8
|
+
|
|
9
|
+
## Turbo Principles
|
|
10
|
+
|
|
11
|
+
- **Turbo Drive**: Automatically handles link clicks and form submissions
|
|
12
|
+
- **Turbo Frames**: Use for independent page segments
|
|
13
|
+
- **Turbo Streams**: Use for real-time updates and multiple page updates
|
|
14
|
+
|
|
15
|
+
## When to Use What
|
|
16
|
+
|
|
17
|
+
### Turbo Frames
|
|
18
|
+
- Independent sections of a page
|
|
19
|
+
- Inline editing
|
|
20
|
+
- Lazy-loaded content
|
|
21
|
+
- Modal dialogs
|
|
22
|
+
|
|
23
|
+
### Turbo Streams
|
|
24
|
+
- Real-time updates (via WebSocket)
|
|
25
|
+
- Multiple simultaneous page updates
|
|
26
|
+
- Optimistic UI updates
|
|
27
|
+
- Background job results
|
|
28
|
+
|
|
29
|
+
### Stimulus
|
|
30
|
+
- Client-side interactivity
|
|
31
|
+
- Form validation
|
|
32
|
+
- UI enhancements
|
|
33
|
+
- When Turbo alone isn't sufficient
|
|
34
|
+
|
|
35
|
+
## Best Practices
|
|
36
|
+
|
|
37
|
+
- Prefer Turbo over custom JavaScript
|
|
38
|
+
- Keep Stimulus controllers small and focused
|
|
39
|
+
- Use semantic HTML with Turbo
|
|
40
|
+
- Follow progressive enhancement
|
|
41
|
+
- Test Turbo interactions
|
|
42
|
+
|
|
43
|
+
## Common Patterns
|
|
44
|
+
|
|
45
|
+
- Use `data-turbo-frame` for targeting frames
|
|
46
|
+
- Use `turbo_stream_from` for real-time updates
|
|
47
|
+
- Respond with `turbo_stream` format in controllers
|
|
48
|
+
- Use Stimulus for UI state management
|
|
49
|
+
- Leverage Turbo's morphing for smooth updates
|
|
50
|
+
|
|
51
|
+
## Performance
|
|
52
|
+
|
|
53
|
+
- Lazy load Turbo Frames when appropriate
|
|
54
|
+
- Cache Turbo Frame responses
|
|
55
|
+
- Use Turbo Stream broadcasts efficiently
|
|
56
|
+
- Minimize JavaScript controller complexity
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Security Rules
|
|
2
|
+
|
|
3
|
+
Security is a top priority in this Rails application.
|
|
4
|
+
|
|
5
|
+
## Input Validation
|
|
6
|
+
|
|
7
|
+
- Always use strong parameters in controllers
|
|
8
|
+
- Validate and sanitize user input
|
|
9
|
+
- Use ActiveRecord validations
|
|
10
|
+
- Never trust user input
|
|
11
|
+
|
|
12
|
+
## Authentication & Authorization
|
|
13
|
+
|
|
14
|
+
- Implement proper authentication (Devise, has_secure_password, etc.)
|
|
15
|
+
- Use authorization gems (Pundit, CanCanCan) for complex permissions
|
|
16
|
+
- Protect sensitive actions with before_action filters
|
|
17
|
+
- Use secure session configuration
|
|
18
|
+
|
|
19
|
+
## Database Security
|
|
20
|
+
|
|
21
|
+
- Never commit database credentials
|
|
22
|
+
- Use environment variables for sensitive configuration
|
|
23
|
+
- Prevent SQL injection by using ActiveRecord query methods
|
|
24
|
+
- Add database-level constraints when appropriate
|
|
25
|
+
|
|
26
|
+
## CSRF Protection
|
|
27
|
+
|
|
28
|
+
- Keep CSRF protection enabled (default in Rails)
|
|
29
|
+
- Use `protect_from_forgery` in ApplicationController
|
|
30
|
+
- Include authenticity tokens in forms
|
|
31
|
+
|
|
32
|
+
## Common Vulnerabilities
|
|
33
|
+
|
|
34
|
+
Protect against:
|
|
35
|
+
- SQL Injection: Use parameterized queries
|
|
36
|
+
- XSS: Sanitize output, use content_tag helpers
|
|
37
|
+
- Mass Assignment: Use strong parameters
|
|
38
|
+
- CSRF: Use Rails default protections
|
|
39
|
+
- Insecure Direct Object References: Authorize resource access
|
|
40
|
+
|
|
41
|
+
## Dependency Management
|
|
42
|
+
|
|
43
|
+
- Keep gems up to date
|
|
44
|
+
- Run `bundle audit` regularly
|
|
45
|
+
- Use Dependabot or similar tools
|
|
46
|
+
- Review security advisories
|
|
47
|
+
|
|
48
|
+
## Best Practices
|
|
49
|
+
|
|
50
|
+
- Follow OWASP Top 10 guidelines
|
|
51
|
+
- Use HTTPS in production
|
|
52
|
+
- Implement rate limiting for APIs
|
|
53
|
+
- Log security events
|
|
54
|
+
- Regular security audits with Brakeman
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths: spec/**/*,test/**/*
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Testing Rules
|
|
6
|
+
|
|
7
|
+
This project values comprehensive test coverage.
|
|
8
|
+
|
|
9
|
+
## Test Structure
|
|
10
|
+
|
|
11
|
+
- One test file per model/controller/component
|
|
12
|
+
- Use descriptive test names
|
|
13
|
+
- Group related tests with clear organization
|
|
14
|
+
- Keep tests focused and independent
|
|
15
|
+
|
|
16
|
+
## Test Types
|
|
17
|
+
|
|
18
|
+
### Model Tests
|
|
19
|
+
- Test validations
|
|
20
|
+
- Test associations
|
|
21
|
+
- Test custom methods
|
|
22
|
+
- Test scopes and queries
|
|
23
|
+
|
|
24
|
+
### Controller Tests
|
|
25
|
+
- Test HTTP responses (200, 302, 404, etc.)
|
|
26
|
+
- Test authentication/authorization
|
|
27
|
+
- Test parameter handling
|
|
28
|
+
- Avoid testing view rendering details
|
|
29
|
+
|
|
30
|
+
### System/Integration Tests
|
|
31
|
+
- Test critical user workflows end-to-end
|
|
32
|
+
- Test JavaScript/Hotwire behavior
|
|
33
|
+
- Keep tests for happy paths and critical features
|
|
34
|
+
|
|
35
|
+
## Best Practices
|
|
36
|
+
|
|
37
|
+
- Write tests before or alongside code (TDD/BDD)
|
|
38
|
+
- Use factories or fixtures for test data
|
|
39
|
+
- Mock external services
|
|
40
|
+
- Keep tests fast and isolated
|
|
41
|
+
- Test edge cases and error conditions
|
|
42
|
+
|
|
43
|
+
## Running Tests
|
|
44
|
+
|
|
45
|
+
- Run full suite regularly
|
|
46
|
+
- Run specific tests during development
|
|
47
|
+
- Ensure tests pass before committing
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
|
|
5
|
+
module Claude
|
|
6
|
+
module Generators
|
|
7
|
+
class SkillGenerator < Rails::Generators::NamedBase
|
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
|
9
|
+
|
|
10
|
+
class_option :description, type: :string, default: nil,
|
|
11
|
+
desc: "Skill description"
|
|
12
|
+
class_option :with_references, type: :boolean, default: false,
|
|
13
|
+
desc: "Create references directory"
|
|
14
|
+
class_option :template, type: :string, default: "generic",
|
|
15
|
+
desc: "Template type (generic, model, controller, frontend)"
|
|
16
|
+
|
|
17
|
+
def create_skill_directory
|
|
18
|
+
empty_directory skill_path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create_skill_file
|
|
22
|
+
template "SKILL.md.tt", "#{skill_path}/SKILL.md"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create_references_directory
|
|
26
|
+
return unless options[:with_references]
|
|
27
|
+
|
|
28
|
+
empty_directory "#{skill_path}/references"
|
|
29
|
+
create_file "#{skill_path}/references/.keep", ""
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def show_instructions
|
|
33
|
+
say "\nSkill '#{file_name}' created successfully!", :green
|
|
34
|
+
say "\nLocation: #{skill_path}/", :blue
|
|
35
|
+
say "\nNext steps:", :yellow
|
|
36
|
+
say " 1. Edit #{skill_path}/SKILL.md to add your skill content"
|
|
37
|
+
say " 2. Add reference files in #{skill_path}/references/ (optional)" if options[:with_references]
|
|
38
|
+
say " 3. The skill will be auto-loaded by Claude\n"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def skill_path
|
|
44
|
+
".claude/skills/#{file_name}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def skill_description
|
|
48
|
+
options[:description] || "Custom skill for #{file_name.titleize}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def skill_tags
|
|
52
|
+
case options[:template]
|
|
53
|
+
when "model"
|
|
54
|
+
%w[activerecord models database]
|
|
55
|
+
when "controller"
|
|
56
|
+
%w[controllers routing actions]
|
|
57
|
+
when "frontend"
|
|
58
|
+
%w[views frontend ui]
|
|
59
|
+
else
|
|
60
|
+
["custom"]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def template_sections
|
|
65
|
+
case options[:template]
|
|
66
|
+
when "model"
|
|
67
|
+
model_template_sections
|
|
68
|
+
when "controller"
|
|
69
|
+
controller_template_sections
|
|
70
|
+
when "frontend"
|
|
71
|
+
frontend_template_sections
|
|
72
|
+
else
|
|
73
|
+
generic_template_sections
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def generic_template_sections
|
|
78
|
+
<<~SECTIONS
|
|
79
|
+
## Quick Reference
|
|
80
|
+
|
|
81
|
+
| Command | Purpose |
|
|
82
|
+
|---------|---------|
|
|
83
|
+
| TODO | Add commands here |
|
|
84
|
+
|
|
85
|
+
## Overview
|
|
86
|
+
|
|
87
|
+
#{skill_description}
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
Add usage examples and patterns here.
|
|
92
|
+
|
|
93
|
+
## Common Patterns
|
|
94
|
+
|
|
95
|
+
Add frequently used code patterns here.
|
|
96
|
+
|
|
97
|
+
## Best Practices
|
|
98
|
+
|
|
99
|
+
Add best practices and conventions here.
|
|
100
|
+
SECTIONS
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def model_template_sections
|
|
104
|
+
<<~SECTIONS
|
|
105
|
+
## Quick Reference
|
|
106
|
+
|
|
107
|
+
| Pattern | Example |
|
|
108
|
+
|---------|---------|
|
|
109
|
+
| Define Model | `class #{file_name.classify} < ApplicationRecord` |
|
|
110
|
+
| Validation | `validates :field, presence: true` |
|
|
111
|
+
| Association | `has_many :items` |
|
|
112
|
+
|
|
113
|
+
## Overview
|
|
114
|
+
|
|
115
|
+
#{skill_description}
|
|
116
|
+
|
|
117
|
+
## Validations
|
|
118
|
+
|
|
119
|
+
Add validation patterns here.
|
|
120
|
+
|
|
121
|
+
## Associations
|
|
122
|
+
|
|
123
|
+
Add association patterns here.
|
|
124
|
+
|
|
125
|
+
## Scopes and Queries
|
|
126
|
+
|
|
127
|
+
Add query patterns here.
|
|
128
|
+
|
|
129
|
+
## Callbacks
|
|
130
|
+
|
|
131
|
+
Add callback patterns here.
|
|
132
|
+
SECTIONS
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def controller_template_sections
|
|
136
|
+
<<~SECTIONS
|
|
137
|
+
## Quick Reference
|
|
138
|
+
|
|
139
|
+
| Action | Purpose |
|
|
140
|
+
|--------|---------|
|
|
141
|
+
| index | List resources |
|
|
142
|
+
| show | Display single resource |
|
|
143
|
+
| new | Form for creating |
|
|
144
|
+
| create | Save new resource |
|
|
145
|
+
| edit | Form for editing |
|
|
146
|
+
| update | Save changes |
|
|
147
|
+
| destroy| Delete resource |
|
|
148
|
+
|
|
149
|
+
## Overview
|
|
150
|
+
|
|
151
|
+
#{skill_description}
|
|
152
|
+
|
|
153
|
+
## Standard Actions
|
|
154
|
+
|
|
155
|
+
Add standard CRUD action patterns here.
|
|
156
|
+
|
|
157
|
+
## Custom Actions
|
|
158
|
+
|
|
159
|
+
Add custom action patterns here.
|
|
160
|
+
|
|
161
|
+
## Filters and Callbacks
|
|
162
|
+
|
|
163
|
+
Add before_action and other filter patterns here.
|
|
164
|
+
SECTIONS
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def frontend_template_sections
|
|
168
|
+
<<~SECTIONS
|
|
169
|
+
## Quick Reference
|
|
170
|
+
|
|
171
|
+
| Pattern | Usage |
|
|
172
|
+
|---------|-------|
|
|
173
|
+
| Partial | `<%= render 'partial' %>` |
|
|
174
|
+
| Helper | `<%= helper_method %>` |
|
|
175
|
+
| Link | `<%= link_to 'Text', path %>` |
|
|
176
|
+
|
|
177
|
+
## Overview
|
|
178
|
+
|
|
179
|
+
#{skill_description}
|
|
180
|
+
|
|
181
|
+
## Templates
|
|
182
|
+
|
|
183
|
+
Add view template patterns here.
|
|
184
|
+
|
|
185
|
+
## Helpers
|
|
186
|
+
|
|
187
|
+
Add helper method patterns here.
|
|
188
|
+
|
|
189
|
+
## Components
|
|
190
|
+
|
|
191
|
+
Add component patterns here.
|
|
192
|
+
SECTIONS
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: <%= file_name %>
|
|
3
|
+
description: <%= skill_description %>
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
rails_version: ">= 7.0"
|
|
6
|
+
tags:
|
|
7
|
+
<% skill_tags.each do |tag| -%>
|
|
8
|
+
- <%= tag %>
|
|
9
|
+
<% end -%>
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# <%= file_name.titleize %>
|
|
13
|
+
|
|
14
|
+
<%= template_sections %>
|
|
15
|
+
|
|
16
|
+
## Troubleshooting
|
|
17
|
+
|
|
18
|
+
Add common issues and solutions here.
|
|
19
|
+
|
|
20
|
+
## References
|
|
21
|
+
|
|
22
|
+
- [Add external documentation links]
|
|
23
|
+
- [Add related resources]
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
*Generated with rails_claude_skills v<%= RailsClaudeSkills::VERSION %>*
|