Skip to content

Commit bdda2de

Browse files
justin808claude
andcommitted
Document critical formatting rules and conflict resolution workflow
Add comprehensive formatting guidelines to prevent formatting wars: - CLAUDE.md: Add Prettier as critical requirement with merge conflict workflow - linters.md: Add dedicated Prettier section with conflict resolution steps - coding-agents-guide.md: Add formatting requirements for AI agents Key principle: Prettier is the SOLE authority for formatting - never manually format code, especially during merge conflict resolution. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bc9ca10 commit bdda2de

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

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

@@ -33,6 +34,31 @@ These requirements are non-negotiable. CI will fail if not followed.
3334
- **Type checking**: `yarn run type-check`
3435
- **⚠️ MANDATORY BEFORE GIT PUSH**: `bundle exec rubocop` and fix ALL violations + ensure trailing newlines
3536

37+
## ⚠️ FORMATTING RULES
38+
39+
**Prettier is the SOLE authority for formatting. NEVER manually format code.**
40+
41+
### Standard Workflow
42+
1. Make code changes
43+
2. Run `npx prettier --write <files>` or `rake autofix`
44+
3. Commit changes
45+
46+
### Merge Conflict Resolution Workflow
47+
**CRITICAL**: When resolving merge conflicts, follow this exact sequence:
48+
49+
1. **Resolve logical conflicts only** - don't worry about formatting
50+
2. **Add resolved files**: `git add <conflicted-files>`
51+
3. **Let Prettier format**: `npx prettier --write <conflicted-files>`
52+
4. **Add formatted files**: `git add <conflicted-files>` (if Prettier made changes)
53+
5. **Continue rebase/merge**: `git rebase --continue` or `git commit`
54+
55+
**❌ NEVER manually format during conflict resolution** - this causes formatting wars between tools.
56+
57+
### Debugging Formatting Issues
58+
- Check current formatting: `npx prettier --check .`
59+
- Fix all formatting: `npx prettier --write .`
60+
- If CI fails on formatting, always run Prettier, never manual fixes
61+
3662
### Development Setup Commands
3763

3864
- **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 <resolved-files>`
360+
3. `npx prettier --write <resolved-files>`
361+
4. `git add <resolved-files>` (if Prettier 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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,38 @@ 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+
npx prettier --check .
41+
42+
# Fix formatting
43+
npx prettier --write .
44+
45+
# Or use project scripts
46+
rake autofix
47+
yarn start format.listDifferent # check only
48+
```
49+
50+
### Merge Conflict Resolution
51+
52+
When resolving merge conflicts, **NEVER manually format**. Follow this sequence:
53+
54+
1. Resolve logical conflicts only
55+
2. `git add <resolved-files>`
56+
3. `npx prettier --write <resolved-files>`
57+
4. `git add <resolved-files>` (if Prettier made changes)
58+
5. Continue with `git rebase --continue` or `git commit`
59+
60+
**Why this matters**: Manual formatting during conflict resolution creates "formatting wars" between tools and leads to back-and-forth formatting changes in PRs.
61+
3062
## ESLint
3163

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

0 commit comments

Comments
 (0)