claude-on-rails 0.1.3 → 0.2.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.
@@ -0,0 +1,32 @@
1
+ # ClaudeOnRails Context
2
+
3
+ This project uses ClaudeOnRails with a swarm of specialized agents for Rails development.
4
+
5
+ ## Project Information
6
+ - **Rails Version**: <%= Rails.version %>
7
+ - **Ruby Version**: <%= RUBY_VERSION %>
8
+ - **Project Type**: <%= @api_only ? 'API-only' : 'Full-stack Rails' %>
9
+ - **Test Framework**: <%= @test_framework || 'Not detected' %>
10
+ <% if @has_graphql -%>
11
+ - **GraphQL**: Enabled
12
+ <% end -%>
13
+ <% if @has_turbo && !@api_only -%>
14
+ - **Turbo/Stimulus**: Enabled
15
+ <% end -%>
16
+
17
+ ## Swarm Configuration
18
+
19
+ The claude-swarm.yml file defines specialized agents for different aspects of Rails development:
20
+ - Each agent has specific expertise and works in designated directories
21
+ - Agents collaborate to implement features across all layers
22
+ - The architect agent coordinates the team
23
+
24
+ ## Development Guidelines
25
+
26
+ When working on this project:
27
+ - Follow Rails conventions and best practices
28
+ - Write tests for all new functionality
29
+ - Use strong parameters in controllers
30
+ - Keep models focused with single responsibilities
31
+ - Extract complex business logic to service objects
32
+ - Ensure proper database indexing for foreign keys and queries
@@ -16,24 +16,24 @@ You are a Rails API specialist working in the app/controllers/api directory. You
16
16
  ```ruby
17
17
  class Api::BaseController < ActionController::API
18
18
  include ActionController::HttpAuthentication::Token::ControllerMethods
19
-
19
+
20
20
  before_action :authenticate
21
-
21
+
22
22
  rescue_from ActiveRecord::RecordNotFound, with: :not_found
23
23
  rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity
24
-
24
+
25
25
  private
26
-
26
+
27
27
  def authenticate
28
28
  authenticate_or_request_with_http_token do |token, options|
29
29
  @current_user = User.find_by(api_token: token)
30
30
  end
31
31
  end
32
-
32
+
33
33
  def not_found(exception)
34
34
  render json: { error: exception.message }, status: :not_found
35
35
  end
36
-
36
+
37
37
  def unprocessable_entity(exception)
38
38
  render json: { errors: exception.record.errors }, status: :unprocessable_entity
39
39
  end
@@ -47,26 +47,26 @@ class Api::V1::ProductsController < Api::BaseController
47
47
  products = Product.page(params[:page]).per(params[:per_page])
48
48
  render json: products, meta: pagination_meta(products)
49
49
  end
50
-
50
+
51
51
  def show
52
52
  product = Product.find(params[:id])
53
53
  render json: product
54
54
  end
55
-
55
+
56
56
  def create
57
57
  product = Product.new(product_params)
58
-
58
+
59
59
  if product.save
60
60
  render json: product, status: :created
61
61
  else
62
62
  render json: { errors: product.errors }, status: :unprocessable_entity
63
63
  end
64
64
  end
65
-
65
+
66
66
  private
67
-
67
+
68
68
  def product_params
69
- params.require(:product).permit(:name, :price, :description)
69
+ params.expect(product: [:name, :price, :description])
70
70
  end
71
71
  end
72
72
  ```
@@ -77,10 +77,10 @@ end
77
77
  ```ruby
78
78
  class ProductSerializer < ActiveModel::Serializer
79
79
  attributes :id, :name, :price, :description, :created_at
80
-
80
+
81
81
  has_many :reviews
82
82
  belongs_to :category
83
-
83
+
84
84
  def price
85
85
  "$#{object.price}"
86
86
  end
@@ -119,7 +119,7 @@ namespace :api do
119
119
  namespace :v1 do
120
120
  resources :products
121
121
  end
122
-
122
+
123
123
  namespace :v2 do
124
124
  resources :products
125
125
  end
@@ -130,9 +130,9 @@ end
130
130
  ```ruby
131
131
  class Api::BaseController < ActionController::API
132
132
  before_action :set_api_version
133
-
133
+
134
134
  private
135
-
135
+
136
136
  def set_api_version
