chiron 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/.rspec +3 -0
- data/.rspec_status +7 -0
- data/.rubocop.yml +24 -0
- data/CHANGELOG.md +34 -0
- data/CLAUDE.md +108 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +93 -0
- data/LICENSE +21 -0
- data/README.md +155 -0
- data/Rakefile +12 -0
- data/docs/development_journal.md +60 -0
- data/exe/chiron +6 -0
- data/lib/chiron/cli.rb +259 -0
- data/lib/chiron/templates/CLAUDE.md.erb +97 -0
- data/lib/chiron/templates/claude/settings.json +6 -0
- data/lib/chiron/templates/commands/context/catchup.md +77 -0
- data/lib/chiron/templates/commands/context/prime.md +32 -0
- data/lib/chiron/templates/commands/context/quickstart.md +47 -0
- data/lib/chiron/templates/commands/conventions/rails.md +166 -0
- data/lib/chiron/templates/commands/journal/instructions.md +129 -0
- data/lib/chiron/templates/commands/journal/template.md +87 -0
- data/lib/chiron/templates/commands/quality/pre-commit.md +95 -0
- data/lib/chiron/templates/commands/quality/test-driven.md +187 -0
- data/lib/chiron/templates/commands/workflows/create-prd.md +57 -0
- data/lib/chiron/templates/commands/workflows/feature-complete.md +139 -0
- data/lib/chiron/templates/commands/workflows/generate-tasks.md +65 -0
- data/lib/chiron/templates/commands/workflows/process-tasks.md +84 -0
- data/lib/chiron/templates/development_journal.md.erb +80 -0
- data/lib/chiron/version.rb +5 -0
- data/lib/chiron.rb +16 -0
- metadata +174 -0
data/lib/chiron/cli.rb
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thor'
|
|
4
|
+
require 'tty-prompt'
|
|
5
|
+
require 'colorize'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
require 'erb'
|
|
8
|
+
require 'date'
|
|
9
|
+
|
|
10
|
+
module Chiron
|
|
11
|
+
class CLI < Thor
|
|
12
|
+
def self.exit_on_failure?
|
|
13
|
+
true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'init', 'Initialize Claude workflow in current Rails project'
|
|
17
|
+
option :project_name, type: :string, desc: 'Project name for CLAUDE.md'
|
|
18
|
+
option :with_oauth, type: :boolean, default: false, desc: 'Include OAuth workflow examples'
|
|
19
|
+
option :with_viewcomponents, type: :boolean, default: false, desc: 'Include ViewComponent rules'
|
|
20
|
+
option :skip_journal, type: :boolean, default: false, desc: 'Skip development journal setup'
|
|
21
|
+
def init
|
|
22
|
+
say 'š¤ Initializing Claude Rails Setup...'.colorize(:blue)
|
|
23
|
+
|
|
24
|
+
@prompt = TTY::Prompt.new
|
|
25
|
+
@project_name = options[:project_name] || prompt_for_project_name
|
|
26
|
+
|
|
27
|
+
check_rails_project
|
|
28
|
+
create_directories
|
|
29
|
+
copy_templates
|
|
30
|
+
update_gitignore
|
|
31
|
+
|
|
32
|
+
say "\n⨠Claude workflow initialized successfully!".colorize(:green)
|
|
33
|
+
say "\nNext steps:".colorize(:yellow)
|
|
34
|
+
say ' 1. Review and customize CLAUDE.md for your project'
|
|
35
|
+
say ' 2. Check .claude/commands/ for available workflows'
|
|
36
|
+
say " 3. Run 'claude' to start using Claude with your new setup"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc 'migrate-cursor', 'Migrate from .cursor to .claude structure'
|
|
40
|
+
def migrate_cursor
|
|
41
|
+
say 'š Migrating from .cursor to .claude...'.colorize(:blue)
|
|
42
|
+
|
|
43
|
+
unless Dir.exist?('.cursor/rules')
|
|
44
|
+
error 'No .cursor/rules directory found!'
|
|
45
|
+
exit 1
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
create_directories
|
|
49
|
+
migrate_rules
|
|
50
|
+
|
|
51
|
+
if @prompt.yes?('Remove .cursor directory after migration?')
|
|
52
|
+
FileUtils.rm_rf('.cursor')
|
|
53
|
+
say 'ā
.cursor directory removed'.colorize(:green)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
say "\n⨠Migration completed!".colorize(:green)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
desc 'add-workflow WORKFLOW', 'Add a specific workflow to your setup'
|
|
60
|
+
def add_workflow(workflow_name)
|
|
61
|
+
available_workflows = Dir.glob(File.join(templates_path, 'commands/**/*.md'))
|
|
62
|
+
.map { |f| File.basename(f, '.md') }
|
|
63
|
+
|
|
64
|
+
unless available_workflows.include?(workflow_name)
|
|
65
|
+
error "Unknown workflow: #{workflow_name}"
|
|
66
|
+
say "Available workflows: #{available_workflows.join(', ')}"
|
|
67
|
+
exit 1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
copy_workflow(workflow_name)
|
|
71
|
+
say "ā
Added #{workflow_name} workflow".colorize(:green)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc 'update', 'Update Claude workflows to latest version'
|
|
75
|
+
def update
|
|
76
|
+
say 'š Updating Claude workflows...'.colorize(:blue)
|
|
77
|
+
|
|
78
|
+
# Backup current commands
|
|
79
|
+
if Dir.exist?('.claude/commands')
|
|
80
|
+
backup_dir = ".claude/commands.backup.#{Time.now.strftime('%Y%m%d%H%M%S')}"
|
|
81
|
+
FileUtils.cp_r('.claude/commands', backup_dir)
|
|
82
|
+
say "š¦ Backed up current commands to #{backup_dir}".colorize(:yellow)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
copy_templates(update: true)
|
|
86
|
+
say "\n⨠Workflows updated!".colorize(:green)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
desc 'doctor', 'Check Claude setup health'
|
|
90
|
+
def doctor
|
|
91
|
+
say 'š„ Running Claude setup diagnostics...'.colorize(:blue)
|
|
92
|
+
|
|
93
|
+
checks = {
|
|
94
|
+
'Rails project' => Dir.exist?('app') && File.exist?('Gemfile'),
|
|
95
|
+
'CLAUDE.md exists' => File.exist?('CLAUDE.md'),
|
|
96
|
+
'.claude directory' => Dir.exist?('.claude'),
|
|
97
|
+
'.claude/commands' => Dir.exist?('.claude/commands'),
|
|
98
|
+
'Development journal' => File.exist?('docs/development_journal.md'),
|
|
99
|
+
'Tasks directory' => Dir.exist?('tasks'),
|
|
100
|
+
'.gitignore entry' => begin
|
|
101
|
+
File.read('.gitignore').include?('.claude/')
|
|
102
|
+
rescue StandardError
|
|
103
|
+
false
|
|
104
|
+
end
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
checks.each do |check, result|
|
|
108
|
+
status = result ? 'ā
'.colorize(:green) : 'ā'.colorize(:red)
|
|
109
|
+
say "#{status} #{check}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if checks.values.all?
|
|
113
|
+
say "\n⨠All checks passed!".colorize(:green)
|
|
114
|
+
else
|
|
115
|
+
say "\nā ļø Some checks failed. Run 'claude-rails init' to fix.".colorize(:yellow)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
desc 'version', 'Show version'
|
|
120
|
+
def version
|
|
121
|
+
say Chiron::VERSION
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private
|
|
125
|
+
|
|
126
|
+
def prompt_for_project_name
|
|
127
|
+
@prompt.ask("What's your project name?") do |q|
|
|
128
|
+
q.required true
|
|
129
|
+
q.default File.basename(Dir.pwd)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def check_rails_project
|
|
134
|
+
return if File.exist?('Gemfile') && File.read('Gemfile').include?('rails')
|
|
135
|
+
|
|
136
|
+
error "This doesn't appear to be a Rails project!"
|
|
137
|
+
exit 1
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def create_directories
|
|
141
|
+
dirs = [
|
|
142
|
+
'.claude/commands/workflows',
|
|
143
|
+
'.claude/commands/conventions',
|
|
144
|
+
'.claude/commands/context',
|
|
145
|
+
'.claude/commands/journal',
|
|
146
|
+
'.claude/commands/quality',
|
|
147
|
+
'tasks',
|
|
148
|
+
'docs'
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
dirs.each do |dir|
|
|
152
|
+
FileUtils.mkdir_p(dir)
|
|
153
|
+
say "š Created #{dir}".colorize(:light_blue) unless Dir.exist?(dir)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def copy_templates(update: false)
|
|
158
|
+
# Copy CLAUDE.md template
|
|
159
|
+
unless update
|
|
160
|
+
template_path = File.join(templates_path, 'CLAUDE.md.erb')
|
|
161
|
+
if File.exist?(template_path)
|
|
162
|
+
content = ERB.new(File.read(template_path)).result(binding)
|
|
163
|
+
File.write('CLAUDE.md', content)
|
|
164
|
+
say 'š Created CLAUDE.md'.colorize(:light_blue)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Copy command templates
|
|
169
|
+
copy_commands
|
|
170
|
+
|
|
171
|
+
# Copy settings.json
|
|
172
|
+
settings_path = File.join(templates_path, 'claude/settings.json')
|
|
173
|
+
if File.exist?(settings_path) && !File.exist?('.claude/settings.json')
|
|
174
|
+
FileUtils.cp(settings_path, '.claude/settings.json')
|
|
175
|
+
say 'āļø Created .claude/settings.json'.colorize(:light_blue)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Initialize development journal
|
|
179
|
+
return if options[:skip_journal] || File.exist?('docs/development_journal.md')
|
|
180
|
+
|
|
181
|
+
create_development_journal
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def copy_commands
|
|
185
|
+
commands_dir = File.join(templates_path, 'commands')
|
|
186
|
+
return unless Dir.exist?(commands_dir)
|
|
187
|
+
|
|
188
|
+
Dir.glob(File.join(commands_dir, '**/*.md')).each do |file|
|
|
189
|
+
relative_path = file.sub("#{commands_dir}/", '')
|
|
190
|
+
target_path = File.join('.claude/commands', relative_path)
|
|
191
|
+
|
|
192
|
+
FileUtils.mkdir_p(File.dirname(target_path))
|
|
193
|
+
FileUtils.cp(file, target_path)
|
|
194
|
+
say "š Copied #{relative_path}".colorize(:light_blue)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def create_development_journal
|
|
199
|
+
journal_template = File.join(templates_path, 'development_journal.md.erb')
|
|
200
|
+
return unless File.exist?(journal_template)
|
|
201
|
+
|
|
202
|
+
content = ERB.new(File.read(journal_template)).result(binding)
|
|
203
|
+
File.write('docs/development_journal.md', content)
|
|
204
|
+
say 'š Created development journal'.colorize(:light_blue)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def update_gitignore
|
|
208
|
+
gitignore_path = '.gitignore'
|
|
209
|
+
return unless File.exist?(gitignore_path)
|
|
210
|
+
|
|
211
|
+
gitignore_content = File.read(gitignore_path)
|
|
212
|
+
|
|
213
|
+
return if gitignore_content.include?('.claude/')
|
|
214
|
+
|
|
215
|
+
File.open(gitignore_path, 'a') do |f|
|
|
216
|
+
f.puts "\n# Claude Code settings (but allow commands directory)"
|
|
217
|
+
f.puts '.claude/*'
|
|
218
|
+
f.puts '!.claude/commands/'
|
|
219
|
+
end
|
|
220
|
+
say 'š Updated .gitignore'.colorize(:light_blue)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def migrate_rules
|
|
224
|
+
Dir.glob('.cursor/rules/*.mdc').each do |rule_file|
|
|
225
|
+
filename = File.basename(rule_file, '.mdc')
|
|
226
|
+
|
|
227
|
+
# Map cursor rules to claude command structure
|
|
228
|
+
target_dir = case filename
|
|
229
|
+
when 'create-prd', 'generate-tasks', 'process-task-list'
|
|
230
|
+
'.claude/commands/workflows'
|
|
231
|
+
when 'rails', 'view_component'
|
|
232
|
+
'.claude/commands/conventions'
|
|
233
|
+
when 'test-driven'
|
|
234
|
+
'.claude/commands/quality'
|
|
235
|
+
else
|
|
236
|
+
'.claude/commands/workflows'
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
target_path = File.join(target_dir, "#{filename}.md")
|
|
240
|
+
|
|
241
|
+
# Copy and transform the content
|
|
242
|
+
content = File.read(rule_file)
|
|
243
|
+
# Remove cursor-specific frontmatter
|
|
244
|
+
content = content.sub(/---.*?---/m, '').strip
|
|
245
|
+
|
|
246
|
+
File.write(target_path, content)
|
|
247
|
+
say "š Migrated #{filename}".colorize(:light_blue)
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def templates_path
|
|
252
|
+
Chiron.templates_path
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def error(message)
|
|
256
|
+
say "ā #{message}".colorize(:red)
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
<%= @project_name %> is a Rails <%= Rails.version rescue "8.0.2" %> application. [Add your project description here]
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
**Important**: Always use binstubs instead of `bundle exec` for better performance and consistency.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Setup
|
|
15
|
+
bundle install
|
|
16
|
+
bin/rails db:create db:migrate db:seed
|
|
17
|
+
|
|
18
|
+
# Development server
|
|
19
|
+
bin/rails server
|
|
20
|
+
# or with Procfile for concurrent processes
|
|
21
|
+
bin/dev
|
|
22
|
+
|
|
23
|
+
# Testing
|
|
24
|
+
bin/rspec # Run all tests
|
|
25
|
+
bin/rspec spec/models/ # Run specific test directory
|
|
26
|
+
bin/rspec spec/models/user_spec.rb # Run single test file
|
|
27
|
+
|
|
28
|
+
# Code quality
|
|
29
|
+
bin/rubocop # Linting
|
|
30
|
+
bin/rubocop --autocorrect # Auto-fix correctable violations
|
|
31
|
+
bin/brakeman # Security scanning
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Architecture Overview
|
|
35
|
+
|
|
36
|
+
### Key Models & Relationships
|
|
37
|
+
[Document your main models and their relationships]
|
|
38
|
+
|
|
39
|
+
### Core Services
|
|
40
|
+
[List your service objects and their purposes]
|
|
41
|
+
|
|
42
|
+
### Controllers Structure
|
|
43
|
+
[Describe your controller organization]
|
|
44
|
+
|
|
45
|
+
## Technical Stack
|
|
46
|
+
|
|
47
|
+
- **Framework**: Rails <%= Rails.version rescue "8.0.2" %> with Hotwire (Turbo + Stimulus)
|
|
48
|
+
- **Database**: PostgreSQL with Active Record
|
|
49
|
+
- **Frontend**: TailwindCSS, Stimulus controllers
|
|
50
|
+
<% if options[:with_viewcomponents] %>- **ViewComponent**: Component-based architecture for reusable UI elements<% end %>
|
|
51
|
+
- **Testing**: RSpec with FactoryBot
|
|
52
|
+
- **Background Jobs**: [Your job processor]
|
|
53
|
+
- **Authorization**: [Your authorization system]
|
|
54
|
+
|
|
55
|
+
## Environment Variables
|
|
56
|
+
|
|
57
|
+
Required for development:
|
|
58
|
+
```
|
|
59
|
+
# Add your required environment variables here
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Rails Conventions
|
|
63
|
+
|
|
64
|
+
- Standard Rails naming conventions (snake_case)
|
|
65
|
+
- RuboCop for code style enforcement
|
|
66
|
+
- Follow Rails best practices and idioms
|
|
67
|
+
|
|
68
|
+
## Development Patterns
|
|
69
|
+
|
|
70
|
+
### Component Architecture
|
|
71
|
+
- Use ViewComponent for reusable UI elements (located in `app/components/`)
|
|
72
|
+
- Follow Rails conventions with Hotwire for reactive interfaces
|
|
73
|
+
- Utilize Stimulus controllers for JavaScript interactions
|
|
74
|
+
|
|
75
|
+
### PRD Workflow
|
|
76
|
+
- Use `.claude/commands/workflows/create-prd.md` for structured feature development
|
|
77
|
+
- PRDs should be saved in `/tasks/` directory as `prd-[feature-name].md`
|
|
78
|
+
- Follow the clarifying questions process before implementation
|
|
79
|
+
|
|
80
|
+
### Code Quality
|
|
81
|
+
- RuboCop for consistent styling
|
|
82
|
+
- Brakeman for security scanning
|
|
83
|
+
- Comprehensive test coverage with RSpec
|
|
84
|
+
|
|
85
|
+
## Testing Standards
|
|
86
|
+
|
|
87
|
+
- Write tests before implementation (TDD)
|
|
88
|
+
- Maintain high test coverage
|
|
89
|
+
- Use FactoryBot for test data
|
|
90
|
+
- Follow RSpec best practices
|
|
91
|
+
|
|
92
|
+
## Important Reminders
|
|
93
|
+
|
|
94
|
+
- Always run tests before committing
|
|
95
|
+
- Use semantic commit messages
|
|
96
|
+
- Update the development journal for significant changes
|
|
97
|
+
- Follow the pre-commit checklist in `.claude/commands/quality/pre-commit.md`
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Catchup Command
|
|
2
|
+
|
|
3
|
+
Use this when the user asks "catchup", "where are we", or wants a project status update.
|
|
4
|
+
|
|
5
|
+
## Process
|
|
6
|
+
|
|
7
|
+
1. **Read Development Journal**
|
|
8
|
+
```
|
|
9
|
+
READ: docs/development_journal.md
|
|
10
|
+
```
|
|
11
|
+
Focus on the last 3-5 entries
|
|
12
|
+
|
|
13
|
+
2. **Check Active Work**
|
|
14
|
+
- List files in /tasks/ directory
|
|
15
|
+
- Identify incomplete tasks
|
|
16
|
+
- Note any blocked items
|
|
17
|
+
|
|
18
|
+
3. **Review Current Branch**
|
|
19
|
+
```bash
|
|
20
|
+
git branch --show-current
|
|
21
|
+
git status --short
|
|
22
|
+
git log --oneline -5
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
4. **Test Status**
|
|
26
|
+
```bash
|
|
27
|
+
bin/rspec --format progress | tail -5
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Summary Format
|
|
31
|
+
|
|
32
|
+
Provide a structured summary:
|
|
33
|
+
|
|
34
|
+
### Recent Progress
|
|
35
|
+
- Last 3 significant accomplishments
|
|
36
|
+
- Who worked on what (from journal)
|
|
37
|
+
- Key problems solved
|
|
38
|
+
|
|
39
|
+
### Current State
|
|
40
|
+
- Active branch and purpose
|
|
41
|
+
- Pending changes
|
|
42
|
+
- Test suite status
|
|
43
|
+
- Any known issues
|
|
44
|
+
|
|
45
|
+
### Next Steps
|
|
46
|
+
- Immediate tasks to complete
|
|
47
|
+
- Blocked items needing attention
|
|
48
|
+
- Suggested priorities
|
|
49
|
+
|
|
50
|
+
## Example Response
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
Here's where we are:
|
|
54
|
+
|
|
55
|
+
**Recent Work:**
|
|
56
|
+
- Fixed authentication modal bugs (3 critical issues resolved)
|
|
57
|
+
- Implemented Phase 1 of in-kind donation form
|
|
58
|
+
- Set up real-time OAuth status monitoring
|
|
59
|
+
|
|
60
|
+
**Current State:**
|
|
61
|
+
- Branch: feature/treasury_forms (working on treasury reimbursement features)
|
|
62
|
+
- All tests passing (247 examples, 0 failures)
|
|
63
|
+
- No uncommitted changes
|
|
64
|
+
|
|
65
|
+
**Next Steps:**
|
|
66
|
+
1. Complete remaining tasks for treasury forms (3 tasks pending)
|
|
67
|
+
2. Address RuboCop warnings in recent changes
|
|
68
|
+
3. Update documentation for new features
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Tips
|
|
72
|
+
|
|
73
|
+
- Be concise but comprehensive
|
|
74
|
+
- Highlight blockers or issues
|
|
75
|
+
- Include contributor attribution
|
|
76
|
+
- Suggest logical next actions
|
|
77
|
+
- Reference specific files/lines when relevant
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Context Window Prime
|
|
2
|
+
|
|
3
|
+
## Quick Context Loading
|
|
4
|
+
|
|
5
|
+
1. **Read Project Configuration**
|
|
6
|
+
```
|
|
7
|
+
READ: CLAUDE.md
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Show Project Structure**
|
|
11
|
+
```bash
|
|
12
|
+
# If eza is available
|
|
13
|
+
eza . --tree --level 3 --git-ignore
|
|
14
|
+
|
|
15
|
+
# Otherwise use standard ls
|
|
16
|
+
ls -la
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. **Check Current Status**
|
|
20
|
+
```bash
|
|
21
|
+
git status --short
|
|
22
|
+
git branch --show-current
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
This is a minimal context prime for when you need to quickly understand:
|
|
28
|
+
- Project configuration and conventions
|
|
29
|
+
- Directory structure
|
|
30
|
+
- Current git state
|
|
31
|
+
|
|
32
|
+
For more detailed context, use the `quickstart` command.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Quick Start Context
|
|
2
|
+
|
|
3
|
+
Use this command to quickly get up to speed with the current project state.
|
|
4
|
+
|
|
5
|
+
## Steps
|
|
6
|
+
|
|
7
|
+
1. **Read Project Documentation**
|
|
8
|
+
- READ: CLAUDE.md
|
|
9
|
+
- READ: README.md (if different from CLAUDE.md)
|
|
10
|
+
|
|
11
|
+
2. **Check Current Status**
|
|
12
|
+
```bash
|
|
13
|
+
git status
|
|
14
|
+
git log --oneline -5
|
|
15
|
+
git branch --show-current
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. **Review Recent Work**
|
|
19
|
+
- READ: docs/development_journal.md (last 3 entries)
|
|
20
|
+
- Check for active tasks in /tasks/ directory
|
|
21
|
+
|
|
22
|
+
4. **Quick Test Status**
|
|
23
|
+
```bash
|
|
24
|
+
bin/rspec --fail-fast
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
5. **Check Code Quality**
|
|
28
|
+
```bash
|
|
29
|
+
bin/rubocop --format simple | tail -20
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Output Summary
|
|
33
|
+
|
|
34
|
+
After running these steps, provide a concise summary:
|
|
35
|
+
- Current branch and its purpose
|
|
36
|
+
- Recent work completed
|
|
37
|
+
- Any failing tests or quality issues
|
|
38
|
+
- Active tasks or PRDs
|
|
39
|
+
- Suggested next steps
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
This is ideal for:
|
|
44
|
+
- Starting a new work session
|
|
45
|
+
- After switching branches
|
|
46
|
+
- When returning to a project after time away
|
|
47
|
+
- Before pair programming sessions
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Rails Development Conventions
|
|
2
|
+
|
|
3
|
+
You are an expert in Ruby on Rails, PostgreSQL, Hotwire (Turbo and Stimulus), and Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Code Style and Structure
|
|
6
|
+
- Write concise, idiomatic Ruby code with accurate examples
|
|
7
|
+
- Follow Rails conventions and best practices
|
|
8
|
+
- Use object-oriented and functional programming patterns as appropriate
|
|
9
|
+
- Prefer iteration and modularization over code duplication
|
|
10
|
+
- Use descriptive variable and method names (e.g., `user_signed_in?`, `calculate_total`)
|
|
11
|
+
- Structure files according to Rails conventions (MVC, concerns, helpers, etc.)
|
|
12
|
+
|
|
13
|
+
## Naming Conventions
|
|
14
|
+
- Use snake_case for file names, method names, and variables
|
|
15
|
+
- Use CamelCase for class and module names
|
|
16
|
+
- Follow Rails naming conventions for models, controllers, and views
|
|
17
|
+
- Use meaningful names that express intent
|
|
18
|
+
|
|
19
|
+
## Ruby and Rails Usage
|
|
20
|
+
- Use Ruby 3.x features when appropriate (pattern matching, endless methods)
|
|
21
|
+
- Leverage Rails' built-in helpers and methods
|
|
22
|
+
- Use ActiveRecord effectively for database operations
|
|
23
|
+
- Follow RESTful routing conventions
|
|
24
|
+
- Use concerns for shared behavior across models or controllers
|
|
25
|
+
|
|
26
|
+
## Rails 8 Specific Features
|
|
27
|
+
- Use the `encrypts` macro for sensitive data:
|
|
28
|
+
```ruby
|
|
29
|
+
class User < ApplicationRecord
|
|
30
|
+
encrypts :api_key
|
|
31
|
+
encrypts :personal_data
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
- Leverage Solid Queue for background jobs
|
|
35
|
+
- Use Solid Cache for caching
|
|
36
|
+
- Take advantage of Propshaft for assets
|
|
37
|
+
|
|
38
|
+
## Syntax and Formatting
|
|
39
|
+
- Follow the Ruby Style Guide (https://rubystyle.guide/)
|
|
40
|
+
- Use Ruby's expressive syntax (e.g., `unless`, `||=`, `&.`)
|
|
41
|
+
- Prefer single quotes for strings unless interpolation is needed
|
|
42
|
+
- Use modern hash syntax: `{ key: value }`
|
|
43
|
+
- Keep methods small and focused
|
|
44
|
+
|
|
45
|
+
## Error Handling and Validation
|
|
46
|
+
- Use exceptions for exceptional cases, not for control flow
|
|
47
|
+
- Implement proper error logging and user-friendly messages
|
|
48
|
+
- Use ActiveModel validations in models
|
|
49
|
+
- Handle errors gracefully in controllers with appropriate responses
|
|
50
|
+
- Use strong parameters for mass assignment protection
|
|
51
|
+
|
|
52
|
+
## Database and ActiveRecord
|
|
53
|
+
- Write efficient queries using includes, joins, or select
|
|
54
|
+
- Avoid N+1 queries with eager loading
|
|
55
|
+
- Use database indexes effectively
|
|
56
|
+
- Write reversible migrations
|
|
57
|
+
- Use scopes for commonly used queries
|
|
58
|
+
- Leverage ActiveRecord callbacks judiciously
|
|
59
|
+
|
|
60
|
+
## Testing Approach
|
|
61
|
+
- Write comprehensive tests using RSpec
|
|
62
|
+
- Follow TDD/BDD practices
|
|
63
|
+
- Use factories (FactoryBot) for test data
|
|
64
|
+
- Write unit tests for models and services
|
|
65
|
+
- Write integration tests for controllers
|
|
66
|
+
- Write system tests for user workflows
|
|
67
|
+
- Aim for high test coverage
|
|
68
|
+
|
|
69
|
+
## UI and Frontend
|
|
70
|
+
- Use Hotwire (Turbo and Stimulus) for dynamic interactions
|
|
71
|
+
- Implement responsive design with Tailwind CSS
|
|
72
|
+
- Use Rails view helpers and partials to keep views DRY
|
|
73
|
+
- Leverage ViewComponent for reusable UI components
|
|
74
|
+
- Use Turbo Frames for partial page updates
|
|
75
|
+
- Use Turbo Streams for real-time updates
|
|
76
|
+
|
|
77
|
+
## Performance Optimization
|
|
78
|
+
- Use database indexing effectively
|
|
79
|
+
- Implement caching strategies:
|
|
80
|
+
- Fragment caching for views
|
|
81
|
+
- Russian Doll caching for nested content
|
|
82
|
+
- Low-level caching for expensive operations
|
|
83
|
+
- Use background jobs for time-consuming tasks
|
|
84
|
+
- Optimize asset delivery with CDNs
|
|
85
|
+
- Monitor and optimize database queries
|
|
86
|
+
|
|
87
|
+
## Security Best Practices
|
|
88
|
+
- Use strong parameters in controllers
|
|
89
|
+
- Implement proper authentication (e.g., Devise, custom)
|
|
90
|
+
- Use authorization (e.g., Pundit, CanCanCan)
|
|
91
|
+
- Protect against common vulnerabilities:
|
|
92
|
+
- XSS (Rails handles by default)
|
|
93
|
+
- CSRF (use Rails tokens)
|
|
94
|
+
- SQL injection (use parameterized queries)
|
|
95
|
+
- Keep dependencies updated
|
|
96
|
+
- Use encrypted credentials for secrets
|
|
97
|
+
|
|
98
|
+
## Service Objects Pattern
|
|
99
|
+
```ruby
|
|
100
|
+
# app/services/user_registration_service.rb
|
|
101
|
+
class UserRegistrationService
|
|
102
|
+
def initialize(params)
|
|
103
|
+
@params = params
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def call
|
|
107
|
+
ActiveRecord::Base.transaction do
|
|
108
|
+
user = User.create!(@params)
|
|
109
|
+
send_welcome_email(user)
|
|
110
|
+
track_registration(user)
|
|
111
|
+
user
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def send_welcome_email(user)
|
|
118
|
+
UserMailer.welcome(user).deliver_later
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def track_registration(user)
|
|
122
|
+
Analytics.track('User Registered', user_id: user.id)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Background Jobs
|
|
128
|
+
```ruby
|
|
129
|
+
# app/jobs/data_import_job.rb
|
|
130
|
+
class DataImportJob < ApplicationJob
|
|
131
|
+
queue_as :default
|
|
132
|
+
|
|
133
|
+
def perform(file_path)
|
|
134
|
+
DataImporter.new(file_path).import
|
|
135
|
+
rescue StandardError => e
|
|
136
|
+
Rails.logger.error "Import failed: #{e.message}"
|
|
137
|
+
raise
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## API Development
|
|
143
|
+
- Use Rails API mode for API-only applications
|
|
144
|
+
- Implement versioning for APIs
|
|
145
|
+
- Use serializers for JSON responses
|
|
146
|
+
- Implement proper authentication (JWT, OAuth)
|
|
147
|
+
- Follow REST principles
|
|
148
|
+
- Document APIs thoroughly
|
|
149
|
+
|
|
150
|
+
## Deployment Considerations
|
|
151
|
+
- Use environment variables for configuration
|
|
152
|
+
- Implement health check endpoints
|
|
153
|
+
- Set up proper logging and monitoring
|
|
154
|
+
- Use asset precompilation
|
|
155
|
+
- Configure database connection pooling
|
|
156
|
+
- Set up SSL/TLS properly
|
|
157
|
+
|
|
158
|
+
## Common Pitfalls to Avoid
|
|
159
|
+
- Don't use inline styles or JavaScript
|
|
160
|
+
- Avoid fat controllers - keep them thin
|
|
161
|
+
- Don't skip validations or tests
|
|
162
|
+
- Avoid modifying core classes
|
|
163
|
+
- Don't store sensitive data in code
|
|
164
|
+
- Avoid premature optimization
|
|
165
|
+
|
|
166
|
+
Remember: Convention over Configuration - follow Rails conventions unless you have a very good reason not to!
|