This file provides specific guidance for AI agents working on the Exercism website codebase.
For comprehensive documentation about the application architecture, setup, and patterns, see docs/context/overview.md. The docs/context/ directory contains detailed documentation on all aspects of the application:
overview.md- Complete application documentation and setup guiderunning-the-app.md- Environment setup and development servercommands.md- Mandate command pattern documentationAPI.md- API architecture and authentication patternsSPI.md- Internal service endpointstesting/- Comprehensive testing patterns and examplestesting/screenshots.md- Screenshot generation and visual testing with AI analysis
- And more component-specific documentation
Always reference the relevant docs in docs/context/ when working on specific features.
Validation commands:
- Tests:
bin/rails test(Rails TestUnit with FactoryBot) - Linting:
bin/rubocop -a(auto-fixes issues) - Security:
bin/brakeman
IMPORTANT: Linting and security checks are run automatically by the git pre-commit hook. For basic changes, you don't need to run these yourself - just let the git hook handle it when you commit. For more complex changes, run tests manually during development, but leave rubocop and brakeman to the git hook. If making front-end changes, run yarn test before committing.
Development server:
./bin/dev # Preferred - handles all setup automaticallyManual testing:
bundle exec rails test # Ruby tests (10-15 min)
bundle exec rails test test/system # System tests (15-20 min)
yarn test # JavaScript tests (2-3 min)Asset builds:
yarn build:css && yarn build # Build all assets
rm -rf .built-assets/ # Clear asset cache if neededCommand Pattern (Critical):
- Business logic goes in
/app/commands/using Mandate gem - Controllers delegate to commands:
cmd = User::Update.(user, params) - Use
.on_successand.on_failurecallbacks in API controllers - Commands should have short
callmethods that delegate to private methods
Testing Patterns:
- Use FactoryBot:
create :userfor persisted,build :userfor unsaved - Minitest framework with helper methods in
test/test_helper.rb - System tests use Capybara for browser automation
- See
docs/context/testing/for detailed patterns
API Architecture:
/apiroutes for authenticated public endpoints (CLI, frontend)/spiroutes for internal AWS Lambda services- Always use Bearer token authentication for API
- Delegate business logic to commands, keep controllers thin
- Do not use
git -C <path>. Instead,cdto the correct directory before running git commands. This avoids issues with worktrees and ensures hooks run in the right context.
Never cancel long-running operations:
bundle install: 15-20 minutes (native extensions)- Full test suite: 10-15 minutes
- System tests: 15-20 minutes
Version requirements (exact):
- Ruby 3.4.4 (will fail with other versions)
- Node.js 20+
- MySQL 5.7
Required services:
- Docker (LocalStack, OpenSearch)
- Redis, MySQL
- Run
./bin/devto start everything
Key directories:
app/commands/- Business logic (Mandate pattern)app/controllers/api/- Public API endpointsapp/controllers/spi/- Internal service endpointstest/- All test filesdocs/context/- Detailed component documentation
When editing:
- Read relevant
docs/context/*.mdfiles first - Follow existing patterns in similar files
- Use commands for business logic, not controllers
- Add appropriate tests (see testing docs)
- Run pre-commit validation commands
docs/context/overview.md- Complete codebase documentation and setup guidedocs/context/running-the-app.md- Environment setup and development serverdocs/context/commands.md- Command pattern detailsdocs/context/testing/- Testing patterns and examples