This file contains instructions for Claude Code instances working on this project.
🚨 STOP! BEFORE ANY GIT COMMIT 🚨
You MUST ask the user "Would you like me to commit these changes?" and wait for explicit confirmation BEFORE running
git commit. This is NON-NEGOTIABLE. Never auto-commit.
NEVER commit changes you did not make in this session.
ALWAYS ask for user confirmation before committing. Do not commit automatically. Show the user:
- The files that will be committed
- The proposed commit message
- Wait for explicit approval (e.g., "yes", "ok", "commit it") before running
git commit
If you commit without asking first, you have violated the most important rule in this file.
Before committing:
- Run
git statusto see ALL modified and untracked files - Identify which files YOU modified vs files that were already modified before your session
- Only stage files YOU explicitly created or modified
- If you see untracked files or modifications you didn't make, DO NOT add them
When staging files:
- Use specific file paths:
git add path/to/file.rbinstead ofgit add .orgit add -A - After staging, verify with
git diff --cached --statthat only your changes are included - If unsure, ask the user before committing
Common mistakes to avoid:
- Using
git add .which adds ALL changes including other sessions' work - Using
git add folder/when other files in that folder were modified by someone else - Not checking
git statusbefore committing
NEVER make direct database changes to fix issues. All fixes must be made in code (seed files, migrations, rake tasks, etc.) that can be committed to git.
- If you modify database records directly (e.g., via
rails runner,rails console, or any SQL), you have NOT fixed the issue - Always find and edit the source files (seed YAML files, migrations, etc.) that populate the database
- If the only solution appears to be a direct database edit, you MUST explicitly ask for permission first and explain why a code-based solution isn't possible
- Never claim an issue is "fixed" when only database records were changed - such changes are lost on reseed/reset
🔴 MANDATORY: Every bug fix MUST include test coverage analysis
After fixing any bug or error, you MUST:
- Analyze why the bug wasn't caught by existing tests
- Add a test that would have caught it
- Search for similar issues elsewhere in the codebase
This is NOT optional. Do not consider a bug "fixed" until you've completed all three steps.
Ask yourself: "Why was this not caught in a test?" Common reasons:
- No test exists for the affected code path
- Tests mock at too high a level and don't exercise the actual code
- Tests don't cover the specific configuration/integration being used
- Hardcoded values bypass configurable settings
- Async jobs are enqueued but not executed in tests
- Autoloading behaves differently in test vs runtime
- Edge cases or error handling paths aren't covered
Create a test that would have caught this bug. The test should:
- Fail without your fix (verify by mentally reviewing)
- Pass with your fix
- Be specific enough to catch regressions
- Test the actual integration, not just mocked behavior
Use grep/search to find similar patterns that might have the same problem:
- If you fixed a missing
super()argument, check other subclasses - If you fixed a hardcoded value ignoring settings, search for similar hardcoding
- If you fixed an autoloading issue, check similar module structures
- If you fixed a multi-tenant scope issue, check similar queries
Example: Search command
# If you fixed "model: DEFAULT_MODEL" ignoring integration settings:
grep -r "model: DEFAULT_MODEL" app/services/Example 1: Missing parent initialization
1. User reports: "AI is not configured" error
2. Fix: Pass `website` to parent class in ScriptGenerator
3. Ask: "Why wasn't this caught?" → No tests for ScriptGenerator existed
4. Add: spec/services/video/script_generator_spec.rb with 27 tests
5. Check: grep for "super()" in other AI service subclasses
Example 2: Hardcoded values ignoring configuration
1. User reports: OpenRouter configured but still uses Anthropic
2. Fix: Remove hardcoded `model: DEFAULT_MODEL` from call_llm methods
3. Ask: "Why wasn't this caught?" → Tests mocked the chat() method
4. Add: Test that verifies integration's model setting is respected
5. Check: grep "model: DEFAULT_MODEL" found 2 more services with same issue
IMPORTANT: Never create documentation files at the project root.
All documentation must be placed in the docs/ folder structure:
docs/- General project documentationdocs/architecture/- Architecture decisions and system designdocs/seeding/- Seed data and seed packs documentationdocs/multi_tenancy/- Multi-tenancy related documentationdocs/claude_thoughts/- Claude's research, analysis, and exploratory notesdocs/deployment/- Deployment guides and configurationsdocs/admin/- Admin interface documentationdocs/field_keys/- Field keys system documentation
Use this folder for:
- Exploratory research and analysis
- Architecture investigation findings
- Decision rationale documents
- Any temporary or working documents
Only these markdown files should exist at the project root:
README.md- Main project readmeREADME_*.md- Translated readmes (es, ru, tr, etc.)CHANGELOG.md- Version changelogCONTRIBUTING.md- Contribution guidelinesCLAUDE.md- This file (Claude instructions)
- Use Rails conventions
- Follow existing patterns in the codebase
- Prefer editing existing files over creating new ones
- Run tests before committing significant changes
IMPORTANT: Vue.js is DEPRECATED. Do not use or extend Vue components.
The frontend uses server-rendered pages:
- ERB templates - Standard Rails views (
app/views/) - Liquid templates - Dynamic page parts and theming (
app/themes/) - Tailwind CSS - All styling (no Bootstrap)
- Stimulus.js - For JavaScript interactions (preferred)
app/frontend/- Vue.js apps (seeapp/frontend/DEPRECATED.md)app/graphql/- GraphQL API (seeapp/graphql/DEPRECATED.md)- Bootstrap CSS (see
vendor/assets/stylesheets/bootstrap/DEPRECATED.md)
If Stimulus controllers aren't loading after changes to JavaScript files:
- Clear tmp cache:
rm -rf tmp/cache/assets - Restart Rails server
- Hard refresh browser (Cmd+Shift+R or Ctrl+Shift+R)
WARNING: Do NOT use rails assets:clobber - it deletes the pre-built Tailwind CSS files in app/assets/builds/ which are checked into git. If you accidentally run it, restore the files with git restore app/assets/builds/.
IMPORTANT: Use Playwright for all browser/E2E testing. Do NOT use Selenium or Capybara JS drivers.
- Playwright is the preferred browser automation tool
- Do NOT add Selenium WebDriver or Capybara JS drivers (apparition, poltergeist, etc.)
- Use RSpec for Ruby unit and integration tests
- Use FactoryBot for test data
- Feature specs should NOT use
js: true- keep them as request/controller specs
npx playwright testThis is a multi-tenant application where each website is a tenant. Always:
- Scope queries to
current_websiteorPwb::Current.website - Use
website_idforeign keys for tenant-scoped models - Test cross-tenant isolation in specs