diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d9751921d..138c038e9 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,48 +1,19 @@ -# This is a Ruby on Rails application. +# This project is a Ruby on Rails application. -For project overview, tech stack, architecture reference (models, controllers, services, testing), and more, read `AGENTS.md`. - -## Setup - -Full setup (bundle, npm, database create/migrate/seed): -``` -bin/setup -``` - -If you just need frontend dependencies: -``` -npm ci -``` - -## AI Instruction Files - -When the user says "AI files", "AI instructions", "tell AI to", or "remember to always", these are the files. -If you notice the user repeatedly correcting the same pattern, suggest adding it to the AI files with a concrete proposal. - -| File | Purpose | -|---|---| -| `CLAUDE.md` | Coding rules and conventions (this file) | -| `AGENTS.md` | Architecture reference + project details | -| `.github/copilot-instructions.md` | Coding rules for Copilot (duplicated from CLAUDE.md — keep in sync) | -| `ai/` | Shell script shortcuts for common dev tasks | - -## Related Files - -When changing a model or controller, check whether these related files need updates: - -| If you change... | Also check... | -|---|---| -| Model | Decorator, policy, factory, model spec | -| Controller | Policy, request spec, routing spec, views | -| View | System spec, Stimulus controller (if interactive) | -| Service | Service spec | -| Decorator | Decorator spec | -| Mailer (add/remove) | Mailer spec, mailer preview (follow existing patterns) | -| Add/remove model, concern, service, or gem | AGENTS.md | +# Frontend requirements: +- Strongly prefer Stimulus for JavaScript behavior — do not write raw/inline JS or jQuery +- Always use Tailwind CSS utility classes for styling — do not write custom CSS unless absolutely necessary +- Prefer Turbo for navigation and form submissions before reaching for Stimulus +- ES6+ syntax, ESM imports/exports +- Stimulus controller naming: `[name]_controller.js` -## Code Style +# PRs +- After completing work, create a pull request using `gh pr create` +- Once the PR is created, prepend the PR number to the branch name (e.g., rename `maebeale/fix-login` to `maebeale/1234-fix-login`) using `git branch -m` and `git push origin -u` with the new name, then delete the old remote branch +- On every push, update the PR title and description to reflect the current diff +# Code style requirements: - Use modern Ruby syntax - Prefer early returns and guard clauses - Avoid unnecessary and/or complex conditionals @@ -51,59 +22,56 @@ When changing a model or controller, check whether these related files need upda - Use `presence` over blank checks - Use `Arel.sql` for raw SQL in order clauses - Avoid `update_all` unless explicitly intended -- Prefer service objects under app/services/ +- Prefer service objects under app/services - Prefer POROs over concerns when possible - Use `after_commit` instead of `after_save` for side effects -## RuboCop (rubocop-rails-omakase) - +# RuboCop (rubocop-rails-omakase) This project uses rubocop-rails-omakase. All code MUST follow these rules: -### Strings -- **Always use double quotes** for strings: `"foo"` not `'foo'` - -### Spacing -- **Spaces inside array brackets:** `[ a, b, c ]` not `[a, b, c]` (empty arrays: `[]`) -- **Spaces inside hash braces:** `{ a: 1, b: 2 }` not `{a: 1}` (empty hashes: `{}`) -- **Spaces inside block braces:** `foo { bar }` not `foo {bar}` (empty blocks: `foo { }`) -- **No spaces inside parens:** `foo(bar)` not `foo( bar )` -- **No spaces inside reference brackets:** `hash[:key]` not `hash[ :key ]` -- **Space before block braces:** `foo { }` not `foo{ }` - -### Commas -- **No trailing commas** in arrays, hashes, or method arguments - -### Indentation -- **2-space indentation**, no tabs -- **Consistent indentation** at normal level — do NOT indent methods under `private`/`protected` -- **Align `end` with the variable** in assignments: - ```ruby - result = if condition - value - end - ``` -- **Align `when` with `end`**, not with `case` - -### Whitespace -- **No trailing whitespace** on any line -- **No trailing blank lines** at end of file -- **No empty lines** inside class, module, method, or block bodies - -### Syntax -- **Use `%w[]` and `%i[]`** with square bracket delimiters (not parens) -- **Use modern hash syntax:** `{ key: value }` not `{ :key => value }` -- **No redundant returns** — omit `return` on last expression -- **Use `flat_map`** instead of `.map { }.flatten` -- **No redundant `.to_s`** inside string interpolation -- **Use `Foo.method`** not `Foo::method` for method calls -- **No parentheses around conditions:** `if foo` not `if (foo)` -- **No semicolons** to separate statements - -## HTML/ERB Formatting - -### Tag Attributes -- **Closing `>` on same line as last attribute** — do not put `>` on its own line -- When attributes span multiple lines, keep the closing `>` with the last attribute +## Strings +- Always use double quotes: `"foo"` not `'foo'` + +## Spacing +- Spaces inside array brackets: `[ a, b, c ]` not `[a, b, c]` (empty arrays: `[]`) +- Spaces inside hash braces: `{ a: 1, b: 2 }` not `{a: 1}` (empty hashes: `{}`) +- Spaces inside block braces: `foo { bar }` not `foo {bar}` (empty blocks: `foo { }`) +- No spaces inside parens: `foo(bar)` not `foo( bar )` +- No spaces inside reference brackets: `hash[:key]` not `hash[ :key ]` +- Space before block braces: `foo { }` not `foo{ }` + +## Commas +- No trailing commas in arrays, hashes, or method arguments + +## Indentation +- 2-space indentation, no tabs +- Consistent indentation at normal level — do NOT indent methods under `private`/`protected` +- Align `end` with the variable in assignments +- Align `when` with `end`, not with `case` + +## Whitespace +- No trailing whitespace on any line +- No trailing blank lines at end of file +- No empty lines inside class, module, method, or block bodies + +## Syntax +- Use `%w[]` and `%i[]` with square bracket delimiters (not parens) +- Use modern hash syntax: `{ key: value }` not `{ :key => value }` +- No redundant returns — omit `return` on last expression +- Use `flat_map` instead of `.map { }.flatten` +- No redundant `.to_s` inside string interpolation +- Use `Foo.method` not `Foo::method` for method calls +- No parentheses around conditions: `if foo` not `if (foo)` +- No semicolons to separate statements + +# Git +- When rebasing onto main, review incoming changes for their intent and flag any oversights — missing tests, incomplete migrations, broken assumptions, or conflicts between the two branches. Check both directions: schema/model changes on either branch that affect views, partials, or layouts on the other (e.g., main redesigned a table's CSS but your branch adds new columns to it, or vice versa) + +# HTML/ERB Formatting + +## Tag attributes +- When a tag has long attributes, place the closing `>` on the same line as the last attribute +- Do NOT put the closing `>` on its own line - Example (GOOD): ```erb