This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This app is a Rails 8.1.1 application using:
- Ruby 3.3.10
- SQLite3 database
- Devise for authentication
- RSpec for testing
- Tailwind CSS for styling
- Turbo and Stimulus for interactivity
- Solid Cache, Solid Queue, and Solid Cable for infrastructure
bin/setup # Initial setup: installs dependencies, prepares database, starts server
bin/dev # Start development server with Foreman (Rails + Tailwind watch)
bin/rails server # Start Rails server only (port 3000)
bin/rails tailwindcss:watch # Watch Tailwind CSS changesbin/rails db:prepare # Create database, load schema, run migrations
bin/rails db:migrate # Run pending migrations
bin/rails db:rollback # Rollback last migration
bin/rails db:reset # Drop, create, and setup database
bin/rails db:seed # Load seed databundle exec rspec # Run all specs
bundle exec rspec spec/models # Run model specs
bundle exec rspec spec/path/to/file_spec.rb # Run specific file
bundle exec rspec spec/path/to/file_spec.rb:42 # Run specific lineRSpec is configured with:
- FactoryBot for test data (
spec/factories/) - SimpleCov for coverage reporting (
coverage/directory) - Shoulda Matchers for ActiveRecord/ActiveModel matchers
- Devise test helpers for authentication in specs
- Transactional fixtures enabled
bin/rubocop # Run RuboCop linter
bin/rubocop -a # Auto-correct offenses
bin/brakeman # Run security scanner
bundle exec bundle-audit check # Check for vulnerable gem versionsThe project uses rubocop-rails-omakase for Ruby styling conventions.
bin/rails generate # Run generators (model, controller, migration, etc.)
bin/rails console # Open Rails console
bin/rails routes # List all routes
bin/rails db:migrate:status # Check migration status- Devise handles all user authentication
- User model includes:
:database_authenticatable,:registerable,:recoverable,:rememberable,:validatable,:confirmable,:lockable,:timeoutable,:trackable - Devise routes mounted at
/users(sign in, sign up, etc.) - In development, LetterOpenerWeb is mounted at
/letter_openerto preview emails
- Module name:
MyApp(config/application.rb:9) - Rails 8.1 defaults loaded
- Autoload lib enabled, ignoring
assetsandtaskssubdirectories - Standard Rails MVC structure in
app/directory
- Tailwind CSS for styling (compiled via
tailwindcss-rails) - Turbo Rails for SPA-like navigation
- Stimulus for JavaScript interactions
- Importmap for JavaScript module management
- Assets in
app/assets/,app/javascript/
- Solid Queue for background job processing
- Solid Cache for caching
- Solid Cable for ActionCable (WebSockets)
- Configuration files:
config/queue.yml,config/cache.yml,config/cable.yml
- Kamal for deployment (config in
config/deploy.ymland.kamal/) - Thruster for HTTP/2 proxy
- Puma web server
- Dockerfile included for containerized deployment
- Spec files in
spec/directory - Factories in
spec/factories/ - Support files in
spec/support/ - Configuration:
spec/rails_helper.rbandspec/spec_helper.rb
# In request specs
include Devise::Test::IntegrationHelpers
sign_in user
# In controller specs
include Devise::Test::ControllerHelpers
sign_in user# Already included via config.include FactoryBot::Syntax::Methods
user = create(:user)
build(:user, email: 'test@example.com')- Access at
http://localhost:3000/letter_openerto view sent emails - Only available in development environment
- N+1 query detection enabled in development
- Alerts appear in browser and logs
- Health endpoint at
/upreturns 200 if app boots successfully - Used for load balancer health checks
- Database: SQLite3 in all environments (
storage/development.sqlite3, etc.) - Logs:
log/development.log,log/test.log - Credentials:
config/credentials.yml.enc(encrypted, usebin/rails credentials:edit) - Master key:
config/master.key(gitignored, required for decrypting credentials)
This project includes a comprehensive Claude Code infrastructure system for enhanced development workflows.
Skills provide domain-specific knowledge that activates automatically based on context.
Available Skills:
- rails-dev-guidelines - Rails MVC patterns, ActiveRecord, and best practices
- rspec-testing-guidelines - RSpec testing patterns, factories, and mocking
- devise-auth-patterns - Devise authentication and security
- frontend-rails-patterns - Views, Turbo, Stimulus, and Tailwind
- database-design-patterns - Schema design, migrations, and optimization
- security-best-practices - Rails security patterns (blocking enforcement)
Skill Usage:
# Skills activate automatically based on file context and keywords
# Manual activation available:
/skill rails-dev-guidelines
/skill rspec-testing-guidelinesConfiguration:
- Skills defined in
.claude/skills/ - Activation rules in
.claude/skills/skill-rules.json - Auto-activation via hooks (see below)
Agents provide focused, autonomous workflows for complex tasks.
Available Agents:
# Code review with comprehensive analysis
claude agent:rails-code-reviewer
# Plan and execute safe, incremental refactoring
claude agent:refactor-planner
# Debug and fix failing RSpec tests
claude agent:rspec-test-fixerAgent Characteristics:
- Autonomous operation for multi-step tasks
- Structured output documents in
dev/active/ - Request approval before making changes
- Reference skills and project conventions
Development documentation that survives context resets.
Commands:
# Create comprehensive development docs
/dev-docs [feature or task description]
# Update docs as work progresses
/dev-docs-updateOutput Structure:
dev/active/[task-name]/
├── [task-name]-plan.md # Strategic overview and phases
├── [task-name]-context.md # Decisions, files, and patterns
└── [task-name]-tasks.md # Detailed checklist
When to Use:
- Starting new features or refactoring
- Complex multi-day initiatives
- After context resets (docs provide full context)
- Tracking progress and decisions
Automated workflows that enhance development experience.
Active Hooks:
-
skill-activation-prompt (UserPromptSubmit)
- Analyzes prompts and file context
- Suggests relevant skills automatically
- Configured via
skill-rules.json
-
post-tool-use-tracker (PostToolUse)
- Tracks modified files after edits
- Suggests relevant checks (RuboCop, RSpec)
- Maintains session history in
.claude/cache/
Hook Logs:
# Modified files log
.claude/cache/session/[session-id]-modified-files.log
# Suggested checks
.claude/cache/session/[session-id]-checks-needed.logSkills follow a modular pattern to prevent context limit issues.
Structure:
.claude/skills/[skill-name]/
├── SKILL.md # Main file (≤500 lines)
└── resources/ # Detailed topic files (≤500 each)
├── topic-1.md
└── topic-2.md
Key Principles:
- Main SKILL.md provides overview and navigation
- Resources provide deep-dive content
- Progressive disclosure (load resources as needed)
- Clear cross-references between files
Skills activate based on:
- Keywords in prompts (e.g., "controller", "validation", "RSpec")
- Intent patterns (e.g., "create a model", "fix failing test")
- File patterns (e.g.,
app/models/**/*.rb,spec/**/*_spec.rb) - Mode:
suggest(recommend) orblock(require before proceeding)
Example Rule:
{
"name": "rails-dev-guidelines",
"mode": "suggest",
"priority": "high",
"triggers": {
"keywords": ["model", "controller", "migration"],
"filePatterns": ["app/models/**/*.rb", "app/controllers/**/*.rb"]
}
}Using Skills:
- Skills activate automatically in most cases
- Use
/skill [name]for manual activation - Skills reference each other for comprehensive guidance
- Check skill suggestions in hook output
Using Agents:
- Use for complex, multi-step operations
- Agents produce structured documentation
- Review agent output before approving changes
- Agents maintain project conventions
Using Dev Docs:
- Create at project start, not mid-way
- Update regularly with
/dev-docs-update - Reference after context resets
- Keep as source of truth for decisions
.claude/
├── hooks/ # Automation hooks
│ ├── skill-activation-prompt.js
│ └── post-tool-use-tracker.sh
├── skills/ # Domain knowledge
│ ├── skill-rules.json
│ ├── rails-dev-guidelines/
│ ├── rspec-testing-guidelines/
│ └── [other skills]/
├── agents/ # Specialized workflows
│ ├── rails-code-reviewer.md
│ ├── refactor-planner.md
│ └── rspec-test-fixer.md
└── commands/ # Slash commands
├── dev-docs.md
└── dev-docs-update.md
dev/active/ # Development docs
└── [task-name]/
├── [task-name]-plan.md
├── [task-name]-context.md
└── [task-name]-tasks.md
Adding a New Skill:
- Create directory:
.claude/skills/[skill-name]/ - Create
SKILL.mdwith structure (see existing skills) - Add resources in
resources/subdirectory - Add activation rule to
skill-rules.json - Test by triggering keywords or file patterns
Adding a New Agent:
- Create
.claude/agents/[agent-name].md - Define role, process, and output format
- Reference relevant skills and conventions
- Document constraints (e.g., "request approval first")
Modifying Hooks:
- Hooks in
.claude/hooks/are executable scripts - Respect hook types (UserPromptSubmit, PostToolUse, Stop)
- Test thoroughly as they affect all sessions
- Keep performance impact minimal
Skill not activating:
- Check
skill-rules.jsonfor trigger patterns - Verify hook is executable:
chmod +x .claude/hooks/*.js - Ensure keywords match your prompt
- Try manual activation:
/skill [name]
Hook not running:
- Verify hook is executable
- Check hook logs in
.claude/cache/ - Ensure hook type matches event (UserPromptSubmit, PostToolUse)
- Check for syntax errors in hook script
Dev docs out of sync:
- Run
/dev-docs-updateregularly - Keep manual changes in sync with code
- Use git to track doc changes
- Treat docs as code (review, commit)
- Skills inspired by claude-code-infrastructure-showcase
- Modular skill pattern follows 500-line rule for context efficiency
- Auto-activation system reduces cognitive load
- Dev docs pattern ensures continuity across context resets