Skip to content

Add CLAUDE.md for LLM agent assistance #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
72 changes: 72 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Ruby LSP Rails is a Ruby LSP add-on that provides Rails-specific editor features. It's designed to work with the Ruby LSP to enhance Rails development experience in supported editors.

## Development Commands

### Testing
- `bundle exec rake test` - Run full test suite
- `bin/rails test test/my_test.rb` - Run a specific test file

### Linting and Code Quality
- `bin/rubocop` - Run RuboCop linting
- `bundle exec srb tc` - Run Sorbet type checking

### Database
- Database setup is handled by `bundle exec rails db:setup`
- The dummy Rails app is located in `test/dummy/` and is used for testing

## Architecture

### Core Components

**Main Entry Point**: `lib/ruby_lsp/ruby_lsp_rails/addon.rb`

**Add-on System**: `lib/ruby_lsp/ruby_lsp_rails/addon.rb` - Main add-on class that extends RubyLsp::Addon
- Manages lifecycle (activate/deactivate)
- Coordinates feature listeners (hover, completion, definition, etc.)
- Handles Rails-specific functionality like migration prompts
- Uses background thread to initialize Rails runner client

**Server Component**: `lib/ruby_lsp/ruby_lsp_rails/server.rb` - Separate Rails process server
- Runs as isolated process to handle Rails-specific queries
- Provides database schema information, model details, associations
- Handles route information and migration status
- Communicates via JSON-RPC over stdin/stdout

**Client Component**: `lib/ruby_lsp/ruby_lsp_rails/runner_client.rb`
- Client for communicating with server process

**Feature Modules**:
- `hover.rb` - Provides hover information for Rails concepts
- `definition.rb` - Go-to-definition for Rails constructs
- `completion.rb` - Rails-specific autocompletion
- `code_lens.rb` - Code lens features
- `document_symbol.rb` - Document symbol provider
- `indexing_enhancement.rb` - Enhanced indexing for Rails

**Support Modules**:
- `support/associations.rb` - ActiveRecord associations handling
- `support/callbacks.rb` - Rails callbacks support
- `support/location_builder.rb` - Location utilities

### Test Structure

**Dummy Rails App**: `test/dummy/` contains a minimal Rails application for testing
- Standard Rails structure with models, controllers, views
- Database migrations and schema
- Used to test Rails-specific features in realistic environment

**Test Files**: Located in `test/ruby_lsp_rails/`

### Type System

The project uses Sorbet for static typing:
- `# typed: strict` annotations on most files
- Type signatures using Sorbet RBS comments (https://sorbet.org/docs/rbs-support)
- Sorbet configuration in `sorbet/config`
- Generated RBI files in `sorbet/rbi/`
Loading