Skip to content

Commit f129062

Browse files
authored
Update instructions to agents on formatting (#1794)
1 parent dcca723 commit f129062

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ yalc.lock
6060

6161
# Generated by ROR FS-based Registry
6262
generated
63+
64+
# Claude Code local settings
65+
.claude/settings.local.json

CLAUDE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
99
1. **ALWAYS run `bundle exec rubocop` and fix ALL violations**
1010
2. **ALWAYS ensure files end with a newline character**
1111
3. **NEVER push without running full lint check first**
12+
4. **ALWAYS let Prettier handle ALL formatting - never manually format**
1213

1314
These requirements are non-negotiable. CI will fail if not followed.
1415

@@ -39,6 +40,31 @@ Git hooks will automatically run linting on **all changed files (staged + unstag
3940
- **Type checking**: `yarn run type-check`
4041
- **⚠️ MANDATORY BEFORE GIT PUSH**: `bundle exec rubocop` and fix ALL violations + ensure trailing newlines
4142

43+
## ⚠️ FORMATTING RULES
44+
45+
**Prettier is the SOLE authority for formatting. NEVER manually format code.**
46+
47+
### Standard Workflow
48+
1. Make code changes
49+
2. Run `rake autofix` or `yarn start format`
50+
3. Commit changes
51+
52+
### Merge Conflict Resolution Workflow
53+
**CRITICAL**: When resolving merge conflicts, follow this exact sequence:
54+
55+
1. **Resolve logical conflicts only** - don't worry about formatting
56+
2. **Add resolved files**: `git add .` (or specific files)
57+
3. **Auto-fix everything**: `rake autofix`
58+
4. **Add any formatting changes**: `git add .`
59+
5. **Continue rebase/merge**: `git rebase --continue` or `git commit`
60+
61+
**❌ NEVER manually format during conflict resolution** - this causes formatting wars between tools.
62+
63+
### Debugging Formatting Issues
64+
- Check current formatting: `yarn start format.listDifferent`
65+
- Fix all formatting: `rake autofix`
66+
- If CI fails on formatting, always run automated fixes, never manual fixes
67+
4268
### Development Setup Commands
4369

4470
- **Initial setup**: `bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake`

docs/contributor-info/coding-agents-guide.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,20 @@ git checkout HEAD~1 -- Gemfile package.json # Rollback versions
350350
- Database warnings during `rails js:export` are usually non-fatal
351351
- Test builds don't require database connectivity
352352

353-
### 6. Communication with Users
353+
### 6. Formatting Requirements
354+
355+
**⚠️ CRITICAL**: Always use Prettier for formatting - never manually format code.
356+
357+
**Merge conflict resolution workflow:**
358+
1. Resolve logical conflicts only (ignore formatting)
359+
2. `git add .` (or specific files)
360+
3. `rake autofix` (fixes all formatting + linting)
361+
4. `git add .` (if autofix made changes)
362+
5. Continue rebase: `git rebase --continue`
363+
364+
**Never manually format during conflict resolution** - this causes formatting wars.
365+
366+
### 7. Communication with Users
354367

355368
When reporting status to users:
356369

@@ -361,7 +374,7 @@ echo "⚠️ Note: Some TypeScript errors may be unrelated to react_on_rails"
361374
echo "🔗 Next steps: Test your application with 'bin/dev'"
362375
```
363376

364-
### 7. Documentation Updates
377+
### 8. Documentation Updates
365378

366379
After successful upgrades, suggest:
367380

docs/contributor-info/linters.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,37 @@ npm run lint -- --fix
2727

2828
Autofixing is a **HUGE** time saver!
2929

30+
## Prettier
31+
32+
[Prettier](https://prettier.io/) handles code formatting for JavaScript, TypeScript, CSS, and Markdown files.
33+
34+
**⚠️ CRITICAL**: Prettier is the SOLE authority for formatting. Never manually format code.
35+
36+
### Basic Usage
37+
38+
```bash
39+
# Check formatting
40+
yarn start format.listDifferent
41+
42+
# Fix formatting (includes all linters)
43+
rake autofix
44+
45+
# Or format only
46+
yarn start format
47+
```
48+
49+
### Merge Conflict Resolution
50+
51+
When resolving merge conflicts, **NEVER manually format**. Follow this sequence:
52+
53+
1. Resolve logical conflicts only
54+
2. `git add .` (or specific files)
55+
3. `rake autofix` (fixes all formatting + linting)
56+
4. `git add .` (if autofix made changes)
57+
5. Continue with `git rebase --continue` or `git commit`
58+
59+
**Why this matters**: Manual formatting during conflict resolution creates "formatting wars" between tools and leads to back-and-forth formatting changes in PRs.
60+
3061
## ESLint
3162

3263
See the [ESLint](https://eslint.org/) website for more information.

0 commit comments

Comments
 (0)