search-files-content-trim

search-files-content-trim is a skill for Claude Code, Codex from humanerd-drew/opencode-drewgent. It costs 36 tokens per session (1,359 once invoked), scanned A, original, MIT.

A search setting that shows short previews of matching lines instead of sending full long lines into the agent's context by default.

In plain words
What is it for?
It is for making codebase searches more concise, especially when files contain long lines or many matches.
Why use it?
It reduces unnecessary text in search results, leaving the agent's context available for useful work. Full content can still be requested when needed.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for making codebase searches more concise, especially when files contain long lines or many matches.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/humanerd-drew/opencode-drewgent/search-files-content-trim
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add humanerd-drew/opencode-drewgent --skill search-files-content-trim
Clone the repo
git clone --depth 1 https://github.com/humanerd-drew/opencode-drewgent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for search-files-content-trim

README.md
[![agentmods](https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/search-files-content-trim.svg)](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/search-files-content-trim)
Your own site
<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/search-files-content-trim"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/search-files-content-trim.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,359 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.01359
Opus 5 $0.00018 $0.00679
Sonnet 5 $0.00007 $0.00272
Haiku 4.5 $0.00004 $0.00136

Measured 4d ago against content hash 90d6f2551f1f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

search-files-content-trim scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/software-development/search-files-content-trim/SKILL.md · 93 lines

How it starts

The opening of the file, as written. The whole thing — 93 lines — stays where its author put it; the contents beside it link to each section on GitHub.

search_files Content Trim — Token-Efficient Default

Audit Finding (2026-05-31)

{{AGENT_NAME}}의 search_files tool은 757자짜리 line을 500자 (ripgrep MAX_CONTENT cap)까지 매번 그대로 LLM context에 push했음. 단일 검색 결과 한 match에 500자 × 50 matches = 25,000 chars/검색. 99.2%의 검색 call은 path:line만 필요하고, full content는 LLM이 read_file()로 follow-up할 일 — 첫 search response의 full content는 낭비.

원인: ripgrep의 MAX_CONTENT=500이 1차 cap. search_tool은 그 이상 truncate 안 함. LLM은 매번 500 chars/line을 받음.

Fix (shipped 2026-05-31)

~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/tools/file_tools.pysearch_tool에 2개 파라미터 추가:

param type default 의미
include_content bool False True면 full content, False면 preview로 truncate
preview_chars int 100 False일 때 매치당 보존할 글자 수. 0이면 content 완전 drop (path:line만)

적용 위치 (총 4개):

  1. SEARCH_FILES_SCHEMA — input schema에 2 properties 추가
  2. search_tool signature — 2 파라미터 + docstring에 audit 결과 명시
  3. search_tool body — redact_sensitive_text 직후 preview truncate 로직 (preview_chars=0"", > preview_chars[:preview_chars] + "...")
  4. _handle_search_files handler — args 2개 pass-through

Effect (verified)

시나리오 Before After (default) 절약
757자 line 1 match 500 chars 103 chars (100+3) 79%
50 matches × 500 chars 25,000 chars 5,150 chars 79%
preview_chars=0 (path:line만) 500 chars 0 chars 100%
include_content=True (회귀 없음) 500 chars 500 chars 0% (의도)

When To Use

  • default (no flag): LLM이 path:line만 필요하고 read_file()로 follow-up할 때. 대부분의 search 호출이 여기에 해당.
  • preview_chars=0: "이 file들이 존재하는지만 알면 됨" 케이스. 50개 file의 path:line만 받고 다음 단계로 넘어감.
  • include_content=True: LLM이 full line을 보고 결정해야 할 때 (e.g. multi-line regex match, raw text/JSON structure 파악).

Pattern: Token-Efficient Tool Default

이 패턴은 다른 tool에도 동일 적용 가능:

  1. Audit current behavior: 한 tool call이 평균 몇 char를 LLM context에 push하는지 측정
  2. Default = cheapest sane option: full content 필요 케이스만 opt-in (include_*=True)
  3. Tunable: preview_chars 같은 numeric param으로 user가 명시적으로 trade-off 조절
  4. Schema에 명시: LLM이 schema description 읽고 알아서 적절히 선택하도록 guide

Read the full file on GitHub · 93 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 93 lines · 36 tokens per session scan A 90d6f2551f1f

Subscribe to this mod's changes

search-files-content-trim is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (2 stars, last pushed 1mo ago), licensed MIT. It adds 36 tokens to every session and 1,359 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.