137
137
  @api_version = request.headers['API-Version'] || 'v1'
138
138
  end
@@ -145,10 +145,10 @@ end
145
145
  ```ruby
146
146
  class Api::AuthController < Api::BaseController
147
147
  skip_before_action :authenticate, only: [:login]
148
-
148
+
149
149
  def login
150
150
  user = User.find_by(email: params[:email])
151
-
151
+
152
152
  if user&.authenticate(params[:password])
153
153
  token = encode_token(user_id: user.id)
154
154
  render json: { token: token, user: user }
@@ -156,9 +156,9 @@ class Api::AuthController < Api::BaseController
156
156
  render json: { error: 'Invalid credentials' }, status: :unauthorized
157
157
  end
158
158
  end
159
-
159
+
160
160
  private
161
-
161
+
162
162
  def encode_token(payload)
163
163
  JWT.encode(payload, Rails.application.secrets.secret_key_base)
164
164
  end
@@ -198,4 +198,4 @@ def index
198
198
  end
199
199
  ```
200
200
 
201
- Remember: APIs should be consistent, well-documented, secure, and performant. Follow REST principles and provide clear error messages.
201
+ Remember: APIs should be consistent, well-documented, secure, and performant. Follow REST principles and provide clear error messages.
@@ -38,6 +38,20 @@ Always ensure:
38
38
  - Security by default
39
39
  - Performance considerations
40
40
 
41
+ ## Enhanced Documentation Access
42
+
43
+ When Rails MCP Server is available, you have access to:
44
+ - **Real-time Rails documentation**: Query official Rails guides and API docs
45
+ - **Framework-specific resources**: Access Turbo, Stimulus, and Kamal documentation
46
+ - **Version-aware guidance**: Get documentation matching the project's Rails version
47
+ - **Best practices examples**: Reference canonical implementations
48
+
49
+ Use MCP tools to:
50
+ - Verify Rails conventions before implementing features
51
+ - Check latest API methods and their parameters
52
+ - Reference security best practices from official guides
53
+ - Ensure compatibility with the project's Rails version
54
+
41
55
  ## Communication Style
42
56
 
43
57
  - Be clear and specific when delegating to specialists
@@ -21,7 +21,7 @@ You are a Rails controller and routing specialist working in the app/controllers
21
21
  ### Strong Parameters
22
22
  ```ruby
23
23
  def user_params
24
- params.require(:user).permit(:name, :email, :role)
24
+ params.expect(user: [:name, :email, :role])
25
25
  end
26
26
  ```
27
27
 
@@ -84,4 +84,20 @@ end
84
84
  - Use constraints for advanced routing
85
85
  - Keep routes RESTful
86
86
 
87
- Remember: Controllers should be thin coordinators. Business logic belongs in models or service objects.
87
+ Remember: Controllers should be thin coordinators. Business logic belongs in models or service objects.
88
+
89
+ ## MCP-Enhanced Capabilities
90
+
91
+ When Rails MCP Server is available, leverage:
92
+ - **Routing Documentation**: Access comprehensive routing guides and DSL reference
93
+ - **Controller Patterns**: Reference ActionController methods and modules
94
+ - **Security Guidelines**: Query official security best practices
95
+ - **API Design**: Access REST and API design patterns from Rails guides
96
+ - **Middleware Information**: Understand the request/response cycle
97
+
98
+ Use MCP tools to:
99
+ - Verify routing DSL syntax and options
100
+ - Check available controller filters and callbacks
101
+ - Reference proper HTTP status codes and when to use them
102
+ - Find security best practices for the current Rails version
103
+ - Understand request/response format handling
@@ -77,4 +77,19 @@ class User < ApplicationRecord
77
77
  end
