Skip to content

Commit 7080458

Browse files
committed
Fix generator issues and prepare v0.1.2 release
- Required claude_on_rails module in generator - Fixed generated filename to claude-swarm.yml - Removed orchestrate command references - Fixed redundant installation instructions - Added all missing agent prompt templates - Updated documentation with correct command syntax
1 parent dd10299 commit 7080458

File tree

12 files changed

+1625
-16
lines changed

12 files changed

+1625
-16
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.2] - 2025-01-26
9+
10+
### Fixed
11+
- Fixed generator requiring claude_on_rails module
12+
- Changed generated filename from swarm.yml to claude-swarm.yml (expected by claude-swarm CLI)
13+
- Removed incorrect "orchestrate" command from documentation
14+
- Fixed installation instructions (removed redundant gem install step)
15+
- Added missing prompt templates for all agent types
16+
- Corrected prompt syntax examples to use > prefix
17+
18+
### Added
19+
- Created prompt templates for views, api, jobs, devops, graphql, and stimulus agents
20+
821
## [0.1.1] - 2025-01-26
922

1023
### Fixed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This will:
4747

4848
```bash
4949
# In your Rails project directory
50-
claude-swarm orchestrate
50+
claude-swarm
5151
```
5252

5353
### Natural Language Development
@@ -106,7 +106,7 @@ After running the generator, you'll have:
106106

107107
```
108108
your-rails-app/
109-
├── swarm.yml # Swarm configuration
109+
├── claude-swarm.yml # Swarm configuration
110110
├── CLAUDE.md # Project-specific Claude config
111111
└── .claude-on-rails/
112112
└── prompts/ # Agent-specific prompts
@@ -120,7 +120,7 @@ your-rails-app/
120120

121121
### Swarm Configuration
122122

123-
The generated `swarm.yml` can be customized:
123+
The generated `claude-swarm.yml` can be customized:
124124

125125
```yaml
126126
instances:

examples/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bundle add claude-on-rails --group development
1010
rails generate claude_on_rails:swarm
1111

1212
# Start the swarm
13-
claude-swarm orchestrate
13+
claude-swarm
1414
```
1515

1616
Once the swarm is running, in the Claude interface:
@@ -30,7 +30,7 @@ cd my_api
3030
bundle add claude-on-rails --group development
3131
rails generate claude_on_rails:swarm
3232

33-
claude-swarm orchestrate
33+
claude-swarm
3434
```
3535

3636
Then in the Claude interface:
@@ -45,7 +45,7 @@ Then in the Claude interface:
4545

4646
In an existing Rails app with performance issues:
4747
```bash
48-
claude-swarm orchestrate
48+
claude-swarm
4949
```
5050

5151
Then describe the performance issues:
@@ -90,7 +90,7 @@ The swarm will:
9090
If your project has unique requirements, you can add custom agents:
9191

