Skip to content

Commit 816e05b

Browse files
committed
Merge branch 'main' into fix/67351-scroll-issue-on-ws-search
2 parents 9b97a6a + 72062d4 commit 816e05b

File tree

199 files changed

+3287
-2237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+3287
-2237
lines changed

.claude/README.md

Lines changed: 153 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,74 +16,177 @@ A setup for running agents (eg: code review, triage etc.) on **issues and pull r
1616

1717
1. Workflow events (manual dispatch, new comment, PR opened, label changes, etc.) kick things off.
1818
2. The workflow calls `anthropics/claude-code-action` with:
19-
2019
* `prompt`: `/command-name REPO:… [ISSUE_NUMBER:… | PR_NUMBER:…]`
21-
* `claude_args`: `--allowedTools <comma-separated list>`
22-
3. The command loads the agent(s). They only get the tools you allow.
20+
3. The command loads the agent(s).
2321

24-
## Add an agent
22+
## Tools
2523

26-
1. Create `.claude/agents/<agent>.md`:
24+
There are two types of tools in this framework, controlled at different levels:
2725

28-
```md
29-
---
30-
name: <agent>
31-
description: <what it does>
32-
tools: Read, Glob, Grep, Bash, Edit, Write
33-
model: inherit
34-
---
35-
# <Agent Name>
36-
<!-- prompt: what to do and how to do -->
37-
```
38-
2. Create `.claude/commands/<command>.md` describing which agent(s) to run and where to post results.
39-
3. Wire it up in a workflow:
26+
### 1. Command-level tools (`allowed-tools` in command frontmatter)
4027

41-
```yml
42-
- uses: anthropics/claude-code-action@<version-or-sha>
43-
with:
44-
prompt: "/<command> REPO:${{ github.repository }} PR_NUMBER:${{ github.event.pull_request.number }}"
45-
claude_args: |
46-
--allowedTools "Read,Glob,Grep,Edit,Write,Bash(gh pr view:*;gh pr comment:*;gh issue comment:*)"
47-
```
28+
These specify which tools **claude-code-action** allows during command execution. Define them in `.claude/commands/<command>.md`:
29+
30+
```md
31+
---
32+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),mcp__github_inline_comment__create_inline_comment
33+
description: Review a code contribution pull request
34+
---
35+
```
36+
37+
This includes:
38+
- **Bash with restrictions**: `Bash(gh pr comment:*)` allows only specific `gh` subcommands
39+
- **MCP tools**: `mcp__<server>__<tool>` from attached MCP servers
40+
- Standard Claude Code tools are available by default (see below)
4841