78
78
  ```
79
79
 
80
+ ## MCP-Enhanced Capabilities
81
+
82
+ When Rails MCP Server is available, leverage:
83
+ - **Migration References**: Access the latest migration syntax and options
84
+ - **ActiveRecord Queries**: Query documentation for advanced query methods
85
+ - **Validation Options**: Reference all available validation options and custom validators
86
+ - **Association Types**: Get detailed information on association options and edge cases
87
+ - **Database Adapters**: Check database-specific features and limitations
88
+
89
+ Use MCP tools to:
90
+ - Verify migration syntax for the current Rails version
91
+ - Find optimal query patterns for complex data retrievals
92
+ - Check association options and their performance implications
93
+ - Reference database-specific features (PostgreSQL, MySQL, etc.)
94
+
80
95
  Remember: Focus on data integrity, performance, and following Rails conventions.
@@ -2,6 +2,15 @@ version: 1
2
2
  swarm:
3
3
  name: "<%= Rails.application.class.module_parent_name %> Rails Development Team"
4
4
  main: architect
5
+ <% if @include_mcp_server %>
6
+ mcps:
7
+ - name: rails
8
+ type: stdio
9
+ command: rails-mcp-server
10
+ args: []
11
+ env:
12
+ RAILS_ENV: <%= Rails.env %>
13
+ <% end %>
5
14
  instances:
6
15
  architect:
7
16
  description: "Rails architect coordinating <%= @api_only ? 'API' : 'full-stack' %> development for <%= Rails.application.class.module_parent_name %>"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :claude_on_rails do
4
+ desc 'Setup Rails MCP Server for enhanced documentation access'
5
+ task setup_mcp: :environment do
6
+ require 'claude_on_rails/mcp_installer'
7
+ ClaudeOnRails::MCPInstaller.new.run
8
+ end
9
+
10
+ desc 'Check Rails MCP Server status and available resources'
11
+ task mcp_status: :environment do
12
+ if ClaudeOnRails::MCPSupport.available?
13
+ puts '✓ Rails MCP Server is installed'
14
+
15
+ downloaded = ClaudeOnRails::MCPSupport.downloaded_resources
16
+ missing = ClaudeOnRails::MCPSupport.missing_resources
17
+
18
+ if downloaded.any?
19
+ puts "\nDownloaded resources:"
20
+ downloaded.each { |resource| puts " ✓ #{resource}" }
21
+ end
22
+
23
+ if missing.any?
24
+ puts "\nMissing resources:"
25
+ missing.each { |resource| puts " ✗ #{resource}" }
26
+ puts "\nRun 'bundle exec rake claude_on_rails:setup_mcp' to download missing resources."
27
+ else
28
+ puts "\n✓ All resources are downloaded"
29
+ end
30
+ else
31
+ puts '✗ Rails MCP Server is not installed'
32
+ puts "\nRun 'bundle exec rake claude_on_rails:setup_mcp' to install and configure it."
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-26 00:00:00.000000000 Z
11
+ date: 2025-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '6.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '6.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: claude_swarm
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,103 +25,19 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0.1'
41
27
  - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '5.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '5.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rails
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '2.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '2.0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rspec
28
+ name: rails
127
29
  requirement: !ruby/object:Gem::Requirement
128
30
  requirements:
129
- - - "~>"
31
+ - - ">="
130
32
  - !ruby/object:Gem::Version
131
- version: '2.0'
132
- type: :development
33
+ version: '6.0'
34
+ type: :runtime
133
35
  prerelease: false
134
36
  version_requirements: !ruby/object:Gem::Requirement
135
37
  requirements:
136
- - - "~>"
38
+ - - ">="
137
39
  - !ruby/object:Gem::Version
138
- version: '2.0'
40
+ version: '6.0'
139
41
  description: ClaudeOnRails leverages claude-swarm to create an intelligent team of
140
42
  AI agents specialized in different aspects of Rails development. Simply describe
141
43
  what you want to build, and the swarm handles the rest.
@@ -146,21 +48,29 @@ extensions: []
146
48
  extra_rdoc_files: []
147
49
  files:
148
50
  - ".rspec"
51
+ - ".rubocop.yml"
149
52
  - CHANGELOG.md
53
+ - CLAUDE.md
150
54
  - CONTRIBUTING.md
151
55
  - Gemfile
56
+ - Gemfile.lock
152
57
  - LICENSE
153
58
  - README.md
154
59
  - Rakefile
155
- - claude-on-rails.gemspec
60
+ - SETUP.md
156
61
  - examples/README.md
62
+ - lib/claude-on-rails.rb
157
63
  - lib/claude_on_rails.rb
158
64
  - lib/claude_on_rails/configuration.rb
65
+ - lib/claude_on_rails/mcp_installer.rb
66
+ - lib/claude_on_rails/mcp_support.rb
159
67
  - lib/claude_on_rails/project_analyzer.rb
68
+ - lib/claude_on_rails/railtie.rb
160
69
  - lib/claude_on_rails/swarm_builder.rb
161
70
  - lib/claude_on_rails/version.rb
162
71
  - lib/generators/claude_on_rails/swarm/swarm_generator.rb
163
72
  - lib/generators/claude_on_rails/swarm/templates/CLAUDE.md.erb
73
+ - lib/generators/claude_on_rails/swarm/templates/claude_on_rails_context.md
164
74
  - lib/generators/claude_on_rails/swarm/templates/prompts/api.md
165
75
  - lib/generators/claude_on_rails/swarm/templates/prompts/architect.md
166
76
  - lib/generators/claude_on_rails/swarm/templates/prompts/controllers.md
@@ -173,6 +83,7 @@ files:
173
83
  - lib/generators/claude_on_rails/swarm/templates/prompts/tests.md
174
84
  - lib/generators/claude_on_rails/swarm/templates/prompts/views.md
175
85
  - lib/generators/claude_on_rails/swarm/templates/swarm.yml.erb
86
+ - lib/tasks/claude_on_rails.rake
176
87
  homepage: https://github.com/obie/claude-on-rails
177
88
  licenses:
178
89
  - MIT
@@ -180,7 +91,11 @@ metadata:
180
91
  homepage_uri: https://github.com/obie/claude-on-rails
181
92
  source_code_uri: https://github.com/obie/claude-on-rails
182
93
  changelog_uri: https://github.com/obie/claude-on-rails/blob/main/CHANGELOG.md
183
- post_install_message:
94
+ post_install_message: "========================================================================\n\U0001F680
95
+ ClaudeOnRails has been successfully installed!\n\nFor enhanced Rails documentation
96
+ access, you can set up Rails MCP Server:\n bundle exec rake claude_on_rails:setup_mcp\n\nThis
97
+ optional setup will:\n • Install the Rails MCP Server gem\n • Enable real-time
98
+ documentation access for your AI agents\n\nGet started:\n rails generate claude_on_rails:swarm\n\n========================================================================\n"
184
99
  rdoc_options: []
185
100
  require_paths:
186
101
  - lib
@@ -188,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
103
  requirements:
189
104
  - - ">="
190
105
  - !ruby/object:Gem::Version
191
- version: 2.7.0
106
+ version: 3.3.0
192
107
  required_rubygems_version: !ruby/object:Gem::Requirement
193
108
  requirements:
194
109
  - - ">="
@@ -1,45 +0,0 @@
1
- require_relative "lib/claude_on_rails/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "claude-on-rails"
5
- spec.version = ClaudeOnRails::VERSION
6
- spec.authors = ["Obie Fernandez"]
7
- spec.email = ["obiefernandez@gmail.com"]
8
-
9
- spec.summary = "Rails development framework powered by Claude swarm intelligence"
10
- spec.description = "ClaudeOnRails leverages claude-swarm to create an intelligent team of AI agents specialized in different aspects of Rails development. Simply describe what you want to build, and the swarm handles the rest."
11
- spec.homepage = "https://github.com/obie/claude-on-rails"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = ">= 2.7.0"
14
-
15
- spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = spec.homepage
17
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
18
-
19
- # Specify which files should be added to the gem when it is released.
20
- spec.files = Dir.chdir(__dir__) do
21
- `git ls-files -z`.split("\x0").reject do |f|
22
- (File.expand_path(f) == __FILE__) ||
23
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor .github])
24
- end
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- # Runtime dependencies
31
- spec.add_dependency "rails", ">= 6.0"
32
- spec.add_dependency "claude_swarm", "~> 0.1"
33
-
34
- # Development dependencies
35
- spec.add_development_dependency "bundler", "~> 2.0"
36
- spec.add_development_dependency "rake", "~> 13.0"
37
- spec.add_development_dependency "rspec", "~> 3.0"
38
- spec.add_development_dependency "rspec-rails", "~> 5.0"
39
- spec.add_development_dependency "rubocop", "~> 1.0"
40
- spec.add_development_dependency "rubocop-rails", "~> 2.0"
41
- spec.add_development_dependency "rubocop-rspec", "~> 2.0"
42
-
43
- # For more information and examples about making a new gem, check out our
44
- # guide at: https://bundler.io/guides/creating_gem.html
45
- end