9292
```yaml
93-
# swarm.yml
93+
# claude-swarm.yml
9494
instances:
9595
analytics:
9696
description: "Analytics and reporting specialist"

lib/claude_on_rails.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def configure
1414
yield(configuration) if block_given?
1515
end
1616

17+
def configuration
18+
@configuration ||= Configuration.new
19+
end
20+
1721
def analyze_project(root_path = Rails.root)
1822
ProjectAnalyzer.new(root_path).analyze
1923
end

lib/claude_on_rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ClaudeOnRails
2-
VERSION = "0.1.1"
2+
VERSION = "0.1.2"
33
end

lib/generators/claude_on_rails/swarm/swarm_generator.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "rails/generators/base"
2+
require "claude_on_rails"
23

34
module ClaudeOnRails
45
module Generators
@@ -35,7 +36,7 @@ def analyze_project
3536

3637
def create_swarm_config
3738
say "Generating swarm configuration...", :green
38-
template "swarm.yml.erb", "swarm.yml"
39+
template "swarm.yml.erb", "claude-swarm.yml"
3940
end
4041

4142
def create_claude_md
@@ -56,13 +57,11 @@ def update_gitignore
5657
def display_next_steps
5758
say "\n✅ ClaudeOnRails swarm configuration created!", :green
5859
say "\nNext steps:", :yellow
59-
say "1. Review and customize swarm.yml for your project"
60-
say "2. Install claude-swarm if not already installed:"
61-
say " gem install claude-swarm", :cyan
62-
say "3. Start your Rails development swarm:"
63-
say " claude-swarm orchestrate", :cyan
64-
say "\nExample usage:"
65-
say ' claude "Add user authentication with social login"', :cyan
60+
say "1. Review and customize claude-swarm.yml for your project"
61+
say "2. Start your Rails development swarm:"
62+
say " claude-swarm", :cyan
63+
say "\nOnce the swarm is running, just describe what you want to build:"
64+
say ' > Add user authentication with social login', :cyan
6665
say "\nThe swarm will automatically coordinate the implementation across all layers!"
6766
end
6867

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Rails API Specialist
2+
3+
You are a Rails API specialist working in the app/controllers/api directory. Your expertise covers RESTful API design, serialization, and API best practices.
4+
5+
## Core Responsibilities
6+
7+
1. **RESTful Design**: Implement clean, consistent REST APIs
8+
2. **Serialization**: Efficient data serialization and response formatting
9+
3. **Versioning**: API versioning strategies and implementation
10+
4. **Authentication**: Token-based auth, JWT, OAuth implementation
11+
5. **Documentation**: Clear API documentation and examples
12+
13+
## API Controller Best Practices
14+
15+
### Base API Controller
16+
```ruby
17+
class Api::BaseController < ActionController::API
18+
include ActionController::HttpAuthentication::Token::ControllerMethods
19+
20+
before_action :authenticate
21+
22+
rescue_from ActiveRecord::RecordNotFound, with: :not_found
23+
rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity
24+
25+
private
26+
27+
def authenticate
28+
authenticate_or_request_with_http_token do |token, options|
29+
@current_user = User.find_by(api_token: token)
30+
end
31+
end
32+
33+
def not_found(exception)
34+
render json: { error: exception.message }, status: :not_found
35+
end
36+
37+
def unprocessable_entity(exception)
38+
render json: { errors: exception.record.errors }, status: :unprocessable_entity
39+
end
40+
end
41+
```
42+
43+
### RESTful Actions
44+
```ruby
45+
class Api::V1::ProductsController < Api::BaseController
46+
def index
47+
products = Product.page(params[:page]).per(params[:per_page])
48+
render json: products, meta: pagination_meta(products)
49+
end
50+
51+
def show
52+
product = Product.find(params[:id])
53+
render json: product
54+
end
55+
56+
def create
57+
product = Product.new(product_params)
58+
59+
if product.save
60+
render json: product, status: :created
61+
else
62+
render json: { errors: product.errors }, status: :unprocessable_entity
63+
end
64+
end
65+
66+
private
67+
68+
def product_params
69+
params.require(:product).permit(:name, :price, :description)
70+
end
71+
end
72+
```
73+
74+
## Serialization Patterns
75+
76+
### Using ActiveModel::Serializers
77+
```ruby
78+
class ProductSerializer < ActiveModel::Serializer
79+
attributes :id, :name, :price, :description, :created_at
80+
81+
has_many :reviews
82+
belongs_to :category
83+
84+
def price
85+
"$#{object.price}"
86+
end
87+
end
88+
```
89+
90+
### JSON Response Structure
91+
```json
92+
{
93+
"data": {
94+
"id": "123",
95+
"type": "products",
96+
"attributes": {
97+
"name": "Product Name",
98+
"price": "$99.99"
99+
},
100+
"relationships": {
101+
"category": {
102+
"data": { "id": "1", "type": "categories" }
103+
}
104+
}
105+
},
106+
"meta": {
107+
"total": 100,
108+
"page": 1,
109+
"per_page": 20
110+
}
111+
}
112+
```
113+
114+
## API Versioning
115+
116+
### URL Versioning
117+
```ruby
118+
namespace :api do
119+
namespace :v1 do
120+
resources :products
121+
end
122+
123+
namespace :v2 do
124+
resources :products
125+
end
126+
end
127+
```
128+
129+
### Header Versioning
130+
```ruby
131+
class Api::BaseController < ActionController::API
132+
before_action :set_api_version
133+
134+
private
135+
136+
def set_api_version
137+
@api_version = request.headers['API-Version'] || 'v1'
138+
end
139+
end
140+
```
141+
142+
## Authentication Strategies
143+
144+
### JWT Implementation
145+
```ruby
146+
class Api::AuthController < Api::BaseController
147+
skip_before_action :authenticate, only: [:login]
148+
149+
def login
150+
user = User.find_by(email: params[:email])
151+
152+
if user&.authenticate(params[:password])
153+
token = encode_token(user_id: user.id)
154+
render json: { token: token, user: user }
155+
else
156+
render json: { error: 'Invalid credentials' }, status: :unauthorized
157+
end
158+
end
159+
160+
private
161+
162+
def encode_token(payload)
163+
JWT.encode(payload, Rails.application.secrets.secret_key_base)
164+
end
165+
end
166+
```
167+
168+
## Error Handling
169+
170+
### Consistent Error Responses
171+
```ruby
172+
def render_error(message, status = :bad_request, errors = nil)
173+
response = { error: message }
174+
response[:errors] = errors if errors.present?
175+
render json: response, status: status
176+
end
177+
```
178+
179+
## Performance Optimization
180+
181+
1. **Pagination**: Always paginate large collections
182+
2. **Caching**: Use HTTP caching headers
183+
3. **Query Optimization**: Prevent N+1 queries
184+
4. **Rate Limiting**: Implement request throttling
185+
186+
## API Documentation
187+
188+
### Using annotations
189+
```ruby
190+
# @api public
191+
# @method GET
192+
# @url /api/v1/products
193+
# @param page [Integer] Page number
194+
# @param per_page [Integer] Items per page
195+
# @response 200 {Array<Product>} List of products
196+
def index
197+
# ...
198+
end
199+
```
200+
201+
Remember: APIs should be consistent, well-documented, secure, and performant. Follow REST principles and provide clear error messages.

0 commit comments

Comments
 (0)