49-
Keep the tool list minimal.
42+
For details on configuring `allowed-tools`, see the [Claude Code GitHub Action documentation](https://github.com/anthropics/claude-code-action).
5043

44+
### 2. Agent-level tools (`tools` in agent frontmatter)
5145

52-
If an agent needs to write on a PR/issue, you can use `gh` or github MCP.
46+
These are the **standard Claude Code tools** that individual agents can use. Specify them in `.claude/agents/<agent>.md`:
5347

54-
## GH cli
48+
```md
49+
---
50+
name: <agent>
51+
description: <what it does>
52+
tools: Read, Glob, Grep, Bash, Edit, Write, TodoWrite, BashOutput, KillBash
53+
model: inherit
54+
---
55+
```
56+
57+
Common standard tools:
58+
- **Read** – read files
59+
- **Write** – create files
60+
- **Edit / MultiEdit** – change files (single/batch)
61+
- **Glob** – match files by pattern
62+
- **Grep** – search in files
63+
- **Bash** – run shell/CLIs (unrestricted, unless limited by command `allowed-tools`)
64+
- **TodoWrite** – manage task lists
65+
- **BashOutput** / **KillBash** – manage long-running bash processes
66+
- **WebFetch / WebSearch** – fetch/search the web (optional)
67+
68+
For a complete list of available Claude Code tools, see the [Claude Code tools documentation](https://docs.anthropic.com/en/docs/claude-code/tools).
5569

56-
You can use `gh` via **Bash**, e.g.:
57-
`Bash(gh pr comment "$PR_NUMBER" --body "…")`
5870

59-
## MCP tools
71+
### MCP tools
6072

61-
You can attach **MCP** servers so agents can call extra tools. Your agent prompt then needs to instruct when to call a tool.
73+
**MCP (Model Context Protocol) tools** allow agents to call additional tools from attached MCP servers. Your agent prompt needs to instruct when to call a tool.
6274

63-
Tool names follow: **`mcp__<server>__<tool>`**.
75+
MCP tool names follow: **`mcp__<server>__<tool>`**.
6476

65-
* Examples:
66-
`mcp__filesystem__read_file`
67-
`mcp__github__list_issues`
68-
`mcp__github__get_pull_request`
77+
**MCP tools must be declared in both places**:
6978

70-
Add them to the same allowlist you pass to the action:
79+
1. **Command frontmatter** (`allowed-tools`) – so claude-code-action allows them
80+
2. **Agent frontmatter** (`tools`) – so the agent knows it can use them
7181

72-
```yml
73-
claude_args: |
74-
--allowedTools "mcp__filesystem__read_file,mcp__github__list_issues,mcp__github__get_pull_request"
82+
Example:
83+
84+
Command (`.claude/commands/review-pr.md`):
85+
```md
86+
---
87+
allowed-tools: Bash(gh pr comment:*),mcp__github_inline_comment__create_inline_comment
88+
---
7589
```
7690

77-
MCP docs (naming): [https://docs.anthropic.com/en/docs/claude-code/mcp](https://docs.anthropic.com/en/docs/claude-code/mcp)
91+
Agent (`.claude/agents/code-reviewer.md`):
92+
```md
93+
---
94+
tools: Read, Glob, Grep, mcp__github_inline_comment__create_inline_comment
95+
---
96+
```
97+
98+
#### Built-in MCP servers
99+
100+
The **claude-code-action** may automatically include these built-in MCP servers depending on context (mode, available tokens, PR vs issue, enabled features):
101+
102+
- **`github_comment`**
103+
- **`github_file_ops`**
104+
- **`github_inline_comment`**
105+
- **`github_ci`**
106+
- **`github`** (Official GitHub MCP Server)
107+
108+
Add tools from these servers to your command's `allowed-tools` and agent's `tools` as needed (e.g., `mcp__github_inline_comment__create_inline_comment`).
78109

79-
## Common tools for claude code
110+
#### Custom MCP servers
111+
112+
You can also attach **custom MCP servers** to provide additional tools beyond the built-in ones. Create or configure custom MCP servers according to your needs and follow the same `mcp__<server>__<tool>` naming convention.
113+
114+
For details on MCP tool naming, configuration, and creating custom MCP servers, see the [MCP documentation](https://docs.anthropic.com/en/docs/claude-code/mcp).
115+
116+
## Security considerations
117+
118+
When configuring agents and commands, follow these security best practices:
119+
120+
### Principle of least privilege
121+
122+
**Minimize tool access** – Only grant agents the minimum set of tools they need to perform their task. Review both `allowed-tools` in commands and `tools` in agents regularly.
123+
124+
```md
125+
# ❌ Too permissive
126+
allowed-tools: Bash
127+
tools: Bash, Read, Write, Edit, WebFetch, WebSearch
128+
129+
# ✅ Properly restricted
130+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr view:*)
131+
tools: Bash, Read, Glob, Grep
132+
```
80133

81-
* **Read** – read files
82-
* **Write** – create files
83-
* **Edit / MultiEdit** – change files (single/batch)
84-
* **Glob** – match files by pattern
85-
* **Grep** – search in files
86-
* **Bash** – run shell/CLIs (e.g., `gh`, linters)
87-
* **WebFetch / WebSearch** – fetch/search the web (optional)
134+
### Restrict Bash access
88135

89-
For action options and tool behavior, see the [Claude Code GitHub Action docs](https://github.com/anthropics/claude-code-action).
136+
Always restrict `Bash` usage to specific commands in `allowed-tools` instead of granting unrestricted `Bash` access:
137+
138+
```md
139+
# ❌ Unrestricted Bash
140+
allowed-tools: Bash
141+
142+
# ✅ Restricted to specific gh commands
143+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)
144+
```
145+
146+
### Untrusted input and prompt injection
147+
148+
When agents process **untrusted input from external sources** (e.g., PRs from unknown users when using `allowed_non_write_users: "*"` in workflows), treat the agent as potentially **compromised** or "jailbroken".
149+
150+
**Key considerations:**
151+
152+
1. **Assume prompt injection** – Untrusted PR content may contain prompt injection attempts to manipulate the agent.
153+
154+
2. **Minimize tool access** – Strictly limit tools and consider: What's the worst-case action a compromised agent could take? Can it modify files, commit code, or access secrets?
155+
156+
3. **Best practices** – Prefer read-only tools (`Read`, `Glob`, `Grep`), restrict Bash to safe commands, avoid `Write`/`Edit`, and use built-in MCP tools over unrestricted Bash.
157+
158+
4. **With `allowed_non_write_users: "*"`** – Limit to read-only operations and comments; never grant `Write`, `Edit`, or unrestricted `Bash` access.
159+
160+
Always perform a **security assessment**: If an agent with your current tool configuration were fully compromised, what's the worst damage it could cause? If the answer is unacceptable, reduce tool access.
161+
162+
## Add an agent
163+
164+
1. Create `.claude/agents/<agent>.md`:
165+
166+
```md
167+
---
168+
name: <agent>
169+
description: <what it does>
170+
tools: Read, Glob, Grep, Bash, Edit, Write, mcp__github_inline_comment__create_inline_comment
171+
model: inherit
172+
---
173+
```
174+
175+
2. Create `.claude/commands/<command>.md` describing which agent(s) to run and where to post results. Specify allowed tools in the frontmatter:
176+
177+
```md
178+
---
179+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),mcp__github_inline_comment__create_inline_comment
180+
description: Review a code contribution pull request
181+
---
182+
```
183+
184+
3. Use it in a workflow:
185+
186+
```yml
187+
- uses: anthropics/claude-code-action@<version-or-sha>
188+
with:
189+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
190+
github_token: ${{ secrets.GITHUB_TOKEN }}
191+
prompt: "/<command> REPO:${{ github.repository }} PR_NUMBER:${{ github.event.pull_request.number }}"
192+
```

.claude/agents/code-inline-reviewer.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name: code-inline-reviewer
44
description: Reviews code and creates inline comments for specific rule violations.
5-
tools: Glob, Grep, Read, WebFetch, Bash, Edit, MultiEdit, Write, TodoWrite, WebSearch, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
5+
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
66
model: inherit
77
---
88

@@ -17,12 +17,15 @@ Your job is to scan through changed files and create **inline comments** for spe
1717
Each rule includes:
1818

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

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

27+
- **Search patterns**: `renderItem`, `...` (look for both in proximity)
28+
2629
- **Condition**: Flag ONLY when ALL of these are true:
2730

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

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

71+
- **Search patterns**: `.every(`, `.some(`, `.find(`, `.filter(`
72+
6873
- **Condition**: Flag ONLY when ALL of these are true:
6974

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

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

127+
- **Search patterns**: `useOnyx` within components used in `renderItem`
128+
122129
- **Condition**: Components rendered inside `renderItem` functions should use dedicated hooks from `OnyxListItemProvider` instead of individual `useOnyx` calls.
123130
- **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.
124131

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

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

148+
- **Search patterns**: `useMemo`, `useCallback`, and prop passing patterns
149+
141150
- **Condition**: Objects and functions passed as props should be properly memoized or simplified to primitive values to prevent unnecessary re-renders.
142151
- **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.
143152

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

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

177+
- **Search patterns**: `React.memo`, `deepEqual`
178+
168179
- **Condition**: In `React.memo` and similar optimization functions, compare only specific relevant properties instead of using deep equality checks.
169180
- **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.
170181

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

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

205+
- **Search patterns**: `useEffect`, `useMemo`, `useCallback` dependency arrays
206+
194207
- **Condition**: In `useEffect`, `useMemo`, and `useCallback`, specify individual object properties as dependencies instead of passing entire objects.
195208
- **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.
196209

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

221234
## Instructions
222235

223-
1. **Read each changed file carefully** using the Read tool
224-
2. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
225-
3. **Required parameters for each inline comment:**
236+
1. **First, get the list of changed files and their diffs:**
237+
- Use `gh pr diff` to see what actually changed in the PR
238+
- Focus ONLY on the changed lines, not the entire file
239+
2. **For analyzing changed files:**
240+
- **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.
241+
- **For smaller files:** You may read the full file using the Read tool
242+
- **If a Read fails with token limit error:** Immediately switch to using Grep with targeted patterns for the rules you're checking
243+
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.
244+
4. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
245+
5. **Required parameters for each inline comment:**
226246
- `path`: Full file path (e.g., "src/components/ReportActionsList.tsx")
227247
- `line`: Line number where the issue occurs
228248
- `body`: Concise and actionable description of the violation and fix, following the below Comment Format
229-
4. **Each comment must reference exactly one Rule ID.**
230-
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.
231-
6. **If no violations are found, create a comment** (with no quotes, markdown, or additional text):
232-
LGTM :feelsgood:. Thank you for your hard work!
233-
7. **Output LGTM if and only if**:
234-
- You examined EVERY line of EVERY changed file
249+
6. **Each comment must reference exactly one Rule ID.**
250+
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.
251+
8. **If no violations are found, create a comment** (with no quotes, markdown, or additional text):
252+
LGTM 👍 Thank you for your hard work!
253+
9. **Output LGTM if and only if**:
254+
- You examined EVERY changed line in EVERY changed file (via diff + targeted grep/read)
235255
- You checked EVERY changed file against ALL rules
236256
- You found ZERO violations matching the exact rule criteria
237257
- You verified no false negatives by checking each rule systematically
238258
If you found even ONE violation or have ANY uncertainty do NOT create LGTM comment - create inline comments instead.
239-
8. **DO NOT invent new rules, stylistic preferences, or commentary outside the listed rules.**
240-
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.**
259+
10. **DO NOT invent new rules, stylistic preferences, or commentary outside the listed rules.**
260+
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.**
241261
Only inline comments regarding rules violations or general comment with LGTM message are allowed.
242262
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.
243263

.claude/agents/helpdot-inline-reviewer.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: helpdot-inline-reviewer
33
description: Reviews HelpDot documentation files and creates inline comments for specific rule violations and issues.
4-
tools: Glob, Grep, Read, WebFetch, Bash, Edit, MultiEdit, Write, TodoWrite, WebSearch, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
4+
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash, mcp__github_inline_comment__create_inline_comment
55
model: inherit
66
---
77

@@ -52,9 +52,28 @@ keywords: [feature name, related terms, navigation path, etc.]
5252

5353
## Instructions
5454

55-
1. **Read each changed file carefully** using the Read tool
56-
2. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
57-
3. **Required parameters for each inline comment:**
55+
1. **First, get the list of changed files:**
56+
- Use `gh pr diff` to see what actually changed in the PR
57+
- Focus ONLY on documentation files (*.md, *.csv, etc.)
58+
59+
2. **For analyzing changed files:**
60+
- **Use a hybrid approach** because different violations require different analysis methods:
61+
- **Grep is suitable for pattern-based violations only:**
62+
- Terminology violations ("policy" → "workspace", "user" → "member")
63+
- Button label violations ("Save" → "Confirm", "Continue" → "Next")
64+
- Missing YAML frontmatter markers (`---`)
65+
- **Full file reading is required for semantic violations:**
66+
- Readability issues (clarity, flow, scannability, reading level)
67+
- AI Readiness issues (vague headings, unclear references, logical structure)
68+
- Proper hierarchy and document structure
69+
- **Reading strategy:**
70+
- Most documentation files are small (<1000 lines) - read them in full
71+
- For files >1000 lines: Read in overlapping chunks using offset/limit to maintain context
72+
- **Never rely on grep alone** - semantic violations require understanding context, not just pattern matching
73+
74+
3. **For each violation found, immediately create an inline comment** using the available GitHub inline comment tool
75+
76+
4. **Required parameters for each inline comment:**
5877
- `path`: Full file path (e.g., "docs/articles/new-expensify/chat/Create-a-New-Chat.md")
5978
- `line`: Line number where the issue occurs
6079
- `body`: Concise description of the violation and fix

.claude/agents/helpdot-summary-reviewer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: helpdot-summary-reviewer
33
description: Provides comprehensive summary reviews of HelpDot documentation changes with scoring and overall assessment.
4-
tools: Glob, Grep, Read, WebFetch, Bash, Edit, MultiEdit, Write, TodoWrite, WebSearch, BashOutput, KillBash
4+
tools: Glob, Grep, Read, TodoWrite, Bash, BashOutput, KillBash
55
model: inherit
66
---
77

.github/ISSUE_TEMPLATE/Accessibility.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: Accessibility issue template
33
about: A template to follow when creating a new issue for accessibility failures
4+
labels: ["Accessibility", "Weekly"]
45
---
56

67
If you haven’t already, check out our [contributing guidelines](https://github.com/Expensify/ReactNativeChat/blob/main/contributingGuides/CONTRIBUTING.md) for onboarding and email contributors@expensify.com to request to join our Slack channel!

0 commit comments

Comments
 (0)