claude-on-rails 0.1.4 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c54b004a79682a75a479c16d29933a76e7baca7f71a7af6d8378f77788ec90cd
4
- data.tar.gz: fa1e7da87e5306defb8504d944f06d14bac72be1bc3b02bc5c011db95fec5e2c
3
+ metadata.gz: a54eaca693aeb4a066e7fae8112346681d1127d8b6c247f01d8cf56c4fe12f77
4
+ data.tar.gz: 3e7d637a4625cca7ef9a5886ed5c6aaef1464173b7bbb8735ebcdea5436ec583
5
5
  SHA512:
6
- metadata.gz: 22d8cfa8073d281f30cec4347d3051e91eed508278d372a8a6f2ddbe41fea400fd800d7ad29669df9706f92cf8d017a7278b09dcbea5fc259b250892432e03c0
7
- data.tar.gz: 229724023c7c511a60787f6164c8c5dce6421772d7c0aadd864b17c7833bf7e52e16c56e1f1b76c5a2f315bd04ebb835d6910179373103200ce58e16a01fe259
6
+ metadata.gz: e3845a7c2b042d3c35943fd859ea8286ecfe61434e42e90263b217de1f73bf431f04f9c02f5a492dc65f6a5922c77da6a65c433cc20a55f5520966b4ece914bd
7
+ data.tar.gz: e269424a844bacc0a1906ef7a44e350ccb3798dbfc081702c647b799d703d3d0fa0093cc61888c3c8180e19b19b6fc502723090eedcba4e7f9e3c9dc5658395c
data/.rubocop.yml CHANGED
@@ -11,6 +11,11 @@ AllCops:
11
11
  plugins:
12
12
  - rubocop-rake
13
13
 
14
+ # Allow hyphenated filename to match gem name
15
+ Naming/FileName:
16
+ Exclude:
17
+ - 'lib/claude-on-rails.rb'
18
+
14
19
 
15
20
  # Relaxed metrics for DSL-heavy library code
16
21
  Metrics/MethodLength:
data/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0] - 2025-01-02
9
+
10
+ ### Added
11
+ - Rails MCP Server integration for enhanced documentation access
12
+ - Interactive setup wizard with `rails claude_on_rails:setup_mcp`
13
+ - Status checking with `rails claude_on_rails:mcp_status`
14
+ - Automated MCP setup during swarm generation
15
+ - Post-install message with setup instructions
16
+ - Comprehensive SETUP.md documentation
17
+
18
+ ### Changed
19
+ - Rails MCP Server is now a Ruby gem (not npm package)
20
+ - MCP configuration automatically added to swarm.yml when available
21
+ - All agent prompts enhanced with MCP-specific guidance
22
+ - Simplified setup process - just press Y during generation
23
+
24
+ ### Fixed
25
+ - RDoc version conflicts during gem installation
26
+ - Use --no-document flag to avoid documentation generation issues
27
+ - Improved MCP availability detection
28
+
29
+ ## [0.1.5] - 2025-01-27
30
+
31
+ ### Fixed
32
+ - Fixed rake tasks not loading in Rails applications
33
+ - Added explicit require for rails/railtie in railtie.rb
34
+ - Changed Rails detection to check for Rails::Railtie instead of Rails
35
+ - Removed circular dependency in rake task file
36
+
8
37
  ## [0.1.4] - 2025-01-27
9
38
 
10
39
  ### Fixed
