auto 模式(以及 bypass 模式)插给模型的那段提醒里,有一句让模型在 Bash 里用 grep 和 find 搜索。这个 mod 只拿掉这一句,换成用 Grep 工具搜内容、用 Glob 工具找文件名;提醒的其余部分原样保留。认不出这句时整段原样放行。

In auto mode (and bypass mode), Claude Code adds a reminder for the model. It tells the model to do much of its work in the Bash tool, including "search with grep and find". This mod changes only that clause: it removes the clause and adds one sentence at the end of the reminder, so the model searches file contents with the Grep tool and file names with the Glob tool. The rest of the reminder (reading files with cat/head, editing files with sed, and so on) is left exactly as the engine wrote it.
prompt.attachment, matched on { type: 'auto_mode' }. It does not touch the system prompt, the auto-mode classifier, or any other reminder.--allowedTools=Glob or --tools. Naming either one in --allowedTools brings both back.claude --plugin-dir ./prefer-search-tools # load for this session
command claude plugin test ./prefer-search-tools
Tested with Claude Code 2.1.296. In an interactive auto-mode session, the debug log shows prompt.attachment auto_mode: … rewrote it (479 -> 568 characters). In -p mode the engine does not send this reminder at all.
hooks/prefer-search-tools.ts 24 lines1// The auto-mode reminder (type `auto_mode`, also sent in bypass mode) steers the model to Bash for reading, searching
2// and editing. Only its search clause is taken out and replaced by a sentence naming the Grep and Glob tools; the rest
3// of the reminder stays as the engine wrote it. A reminder without the clause (another build) goes on unchanged.
4
5import type { On } from 'claude-code'
6
7/** The clause as 2.1.296 writes it, in both its strict and relaxed variants. */
8export const SEARCH_CLAUSE = 'search with grep and find, '
9
10export const SEARCH_STEER = 'For searches, use the Grep tool for file contents and the Glob tool for file names, not grep or find through Bash.'
11
12/** The reminder with its search clause replaced, or undefined when it has none. */
13export function steered(text: string): string | undefined {
14 if (!text.includes(SEARCH_CLAUSE)) return undefined
15 return `${text.replace(SEARCH_CLAUSE, '')}\n\n${SEARCH_STEER}`
16}
17
18export function register(on: On): void {
19 on('prompt.attachment', { type: 'auto_mode' }, async ($, e, next) => {
20 const text = steered(e.text)
21 return next(text === undefined ? e : { ...e, text })
22 })
23}
24