SLOPSHOPPER

prefer-search-tools

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

newprompt
★ 2v0.1.0MITupdated 2026-10-13alexcz-a11y/claude-mods/prefer-search-tools
A shopper browsing a rack in a slop shop
README

prefer-search-tools

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.

  • Event: prompt.attachment, matched on { type: 'auto_mode' }. It does not touch the system prompt, the auto-mode classifier, or any other reminder.
  • If a future version rewords the clause, the mod finds nothing to replace and passes the reminder through unchanged.
  • It assumes Grep/Glob are in the session's tool set. On macOS/Linux they are absent by default, so start with --allowedTools=Glob or --tools. Naming either one in --allowedTools brings both back.
  • The engine decides a reminder's text once per process. After installing, the mod takes effect in a new session.
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.

Source 1 files
hooks/prefer-search-tools.ts 24 lines
1// 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