data/CLAUDE.md ADDED
@@ -0,0 +1,59 @@
1
+ # ClaudeOnRails Development
2
+
3
+ ## Project Overview
4
+
5
+ ClaudeOnRails is a Ruby gem that leverages claude-swarm to create intelligent AI agent teams for Rails development. It generates swarm configurations that allow developers to describe what they want to build in natural language, and the swarm coordinates implementation across all Rails layers.
6
+
7
+ ## Guidelines
8
+
9
+ ### 1. File References in Claude
10
+ - Use `@filepath` syntax for file references, not `/file:filepath`
11
+ - File references are the preferred way to include content without duplicating it
12
+
13
+ ### 2. Never Overwrite User Configuration
14
+ - Always check if CLAUDE.md exists before writing to it
15
+ - Use file references to include framework content rather than appending
16
+ - Store framework-specific content in separate files (e.g., `.claude-on-rails/context.md`)
17
+
18
+ ### 3. Claude-Swarm Integration
19
+ - The default configuration file is `claude-swarm.yml`, not `swarm.yml`
20
+ - Command is simply `claude-swarm`, not `claude-swarm orchestrate`
21
+ - claude-swarm is a dependency, so no need to tell users to install it separately
22
+
23
+ ### 4. Documentation Clarity
24
+ - Clearly distinguish between shell commands and Claude prompts
25
+ - Use `>` prefix for Claude prompts to avoid confusion with bash commands
26
+ - Be explicit about where commands should be run vs where prompts should be typed
27
+
28
+ ### 5. Ruby Gem Best Practices
29
+ - Keep development dependencies in Gemfile, not gemspec (RuboCop rule)
30
+ - Always run `bundle exec rake` before committing changes to catch syntax and style issues
31
+ - Use `bundle exec rake release` for gem releases (creates tag, pushes to RubyGems)
32
+ - ...then create GitHub releases separately with `gh release create`
33
+
34
+ ### 6. Generator Best Practices
35
+ - Check for directory existence before creating agents
36
+ - Make generators idempotent (running multiple times shouldn't duplicate content)
37
+ - Provide clear next steps after generation
38
+ - Show what will be created during the analysis phase
39
+
40
+ ### 7. Testing Considerations
41
+ - Make sure that user confirms that they have tested changes with a real Rails project before releasing
42
+ - Consider different Rails configurations (API-only, full-stack, with/without GraphQL)
43
+ - **IMPORTANT**: This project uses RSpec exclusively for testing. NEVER use Minitest or any other testing framework. Do not add minitest gems, create test/ directories, or write any Minitest-style tests. All tests must be written in RSpec format and placed in the spec/ directory.
44
+
45
+ ## Workflow Guidance
46
+
47
+ - For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
48
+ - When you're tempted to respond and return control to me with a message like "The codebase is now in excellent shape with 859 passing tests, 1 failing test, and 5 pending tests. The project is ready for the v0.2.0 release once the team decides how to handle the final test (either fix it or mark it as pending)." then instead, you should decide how to handle the final test _first_.
49
+
50
+ ## Release Guidance
51
+
52
+ - Note that releases are never ready if there are any tests failing in the test suites. Never tell me that a release is ready unless we have a clean build.
53
+
54
+ ## Architecture Notes
55
+
56
+ - The gem analyzes Rails projects to detect patterns and frameworks
57
+ - It generates customized swarm configurations based on project structure
58
+ - Each agent works in a specific directory (MVC separation)
59
+ - Agents communicate via MCP protocol in claude-swarm
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- claude-on-rails (0.1.4)
4
+ claude-on-rails (0.2.0)
5
5
  claude_swarm (~> 0.1)
6
6
  rails (>= 6.0)
7
7
 
@@ -258,14 +258,6 @@ GEM
258
258
  rspec-mocks (3.13.5)
259
259
  diff-lcs (>= 1.2.0, < 2.0)
260
260
  rspec-support (~> 3.13.0)
261
- rspec-rails (5.1.2)
262
- actionpack (>= 5.2)
263
- activesupport (>= 5.2)
264
- railties (>= 5.2)
265
- rspec-core (~> 3.10)
266
- rspec-expectations (~> 3.10)
267
- rspec-mocks (~> 3.10)
268
- rspec-support (~> 3.10)
269
261
  rspec-support (3.13.4)
270
262
  rubocop (1.77.0)
271
263
  json (~> 2.3)
@@ -281,28 +273,9 @@ GEM
281
273
  rubocop-ast (1.45.1)
282
274
  parser (>= 3.3.7.2)
283
275
  prism (~> 1.4)
284
- rubocop-capybara (2.22.1)
285
- lint_roller (~> 1.1)
286
- rubocop (~> 1.72, >= 1.72.1)
287
- rubocop-factory_bot (2.27.1)
288
- lint_roller (~> 1.1)
289
- rubocop (~> 1.72, >= 1.72.1)
290
- rubocop-rails (2.32.0)
291
- activesupport (>= 4.2.0)
292
- lint_roller (~> 1.1)
293
- rack (>= 1.1)
294
- rubocop (>= 1.75.0, < 2.0)
295
- rubocop-ast (>= 1.44.0, < 2.0)
296
276
  rubocop-rake (0.7.1)
297
277
  lint_roller (~> 1.1)
298
278
  rubocop (>= 1.72.1)
299
- rubocop-rspec (2.31.0)
300
- rubocop (~> 1.40)
301
- rubocop-capybara (~> 2.17)
302
- rubocop-factory_bot (~> 2.22)
303
- rubocop-rspec_rails (~> 2.28)
304
- rubocop-rspec_rails (2.29.1)
305
- rubocop (~> 1.61)
306
279
  ruby-progressbar (1.13.0)
307
280
  securerandom (0.4.1)
308
281
  stringio (3.1.7)
@@ -332,15 +305,10 @@ PLATFORMS
332
305
  x86_64-linux-musl
333
306
 
334
307
  DEPENDENCIES
335
- bundler (~> 2.0)
336
308
  claude-on-rails!
337
309
  rake (~> 13.0)
338
310
  rspec (~> 3.0)
339
- rspec-rails (~> 5.0)
340
- rubocop (~> 1.0)
341
- rubocop-rails (~> 2.0)
342
311
  rubocop-rake (~> 0.6)
343
- rubocop-rspec (~> 2.0)
344
312
 
345
313
  BUNDLED WITH
346
314
  2.5.23
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ClaudeOnRails
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/claude-on-rails.svg?cache_bust=0.1.4)](https://badge.fury.io/rb/claude-on-rails)
4
+ [![CI](https://github.com/obie/claude-on-rails/actions/workflows/main.yml/badge.svg)](https://github.com/obie/claude-on-rails/actions/workflows/main.yml)
5
+
6
+
3
7
  A Rails development framework that leverages [claude-swarm](https://github.com/parruda/claude-swarm) to create an intelligent team of AI agents specialized in different aspects of Rails development.
4
8
 
5
9
  Instead of managing personas manually, ClaudeOnRails automatically orchestrates a swarm of specialized agents that work together like a real development team. Simply describe what you want to build, and the swarm handles the rest.
@@ -35,8 +39,11 @@ bundle install
35
39
  rails generate claude_on_rails:swarm
36
40
  ```
37
41
 
42
+ During generation, you'll be offered to set up Rails MCP Server for enhanced documentation access. Simply press Y when prompted!
43
+
38
44
  This will:
39
45
  - Analyze your Rails project structure
46
+ - Optionally set up Rails MCP Server (recommended)
40
47
  - Generate a customized swarm configuration
41
48
  - Create agent-specific prompts
42
49
  - Set up your development environment
@@ -128,7 +135,7 @@ instances:
128
135
  architect:
129
136
  description: "Your project-specific architect description"
130
137
  connections: [models, controllers, custom_agent]
131
-
138
+
132
139
  custom_agent:
133
140
  description: "Specialized agent for your domain"
134
141
  directory: ./app/custom
@@ -151,6 +158,47 @@ Customize agent behavior by editing prompts in `.claude-on-rails/prompts/`:
151
158
  - **Test-Driven**: Automatic test generation for all code
152
159
  - **Performance Focus**: Built-in optimization capabilities
153
160
 
161
+ ## Enhanced Documentation with Rails MCP Server
162
+
163
+ ClaudeOnRails integrates with [Rails MCP Server](https://github.com/mariochavez/rails-mcp-server) to provide your AI agents with real-time access to Rails documentation and best practices.
164
+
165
+ ### Benefits
166
+
167
+ - **Up-to-date Documentation**: Agents access current Rails guides matching your version
168
+ - **Framework Resources**: Includes Turbo, Stimulus, and Kamal documentation
169
+ - **Consistent Standards**: All agents share the same documentation source
170
+ - **Reduced Hallucination**: Agents verify patterns against official documentation
171
+
172
+ ### Automated Setup
173
+
174
+ When you run `rails generate claude_on_rails:swarm`, you'll be prompted to set up Rails MCP Server automatically. Just press Y!
175
+
176
+ If you skipped it initially, you can set it up anytime:
177
+
178
+ ```bash
179
+ bundle exec rake claude_on_rails:setup_mcp
180
+ ```
181
+
182
+ This interactive command will:
183
+ - Install the Rails MCP Server gem
184
+ - Configure your environment for enhanced documentation access
185
+
186
+ ### Check Status
187
+
188
+ To verify your Rails MCP Server installation:
189
+
190
+ ```bash
191
+ bundle exec rake claude_on_rails:mcp_status
192
+ ```
193
+
194
+ ### How It Works
195
+
196
+ When Rails MCP Server is available:
197
+ - Each agent can query Rails documentation in real-time
198
+ - Version-specific guidance ensures compatibility
199
+ - Agents reference canonical implementations
200
+ - Complex features follow official patterns
201
+
154
202
  ## Requirements
155
203
 
156
204
  - Ruby 2.7+
@@ -178,4 +226,4 @@ MIT License - see [LICENSE](./LICENSE) for details.
178
226
 
179
227
  - Powered by [claude-swarm](https://github.com/parruda/claude-swarm)
180
228
  - Built for [Claude Code](https://github.com/anthropics/claude-code)
181
- - Integrates with [Rails MCP Server](https://github.com/mariochavez/rails-mcp-server)
229
+ - Integrates with [Rails MCP Server](https://github.com/maquina-app/rails-mcp-server)
data/SETUP.md ADDED
@@ -0,0 +1,132 @@
1
+ # ClaudeOnRails Setup Guide
2
+
3
+ This guide covers the complete setup process for ClaudeOnRails, including the optional Rails MCP Server integration.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Add to your Gemfile
9
+ gem 'claude-on-rails', group: :development
10
+
11
+ # Install the gem
12
+ bundle install
13
+
14
+ # Generate swarm configuration (includes optional MCP setup)
15
+ rails generate claude_on_rails:swarm
16
+ # Press Y when prompted to set up Rails MCP Server!
17
+
18
+ # Start your AI development team
19
+ claude-swarm
20
+ ```
21
+
22
+ ## Enhanced Setup with Rails MCP Server
23
+
24
+ Rails MCP Server provides your AI agents with real-time access to Rails documentation. While optional, it significantly improves the quality and accuracy of generated code.
25
+
26
+ ### Automated Setup
27
+
28
+ The easiest way is during initial generation - just press Y when prompted!
29
+
30
+ If you skipped it or want to set it up later:
31
+
32
+ ```bash
33
+ bundle exec rake claude_on_rails:setup_mcp
34
+ ```
35
+
36
+ This interactive command will:
37
+ - Install the Rails MCP Server gem globally
38
+ - Configure your environment for enhanced documentation access
39
+
40
+ ### Manual Setup
41
+
42
+ If you prefer manual installation:
43
+
44
+ 1. **Install Rails MCP Server**
45
+ ```bash
46
+ gem install rails-mcp-server
47
+ ```
48
+
49
+ 2. **Regenerate Swarm Configuration**
50
+ ```bash
51
+ rails generate claude_on_rails:swarm
52
+ ```
53
+
54
+ ### Checking MCP Status
55
+
56
+ To verify your Rails MCP Server setup:
57
+
58
+ ```bash
59
+ bundle exec rake claude_on_rails:mcp_status
60
+ ```
61
+
62
+ This shows:
63
+ - Installation status
64
+ - Downloaded resources
65
+ - Missing resources
66
+
67
+ ## Configuration Options
68
+
69
+ ### Generator Options
70
+
71
+ ```bash
72
+ # Skip MCP Server integration
73
+ rails generate claude_on_rails:swarm --no-mcp-server
74
+
75
+ # API-only application
76
+ rails generate claude_on_rails:swarm --api-only
77
+
78
+ # Skip test agent
79
+ rails generate claude_on_rails:swarm --skip-tests
80
+
81
+ # Include GraphQL support
82
+ rails generate claude_on_rails:swarm --graphql
83
+ ```
84
+
85
+ ## Troubleshooting
86
+
87
+ ### Rails MCP Server Not Found
88
+
89
+ If the generator doesn't detect Rails MCP Server:
90
+
91
+ 1. Verify installation: `gem list rails-mcp-server`
92
+ 2. Check PATH: `which rails-mcp-server`
93
+ 3. Reinstall: `gem install rails-mcp-server`
94
+
95
+ ### Documentation Access
96
+
97
+ The Rails MCP Server gem includes built-in documentation for:
98
+ - Rails framework and guides
99
+ - Turbo and Stimulus frameworks
100
+ - Kamal deployment tool
101
+
102
+ No separate download steps are required!
103
+
104
+ ### Multiple Rails Projects
105
+
106
+ MCP Server resources are shared globally, benefiting all your Rails projects:
107
+
108
+ ```bash
109
+ # Install once
110
+ bundle exec rake claude_on_rails:setup_mcp
111
+
112
+ # Use in any Rails project
113
+ cd my-rails-app
114
+ rails generate claude_on_rails:swarm
115
+ ```
116
+
117
+ ## Getting Help
118
+
119
+ - Check status: `bundle exec rake claude_on_rails:mcp_status`
120
+ - View logs: `claude-swarm.log`
121
+ - Report issues: [GitHub Issues](https://github.com/obie/claude-on-rails/issues)
122
+ - Documentation: [README.md](./README.md)
123
+
124
+ ## Next Steps
125
+
126
+ After setup:
127
+
128
+ 1. Review generated `claude-swarm.yml`
129
+ 2. Customize agent prompts in `.claude-on-rails/prompts/`
130
+ 3. Start building with `claude-swarm`
131
+ 4. Describe features in natural language
132
+ 5. Let your AI team implement them!
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file exists to match the gem name for Rails autoloading
4
+ require 'claude_on_rails'
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ClaudeOnRails
4
+ # Interactive installer for Rails MCP Server
5
+ class MCPInstaller
6
+ def run
7
+ puts "\e[32m🚀 ClaudeOnRails MCP Server Setup\e[0m"
8
+ puts "\e[32m#{'=' * 50}\e[0m"
9
+
10
+ if MCPSupport.available?
11
+ puts "\e[32m✓ Rails MCP Server is already installed\e[0m"
12
+ else
13
+ handle_installation
14
+ end
15
+
16
+ puts "\n\e[32m✅ Setup complete!\e[0m"
17
+ show_next_steps
18
+ end
19
+
20
+ private
21
+
22
+ def handle_installation
23
+ puts "\n\e[33mRails MCP Server provides your AI agents with:\e[0m"
24
+ puts "\e[36m • Real-time Rails documentation access\e[0m"
25
+ puts "\e[36m • Version-specific API references\e[0m"
26
+ puts "\e[36m • Framework guides (Turbo, Stimulus, Kamal)\e[0m"
27
+ puts "\e[36m • Best practices and examples\e[0m"
28
+
29
+ if prompt_yes_no?("\nWould you like to install Rails MCP Server? (Y/n)")
30
+ install_mcp_server
31
+ else
32
+ puts "\n\e[33mSkipping Rails MCP Server installation.\e[0m"
33
+ puts "\e[36mYou can run 'bundle exec rake claude_on_rails:setup_mcp' later to set it up.\e[0m"
34
+ end
35
+ end
36
+
37
+ def install_mcp_server
38
+ puts "\n\e[32mInstalling Rails MCP Server globally...\e[0m"
39
+
40
+ # Install without documentation to avoid RDoc conflicts
41
+ if system('gem install rails-mcp-server --no-document')
42
+ puts "\e[32m✓ Rails MCP Server installed successfully!\e[0m"
43
+ else
44
+ puts "\n\e[31m❌ Failed to install Rails MCP Server\e[0m"
45
+ puts "\e[33mPlease try running manually:\e[0m"
46
+ puts "\e[36m gem install rails-mcp-server --no-document\e[0m"
47
+ exit 1
48
+ end
49
+ end
50
+
51
+ def show_next_steps
52
+ puts "\n\e[33mNext steps:\e[0m"
53
+
54
+ if MCPSupport.available?
55
+ puts "\e[36m1. Run the swarm generator to update your configuration:\e[0m"
56
+ puts "\e[36m rails generate claude_on_rails:swarm\e[0m"
57
+ puts "\n\e[36m2. Start your enhanced Rails development swarm:\e[0m"
58
+ puts "\e[36m claude-swarm\e[0m"
59
+ puts "\n\e[32mYour AI agents now have access to Rails documentation! 🎉\e[0m"
60
+ else
61
+ puts "\e[36m1. Complete the MCP Server setup when ready:\e[0m"
62
+ puts "\e[36m bundle exec rake claude_on_rails:setup_mcp\e[0m"
63
+ puts "\n\e[36m2. Then run the swarm generator:\e[0m"
64
+ puts "\e[36m rails generate claude_on_rails:swarm\e[0m"
65
+ end
66
+
67
+ puts "\n\e[36mFor more information:\e[0m"
68
+ puts "\e[36m • Check status: bundle exec rake claude_on_rails:mcp_status\e[0m"
69
+ puts "\e[36m • View documentation: https://github.com/obie/claude-on-rails\e[0m"
70
+ end
71
+
72
+ def prompt_yes_no?(question)
73
+ print "\e[32m#{question} \e[0m"
74
+ response = $stdin.gets.chomp.downcase
75
+ response.empty? || response.start_with?('y')
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ClaudeOnRails
4
+ # Support module for Rails MCP Server integration
5
+ module MCPSupport
6
+ class << self
7
+ # Check if Rails MCP Server gem is available on the system
8
+ def available?
9
+ # Check if the gem is installed
10
+ system('gem list -i rails-mcp-server > /dev/null 2>&1') ||
11
+ # Also check if the executable is available
12
+ system('which rails-mcp-server > /dev/null 2>&1')
13
+ rescue StandardError
14
+ false
15
+ end
16
+
17
+ # Check if a specific resource is downloaded
18
+ def resource_available?(_resource_name)
19
+ # Rails MCP Server includes all resources in the gem
20
+ available?
21
+ end
22
+
23
+ # Get the MCP server configuration for swarm
24
+ def server_config(rails_env = 'development')
25
+ {
26
+ name: 'rails',
27
+ type: 'stdio',
28
+ command: 'rails-mcp-server',
29
+ args: [],
30
+ env: { 'RAILS_ENV' => rails_env }
31
+ }
32
+ end
33
+
34
+ # Check if we can download a resource (always true for gem-based server)
35
+ def download_resource?(_resource_name)
36
+ return false unless available?
37
+
38
+ # Rails MCP Server doesn't require separate resource downloads
39
+ # Documentation is built-in to the gem
40
+ true
41
+ end
42
+
43
+ # Get available resources that can be downloaded
44
+ def available_resources
45
+ %w[rails turbo stimulus kamal]
46
+ end
47
+
48
+ # Check which resources are currently downloaded
49
+ def downloaded_resources
50
+ # All resources are included in the gem
51
+ available? ? available_resources : []
52
+ end
53
+
54
+ # Check which resources are missing
55
+ def missing_resources
56
+ # No resources are missing if the gem is installed
57
+ available? ? [] : available_resources
58
+ end
59
+
60
+ # Check if common resources are set up
61
+ def common_resources_setup?
62
+ # No separate resource setup needed
63
+ available?
64
+ end
65
+
66
+ # Generate installation instructions
67
+ def installation_instructions
68
+ instructions = []
69
+
70
+ unless available?
71
+ instructions << "Install Rails MCP Server:"
72
+ instructions << " gem install rails-mcp-server --no-document"
73
+ instructions << ""
74
+ end
75
+
76
+ instructions
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/railtie'
4
+
5
+ module ClaudeOnRails
6
+ # Railtie to load rake tasks in Rails applications
7
+ class Railtie < Rails::Railtie
8
+ rake_tasks do
9
+ load File.expand_path('../tasks/claude_on_rails.rake', __dir__)
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeOnRails
4
- VERSION = '0.1.4'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -4,6 +4,10 @@ require 'claude_on_rails/version'
4
4
  require 'claude_on_rails/configuration'
5
5
  require 'claude_on_rails/project_analyzer'
6
6
  require 'claude_on_rails/swarm_builder'
7
+ require 'claude_on_rails/mcp_support'
8
+
9
+ # Load railtie if Rails is defined
10
+ require 'claude_on_rails/railtie' if defined?(Rails::Railtie)
7
11
 
8
12
  module ClaudeOnRails
9
13
  class Error < StandardError; end
@@ -20,6 +20,9 @@ module ClaudeOnRails
20
20
  class_option :turbo, type: :boolean, default: true,
21
21
  desc: 'Include Turbo/Stimulus specialist agents'
22
22
 
23
+ class_option :mcp_server, type: :boolean, default: true,
24
+ desc: 'Include Rails MCP Server for enhanced documentation access'
25
+
23
26
  def analyze_project
24
27
  say 'Analyzing Rails project structure...', :green
25
28
  @project_analysis = ClaudeOnRails.analyze_project(Rails.root)
@@ -31,9 +34,16 @@ module ClaudeOnRails
31
34
  @skip_tests = options[:skip_tests]
32
35
  @test_framework = @project_analysis[:test_framework]
33
36
 
37
+ # Check for Rails MCP Server
38
+ @include_mcp_server = options[:mcp_server] && ClaudeOnRails::MCPSupport.available?
39
+
34
40
  say "Project type: #{@api_only ? 'API-only' : 'Full-stack Rails'}", :cyan
35
41
  say "Test framework: #{@test_framework}", :cyan if @test_framework
36
42
  say "GraphQL detected: #{@has_graphql ? 'Yes' : 'No'}", :cyan
43
+ say "Rails MCP Server: #{@include_mcp_server ? 'Available' : 'Not available'}", :cyan
44
+
45
+ # Offer MCP setup if enabled but not available
46
+ offer_mcp_setup if options[:mcp_server] && !@include_mcp_server
37
47
 
38
48
  # Show which agents will be created
39
49
  say "\nAgents to be created:", :yellow
@@ -77,12 +87,20 @@ module ClaudeOnRails
77
87
 
78
88
  def update_gitignore
79
89
  say 'Updating .gitignore...', :green
90
+ gitignore_path = Rails.root.join('.gitignore')
91
+
92
+ # Create .gitignore if it doesn't exist
93
+ create_file '.gitignore', '' unless File.exist?(gitignore_path)
94
+
80
95
  append_to_file '.gitignore', "\n# ClaudeOnRails\n.claude-on-rails/sessions/\n.claude-swarm/\nclaude-swarm.log\n"
81
96
  end
82
97
 
83
98
  def display_next_steps
84
99
  say "\n✅ ClaudeOnRails swarm configuration created!", :green
85
100
  say "\nNext steps:", :yellow
101
+
102
+ # Remove this section since we now handle it interactively in analyze_project
103
+
86
104
  say '1. Review and customize claude-swarm.yml for your project'
87
105
  say '2. Start your Rails development swarm:'
88
106
  say ' claude-swarm', :cyan
@@ -120,6 +138,27 @@ module ClaudeOnRails
120
138
  list << 'devops' if File.directory?(Rails.root.join('config'))
121
139
  list
122
140
  end
141
+
142
+ def offer_mcp_setup
143
+ say "\n🎯 Rails MCP Server Enhancement Available!", :yellow
144
+ say "Rails MCP Server provides your AI agents with real-time Rails documentation.", :cyan
145
+
146
+ if yes?("Would you like to set it up now? (Y/n)", :green)
147
+ say "\nStarting Rails MCP Server setup...", :green
148
+ system('bundle exec rake claude_on_rails:setup_mcp')
149
+
150
+ # Re-check availability after setup
151
+ @include_mcp_server = ClaudeOnRails::MCPSupport.available?
152
+
153
+ if @include_mcp_server
154
+ say "\n✓ Rails MCP Server is now available!", :green
155
+ else
156
+ say "\nSetup was not completed. Continuing without MCP Server.", :yellow
157
+ end
158
+ else
159
+ say "\nYou can set it up later with: bundle exec rake claude_on_rails:setup_mcp", :cyan
160
+ end
161
+ end
123
162
  end
124
163
  end
125
164
  end
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
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-27 00:00:00.000000000 Z
11
+ date: 2025-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claude_swarm
@@ -50,16 +50,22 @@ files:
50
50
  - ".rspec"
51
51
  - ".rubocop.yml"
52
52
  - CHANGELOG.md
53
+ - CLAUDE.md
53
54
  - CONTRIBUTING.md
54
55
  - Gemfile
55
56
  - Gemfile.lock
56
57
  - LICENSE
57
58
  - README.md
58
59
  - Rakefile
60
+ - SETUP.md
59
61
  - examples/README.md
62
+ - lib/claude-on-rails.rb
60
63
  - lib/claude_on_rails.rb
61
64
  - lib/claude_on_rails/configuration.rb
65
+ - lib/claude_on_rails/mcp_installer.rb
66
+ - lib/claude_on_rails/mcp_support.rb
62
67
  - lib/claude_on_rails/project_analyzer.rb
68
+ - lib/claude_on_rails/railtie.rb
63
69
  - lib/claude_on_rails/swarm_builder.rb
64
70
  - lib/claude_on_rails/version.rb
65
71
  - lib/generators/claude_on_rails/swarm/swarm_generator.rb
@@ -77,6 +83,7 @@ files:
77
83
  - lib/generators/claude_on_rails/swarm/templates/prompts/tests.md
78
84
  - lib/generators/claude_on_rails/swarm/templates/prompts/views.md
79
85
  - lib/generators/claude_on_rails/swarm/templates/swarm.yml.erb
86
+ - lib/tasks/claude_on_rails.rake
80
87
  homepage: https://github.com/obie/claude-on-rails
81
88
  licenses:
82
89
  - MIT
@@ -84,7 +91,11 @@ metadata:
84
91
  homepage_uri: https://github.com/obie/claude-on-rails
85
92
  source_code_uri: https://github.com/obie/claude-on-rails
86
93
  changelog_uri: https://github.com/obie/claude-on-rails/blob/main/CHANGELOG.md
87
- 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"
88
99
  rdoc_options: []
89
100
  require_paths:
90
101
  - lib