claude-code-templates 1.10.0 → 1.11.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.
- package/README.md +6 -0
- package/bin/create-claude-config.js +1 -0
- package/package.json +2 -2
- package/src/analytics/core/ConversationAnalyzer.js +94 -20
- package/src/analytics/core/FileWatcher.js +146 -11
- package/src/analytics/data/DataCache.js +124 -19
- package/src/analytics/notifications/NotificationManager.js +37 -0
- package/src/analytics/notifications/WebSocketServer.js +1 -1
- package/src/analytics-web/FRONT_ARCHITECTURE.md +46 -0
- package/src/analytics-web/assets/js/{main.js → main.js.deprecated} +32 -3
- package/src/analytics-web/components/AgentsPage.js +2535 -0
- package/src/analytics-web/components/App.js +430 -0
- package/src/analytics-web/components/{Dashboard.js → Dashboard.js.deprecated} +23 -7
- package/src/analytics-web/components/DashboardPage.js +1527 -0
- package/src/analytics-web/components/Sidebar.js +197 -0
- package/src/analytics-web/components/ToolDisplay.js +539 -0
- package/src/analytics-web/index.html +3275 -1792
- package/src/analytics-web/services/DataService.js +89 -16
- package/src/analytics-web/services/StateService.js +9 -0
- package/src/analytics-web/services/WebSocketService.js +17 -5
- package/src/analytics.js +323 -35
- package/src/console-bridge.js +610 -0
- package/src/file-operations.js +143 -23
- package/src/hook-scanner.js +21 -1
- package/src/index.js +24 -1
- package/src/templates.js +28 -0
- package/src/test-console-bridge.js +67 -0
- package/src/utils.js +46 -0
- package/templates/ruby/.claude/commands/model.md +360 -0
- package/templates/ruby/.claude/commands/test.md +480 -0
- package/templates/ruby/.claude/settings.json +146 -0
- package/templates/ruby/.mcp.json +83 -0
- package/templates/ruby/CLAUDE.md +284 -0
- package/templates/ruby/examples/rails-app/.claude/commands/authentication.md +490 -0
- package/templates/ruby/examples/rails-app/CLAUDE.md +376 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# Rails 8 Project Configuration
|
|
2
|
+
|
|
3
|
+
This file provides specific guidance for Ruby on Rails 8 web application development using Claude Code.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is a Ruby on Rails 8 web application project optimized for modern web development with the latest Rails features. The project follows Rails 8 conventions and leverages new capabilities like native authentication, Solid trifecta, and Kamal 2 deployment.
|
|
8
|
+
|
|
9
|
+
## Rails 8 Specific Development Commands
|
|
10
|
+
|
|
11
|
+
### Project Creation & Setup
|
|
12
|
+
- `rails new myapp` - Create new Rails 8 application
|
|
13
|
+
- `rails new myapp --skip-kamal` - Create app without Kamal deployment
|
|
14
|
+
- `rails new myapp --database=postgresql` - Create app with PostgreSQL
|
|
15
|
+
- `rails new myapp --css=tailwind` - Create app with Tailwind CSS
|
|
16
|
+
- `rails new myapp --javascript=esbuild` - Create app with esbuild
|
|
17
|
+
|
|
18
|
+
### Server Management
|
|
19
|
+
- `bin/rails server` or `bin/rails s` - Start development server
|
|
20
|
+
- `bin/rails server -p 4000` - Start server on port 4000
|
|
21
|
+
- `bin/rails server -e production` - Start in production mode
|
|
22
|
+
- `bin/dev` - Start development server with asset compilation (if available)
|
|
23
|
+
|
|
24
|
+
### Database Management
|
|
25
|
+
- `bin/rails db:create` - Create database
|
|
26
|
+
- `bin/rails db:migrate` - Run pending migrations
|
|
27
|
+
- `bin/rails db:rollback` - Rollback last migration
|
|
28
|
+
- `bin/rails db:reset` - Drop, create, and migrate database
|
|
29
|
+
- `bin/rails db:seed` - Run database seeds
|
|
30
|
+
- `bin/rails db:setup` - Create, migrate, and seed database
|
|
31
|
+
|
|
32
|
+
### Generation Commands
|
|
33
|
+
- `bin/rails generate model User name:string email:string` - Generate model
|
|
34
|
+
- `bin/rails generate controller Users index show` - Generate controller
|
|
35
|
+
- `bin/rails generate migration AddIndexToUsers email:index` - Generate migration
|
|
36
|
+
- `bin/rails generate authentication` - Generate Rails 8 native authentication (NEW)
|
|
37
|
+
- `bin/rails generate solid_queue:install` - Install Solid Queue (NEW)
|
|
38
|
+
- `bin/rails generate solid_cache:install` - Install Solid Cache (NEW)
|
|
39
|
+
|
|
40
|
+
### Rails 8 Native Authentication
|
|
41
|
+
- `bin/rails generate authentication User` - Generate authentication for User model
|
|
42
|
+
- `bin/rails generate authentication:views` - Generate authentication views
|
|
43
|
+
- `bin/rails generate authentication:controllers` - Generate authentication controllers
|
|
44
|
+
|
|
45
|
+
### Background Jobs (Solid Queue)
|
|
46
|
+
- `bin/rails solid_queue:start` - Start Solid Queue worker
|
|
47
|
+
- `bin/rails solid_queue:install` - Install Solid Queue configuration
|
|
48
|
+
- `SampleJob.perform_later(user)` - Enqueue background job
|
|
49
|
+
|
|
50
|
+
### Caching (Solid Cache)
|
|
51
|
+
- `Rails.cache.write("key", "value")` - Write to cache
|
|
52
|
+
- `Rails.cache.read("key")` - Read from cache
|
|
53
|
+
- `Rails.cache.delete("key")` - Delete from cache
|
|
54
|
+
- `bin/rails solid_cache:clear` - Clear all cached data
|
|
55
|
+
|
|
56
|
+
### Asset Management (Propshaft)
|
|
57
|
+
- `bin/rails assets:precompile` - Precompile assets for production
|
|
58
|
+
- `bin/rails assets:clobber` - Remove compiled assets
|
|
59
|
+
- Assets are automatically served in development
|
|
60
|
+
|
|
61
|
+
### Testing Commands
|
|
62
|
+
- `bin/rails test` - Run all tests
|
|
63
|
+
- `bin/rails test:models` - Run model tests
|
|
64
|
+
- `bin/rails test:controllers` - Run controller tests
|
|
65
|
+
- `bin/rails test:system` - Run system tests
|
|
66
|
+
- `bin/rails test test/models/user_test.rb` - Run specific test file
|
|
67
|
+
|
|
68
|
+
### Console & Debugging
|
|
69
|
+
- `bin/rails console` or `bin/rails c` - Start Rails console
|
|
70
|
+
- `bin/rails console --sandbox` - Start console in sandbox mode
|
|
71
|
+
- `bin/rails dbconsole` or `bin/rails db` - Start database console
|
|
72
|
+
|
|
73
|
+
### Code Quality & Security (Rails 8 Defaults)
|
|
74
|
+
- `bin/rails rubocop` - Run RuboCop with Rails 8 Omakase config
|
|
75
|
+
- `bin/rails brakeman` - Run security scan (included by default)
|
|
76
|
+
- `bundle audit` - Check for vulnerable gems
|
|
77
|
+
|
|
78
|
+
## Deployment with Kamal 2 (Rails 8 Default)
|
|
79
|
+
|
|
80
|
+
### Kamal 2 Commands
|
|
81
|
+
- `kamal setup` - Initial server setup
|
|
82
|
+
- `kamal deploy` - Deploy application
|
|
83
|
+
- `kamal redeploy` - Redeploy without setup
|
|
84
|
+
- `kamal rollback` - Rollback to previous version
|
|
85
|
+
- `kamal logs` - View application logs
|
|
86
|
+
- `kamal logs --follow` - Follow logs in real-time
|
|
87
|
+
- `kamal shell` - SSH into deployed container
|
|
88
|
+
- `kamal details` - Show deployment details
|
|
89
|
+
|
|
90
|
+
### Kamal 2 Configuration
|
|
91
|
+
Configuration is automatically generated in `config/deploy.yml`:
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
# config/deploy.yml
|
|
95
|
+
service: myapp
|
|
96
|
+
image: myapp
|
|
97
|
+
servers:
|
|
98
|
+
- 192.168.1.1
|
|
99
|
+
registry:
|
|
100
|
+
server: registry.digitalocean.com
|
|
101
|
+
username: myusername
|
|
102
|
+
|
|
103
|
+
env:
|
|
104
|
+
clear:
|
|
105
|
+
RAILS_ENV: production
|
|
106
|
+
secret:
|
|
107
|
+
- RAILS_MASTER_KEY
|
|
108
|
+
|
|
109
|
+
builder:
|
|
110
|
+
multiarch: false
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Rails 8 Project Structure
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
myapp/
|
|
117
|
+
├── app/
|
|
118
|
+
│ ├── models/ # ActiveRecord models
|
|
119
|
+
│ ├── controllers/ # ActionController controllers
|
|
120
|
+
│ ├── views/ # ERB/HAML templates
|
|
121
|
+
│ ├── helpers/ # View helpers
|
|
122
|
+
│ ├── mailers/ # ActionMailer mailers
|
|
123
|
+
│ ├── jobs/ # ActiveJob jobs (Solid Queue)
|
|
124
|
+
│ ├── assets/ # Application assets (Propshaft)
|
|
125
|
+
│ └── javascript/ # JavaScript files
|
|
126
|
+
├── config/
|
|
127
|
+
│ ├── application.rb # Application configuration
|
|
128
|
+
│ ├── routes.rb # URL routing
|
|
129
|
+
│ ├── database.yml # Database configuration
|
|
130
|
+
│ ├── deploy.yml # Kamal 2 deployment config (NEW)
|
|
131
|
+
│ └── environments/ # Environment-specific configs
|
|
132
|
+
├── db/
|
|
133
|
+
│ ├── migrate/ # Database migrations
|
|
134
|
+
│ └── seeds.rb # Database seeds
|
|
135
|
+
├── test/ # Test files (default in Rails 8)
|
|
136
|
+
│ ├── models/
|
|
137
|
+
│ ├── controllers/
|
|
138
|
+
│ ├── integration/
|
|
139
|
+
│ └── system/
|
|
140
|
+
├── bin/ # Binstubs
|
|
141
|
+
├── config.ru # Rack configuration
|
|
142
|
+
├── Gemfile # Gem dependencies
|
|
143
|
+
├── Gemfile.lock # Locked gem versions
|
|
144
|
+
└── Dockerfile # Docker configuration (if using containers)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Rails 8 New Features Integration
|
|
148
|
+
|
|
149
|
+
### 1. SQLite Production Enhancements
|
|
150
|
+
Rails 8 makes SQLite production-ready:
|
|
151
|
+
|
|
152
|
+
```ruby
|
|
153
|
+
# config/database.yml
|
|
154
|
+
production:
|
|
155
|
+
adapter: sqlite3
|
|
156
|
+
database: storage/production.sqlite3
|
|
157
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
158
|
+
timeout: 5000
|
|
159
|
+
# New Rails 8 SQLite configurations
|
|
160
|
+
pragmas:
|
|
161
|
+
busy_timeout: 1000
|
|
162
|
+
journal_mode: WAL
|
|
163
|
+
synchronous: NORMAL
|
|
164
|
+
foreign_keys: true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 2. Solid Trifecta Configuration
|
|
168
|
+
|
|
169
|
+
#### Solid Queue (Background Jobs)
|
|
170
|
+
```ruby
|
|
171
|
+
# config/application.rb
|
|
172
|
+
config.active_job.queue_adapter = :solid_queue
|
|
173
|
+
|
|
174
|
+
# app/jobs/sample_job.rb
|
|
175
|
+
class SampleJob < ApplicationJob
|
|
176
|
+
queue_as :default
|
|
177
|
+
|
|
178
|
+
def perform(user)
|
|
179
|
+
# Background job logic
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Solid Cache (Caching)
|
|
185
|
+
```ruby
|
|
186
|
+
# config/application.rb
|
|
187
|
+
config.cache_store = :solid_cache_store
|
|
188
|
+
|
|
189
|
+
# Usage in controllers/models
|
|
190
|
+
Rails.cache.fetch("user_#{user.id}", expires_in: 1.hour) do
|
|
191
|
+
expensive_calculation(user)
|
|
192
|
+
end
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Solid Cable (WebSockets)
|
|
196
|
+
```ruby
|
|
197
|
+
# config/application.rb
|
|
198
|
+
config.action_cable.adapter = :solid_cable
|
|
199
|
+
|
|
200
|
+
# app/channels/chat_channel.rb
|
|
201
|
+
class ChatChannel < ApplicationCable::Channel
|
|
202
|
+
def subscribed
|
|
203
|
+
stream_from "chat_#{params[:room]}"
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 3. Native Authentication (Rails 8)
|
|
209
|
+
```ruby
|
|
210
|
+
# Generate authentication
|
|
211
|
+
bin/rails generate authentication User
|
|
212
|
+
|
|
213
|
+
# app/models/user.rb (generated)
|
|
214
|
+
class User < ApplicationRecord
|
|
215
|
+
has_secure_password
|
|
216
|
+
|
|
217
|
+
validates :email, presence: true, uniqueness: true
|
|
218
|
+
normalizes :email, with: ->(email) { email.strip.downcase }
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# app/controllers/application_controller.rb
|
|
222
|
+
class ApplicationController < ActionController::Base
|
|
223
|
+
before_action :authenticate_user!
|
|
224
|
+
|
|
225
|
+
private
|
|
226
|
+
|
|
227
|
+
def authenticate_user!
|
|
228
|
+
redirect_to login_path unless current_user
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def current_user
|
|
232
|
+
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 4. Propshaft Asset Pipeline
|
|
238
|
+
```ruby
|
|
239
|
+
# config/application.rb
|
|
240
|
+
# Propshaft is now the default - no configuration needed
|
|
241
|
+
|
|
242
|
+
# Assets are automatically fingerprinted and served
|
|
243
|
+
# Use asset helpers in views:
|
|
244
|
+
<%= asset_path("application.css") %>
|
|
245
|
+
<%= asset_path("logo.png") %>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Testing in Rails 8
|
|
249
|
+
|
|
250
|
+
### Default Test Suite Setup
|
|
251
|
+
Rails 8 includes comprehensive testing setup by default:
|
|
252
|
+
|
|
253
|
+
```ruby
|
|
254
|
+
# test/test_helper.rb
|
|
255
|
+
ENV["RAILS_ENV"] ||= "test"
|
|
256
|
+
require_relative "../config/environment"
|
|
257
|
+
require "rails/test_help"
|
|
258
|
+
|
|
259
|
+
module ActiveSupport
|
|
260
|
+
class TestCase
|
|
261
|
+
# Run tests in parallel with specified workers
|
|
262
|
+
parallelize(workers: :number_of_processors)
|
|
263
|
+
|
|
264
|
+
# Setup all fixtures in test/fixtures/*.yml
|
|
265
|
+
fixtures :all
|
|
266
|
+
|
|
267
|
+
# Add more helper methods to be used by all tests here...
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### System Testing with Capybara
|
|
273
|
+
```ruby
|
|
274
|
+
# test/system/users_test.rb
|
|
275
|
+
class UsersTest < ApplicationSystemTestCase
|
|
276
|
+
test "creating a user" do
|
|
277
|
+
visit new_user_path
|
|
278
|
+
|
|
279
|
+
fill_in "Name", with: "John Doe"
|
|
280
|
+
fill_in "Email", with: "john@example.com"
|
|
281
|
+
click_button "Create User"
|
|
282
|
+
|
|
283
|
+
assert_text "User was successfully created"
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Security Best Practices (Rails 8)
|
|
289
|
+
|
|
290
|
+
### Built-in Security Features
|
|
291
|
+
- **Brakeman** - Included by default for security scanning
|
|
292
|
+
- **Credential Management** - Use `rails credentials:edit`
|
|
293
|
+
- **Content Security Policy** - Configure in `application_controller.rb`
|
|
294
|
+
- **Force SSL** - Enable in production environment
|
|
295
|
+
|
|
296
|
+
```ruby
|
|
297
|
+
# config/environments/production.rb
|
|
298
|
+
config.force_ssl = true
|
|
299
|
+
config.content_security_policy do |policy|
|
|
300
|
+
policy.default_src :self, :https
|
|
301
|
+
policy.font_src :self, :https, :data
|
|
302
|
+
policy.img_src :self, :https, :data
|
|
303
|
+
policy.object_src :none
|
|
304
|
+
policy.script_src :self, :https
|
|
305
|
+
policy.style_src :self, :https, :unsafe_inline
|
|
306
|
+
end
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Performance Optimization
|
|
310
|
+
|
|
311
|
+
### Database Optimization
|
|
312
|
+
```ruby
|
|
313
|
+
# Use includes to avoid N+1 queries
|
|
314
|
+
@users = User.includes(:posts).all
|
|
315
|
+
|
|
316
|
+
# Use counter_cache for associations
|
|
317
|
+
class Post < ApplicationRecord
|
|
318
|
+
belongs_to :user, counter_cache: true
|
|
319
|
+
end
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Caching Strategies
|
|
323
|
+
```ruby
|
|
324
|
+
# Fragment caching in views
|
|
325
|
+
<% cache @user do %>
|
|
326
|
+
<%= render @user %>
|
|
327
|
+
<% end %>
|
|
328
|
+
|
|
329
|
+
# Action caching in controllers
|
|
330
|
+
class UsersController < ApplicationController
|
|
331
|
+
caches_action :index, expires_in: 1.hour
|
|
332
|
+
end
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Production Deployment Checklist
|
|
336
|
+
|
|
337
|
+
### Environment Configuration
|
|
338
|
+
- [ ] Set `RAILS_ENV=production`
|
|
339
|
+
- [ ] Configure `RAILS_MASTER_KEY` or `config/credentials.yml.enc`
|
|
340
|
+
- [ ] Set up database (PostgreSQL/MySQL for production)
|
|
341
|
+
- [ ] Configure email delivery
|
|
342
|
+
- [ ] Set up error monitoring (Sentry, Bugsnag)
|
|
343
|
+
- [ ] Configure logging and log rotation
|
|
344
|
+
|
|
345
|
+
### Kamal 2 Deployment
|
|
346
|
+
- [ ] Update `config/deploy.yml` with production servers
|
|
347
|
+
- [ ] Set up Docker registry access
|
|
348
|
+
- [ ] Configure environment variables and secrets
|
|
349
|
+
- [ ] Run `kamal setup` for initial deployment
|
|
350
|
+
- [ ] Deploy with `kamal deploy`
|
|
351
|
+
|
|
352
|
+
### Performance & Monitoring
|
|
353
|
+
- [ ] Enable asset precompilation
|
|
354
|
+
- [ ] Configure CDN for static assets
|
|
355
|
+
- [ ] Set up application performance monitoring (APM)
|
|
356
|
+
- [ ] Configure health checks
|
|
357
|
+
- [ ] Set up backup strategies for database
|
|
358
|
+
|
|
359
|
+
## Upgrading to Rails 8
|
|
360
|
+
|
|
361
|
+
### Migration Steps
|
|
362
|
+
1. Update Gemfile: `gem 'rails', '~> 8.0.0'`
|
|
363
|
+
2. Run `bundle update rails`
|
|
364
|
+
3. Run `bin/rails app:update` to update configuration files
|
|
365
|
+
4. Review and update deprecated code
|
|
366
|
+
5. Update test suite to use new defaults
|
|
367
|
+
6. Consider migrating to Solid trifecta adapters
|
|
368
|
+
7. Optionally migrate authentication to native Rails 8 system
|
|
369
|
+
|
|
370
|
+
### Breaking Changes to Consider
|
|
371
|
+
- Ruby 3.2+ requirement
|
|
372
|
+
- Propshaft replaces Sprockets by default
|
|
373
|
+
- Some deprecated ActiveRecord methods removed
|
|
374
|
+
- Updated default configurations for new applications
|
|
375
|
+
|
|
376
|
+
This Rails 8 configuration provides a modern, production-ready foundation with the latest Rails features and best practices.
|