Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions .claude/agents/code-inline-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ Your job is to scan through changed files and create **inline comments** for spe
Each rule includes:

- A unique **Rule ID**
- **Search patterns**: Grep patterns to efficiently locate potential violations in large files
- **Pass/Fail condition**
- **Reasoning**: Technical explanation of why the rule is important
- Examples of good and bad usage

### [PERF-1] No spread in list item's renderItem

- **Search patterns**: `renderItem`, `...` (look for both in proximity)

- **Condition**: Flag ONLY when ALL of these are true:

- Code is inside a renderItem function (function passed to FlatList, SectionList, etc.)
Expand Down Expand Up @@ -65,6 +68,8 @@ Bad:

### [PERF-2] Use early returns in array iteration methods

- **Search patterns**: `.every(`, `.some(`, `.find(`, `.filter(`

- **Condition**: Flag ONLY when ALL of these are true:

- Using .every(), .some(), .find(), .filter() or similar function
Expand Down Expand Up @@ -119,6 +124,8 @@ const areAllTransactionsValid = transactions.every((transaction) => {

### [PERF-3] Use OnyxListItemProvider hooks instead of useOnyx in renderItem

- **Search patterns**: `useOnyx` within components used in `renderItem`

- **Condition**: Components rendered inside `renderItem` functions should use dedicated hooks from `OnyxListItemProvider` instead of individual `useOnyx` calls.
- **Reasoning**: Individual `useOnyx` calls in renderItem create separate subscriptions for each list item, causing memory overhead and update cascades. `OnyxListItemProvider` hooks provide optimized data access patterns specifically designed for list rendering performance.

Expand All @@ -138,6 +145,8 @@ const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

### [PERF-4] Memoize objects and functions passed as props

- **Search patterns**: `useMemo`, `useCallback`, and prop passing patterns

- **Condition**: Objects and functions passed as props should be properly memoized or simplified to primitive values to prevent unnecessary re-renders.
- **Reasoning**: React uses referential equality to determine if props changed. New object/function instances on every render trigger unnecessary re-renders of child components, even when the actual data hasn't changed. Memoization preserves referential stability.

Expand Down Expand Up @@ -165,6 +174,8 @@ return <ReportActionItem report={report} />

### [PERF-5] Use shallow comparisons instead of deep comparisons

- **Search patterns**: `React.memo`, `deepEqual`

- **Condition**: In `React.memo` and similar optimization functions, compare only specific relevant properties instead of using deep equality checks.
- **Reasoning**: Deep equality checks recursively compare all nested properties, creating performance overhead that often exceeds the re-render cost they aim to prevent. Shallow comparisons of specific relevant properties provide the same optimization benefits with minimal computational cost.

Expand All @@ -191,6 +202,8 @@ memo(ReportActionItem, (prevProps, nextProps) =>

### [PERF-6] Use specific properties as hook dependencies

- **Search patterns**: `useEffect`, `useMemo`, `useCallback` dependency arrays

- **Condition**: In `useEffect`, `useMemo`, and `useCallback`, specify individual object properties as dependencies instead of passing entire objects.
- **Reasoning**: Passing entire objects as dependencies causes hooks to re-execute whenever any property changes, even unrelated ones. Specifying individual properties creates more granular dependency tracking, reducing unnecessary hook executions and improving performance predictability.

Expand Down Expand Up @@ -220,24 +233,31 @@ const {amountColumnSize, dateColumnSize, taxAmountColumnSize} = useMemo(() => {

## Instructions

1. **Read each changed file carefully** using the Read tool
2. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
3. **Required parameters for each inline comment:**
1. **First, get the list of changed files and their diffs:**
- Use `gh pr diff` to see what actually changed in the PR
- Focus ONLY on the changed lines, not the entire file
2. **For analyzing changed files:**
Comment thread
kacper-mikolajczak marked this conversation as resolved.
Resolved
- **For large files (>5000 lines):** Use the Grep tool to search for specific violation patterns instead of reading the entire file. Focus grep searches on the changed portions shown in the diff.
- **For smaller files:** You may read the full file using the Read tool
- **If a Read fails with token limit error:** Immediately switch to using Grep with targeted patterns for the rules you're checking
3. **Search strategy for large files:** Use the search patterns defined in each rule's "Search patterns" field to efficiently locate potential violations with Grep.
Comment thread
kacper-mikolajczak marked this conversation as resolved.
Resolved
4. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
5. **Required parameters for each inline comment:**
- `path`: Full file path (e.g., "src/components/ReportActionsList.tsx")
- `line`: Line number where the issue occurs
- `body`: Concise and actionable description of the violation and fix, following the below Comment Format
4. **Each comment must reference exactly one Rule ID.**
5. **Output must consist exclusively of calls to mcp__github_inline_comment__create_inline_comment in the required format.** No other text, Markdown, or prose is allowed.
6. **If no violations are found, create a comment** (with no quotes, markdown, or additional text):
6. **Each comment must reference exactly one Rule ID.**
7. **Output must consist exclusively of calls to mcp__github_inline_comment__create_inline_comment in the required format.** No other text, Markdown, or prose is allowed.
8. **If no violations are found, create a comment** (with no quotes, markdown, or additional text):
LGTM :feelsgood:. Thank you for your hard work!
7. **Output LGTM if and only if**:
- You examined EVERY line of EVERY changed file
9. **Output LGTM if and only if**:
- You examined EVERY changed line in EVERY changed file (via diff + targeted grep/read)
- You checked EVERY changed file against ALL rules
- You found ZERO violations matching the exact rule criteria
- You verified no false negatives by checking each rule systematically
If you found even ONE violation or have ANY uncertainty do NOT create LGTM comment - create inline comments instead.
8. **DO NOT invent new rules, stylistic preferences, or commentary outside the listed rules.**
9. **DO NOT describe what you are doing, create comments with a summary, explanations, extra content, comments on rules that are NOT violated or ANYTHING ELSE.**
10. **DO NOT invent new rules, stylistic preferences, or commentary outside the listed rules.**
11. **DO NOT describe what you are doing, create comments with a summary, explanations, extra content, comments on rules that are NOT violated or ANYTHING ELSE.**
Only inline comments regarding rules violations or general comment with LGTM message are allowed.
EXCEPTION: If you believe something MIGHT be a Rule violation but are uncertain, err on the side of creating an inline comment with your concern rather than skipping it.

Expand Down
25 changes: 22 additions & 3 deletions .claude/agents/helpdot-inline-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,28 @@ keywords: [feature name, related terms, navigation path, etc.]

## Instructions

1. **Read each changed file carefully** using the Read tool
2. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
3. **Required parameters for each inline comment:**
1. **First, get the list of changed files:**
- Use `gh pr diff` to see what actually changed in the PR
- Focus ONLY on documentation files (*.md, *.csv, etc.)

2. **For analyzing changed files:**
- **Use a hybrid approach** because different violations require different analysis methods:
- **Grep is suitable for pattern-based violations only:**
- Terminology violations ("policy" → "workspace", "user" → "member")
- Button label violations ("Save" → "Confirm", "Continue" → "Next")
- Missing YAML frontmatter markers (`---`)
- **Full file reading is required for semantic violations:**
- Readability issues (clarity, flow, scannability, reading level)
- AI Readiness issues (vague headings, unclear references, logical structure)
- Proper hierarchy and document structure
- **Reading strategy:**
- Most documentation files are small (<1000 lines) - read them in full
- For files >1000 lines: Read in overlapping chunks using offset/limit to maintain context
- **Never rely on grep alone** - semantic violations require understanding context, not just pattern matching

3. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool

4. **Required parameters for each inline comment:**
- `path`: Full file path (e.g., "docs/articles/new-expensify/chat/Create-a-New-Chat.md")
- `line`: Line number where the issue occurs
- `body`: Concise description of the violation and fix
Expand Down