Subagents (Task tool) use sed/cat/ls instead of dedicated Read/Edit/Glob tools

Resolved 💬 3 comments Opened Jan 29, 2026 by ilanoh Closed Feb 2, 2026

Description

Subagents spawned via the Task tool frequently use Bash commands (sed, cat, ls, awk) instead of the dedicated tools (Edit, Read, Glob, Grep) that the main Claude Code session is instructed to prefer.

While the main session generally follows the system prompt rules, subagents appear to not inherit or respect the same constraints, leading to:

  • sed used for file edits instead of Edit
  • cat used for file reads instead of Read
  • ls/find used for file search instead of Glob

Impact

  • sed is dangerous -- regex-based substitution can silently corrupt files, unlike the Edit tool which has safety checks (uniqueness validation, prior read requirement, clear diffs)
  • cat/ls trigger unnecessary permission prompts since the dedicated tools don't require them
  • Users have no control over subagent behavior -- they can't intervene before a sed command runs inside a Task agent

Expected Behavior

Subagents spawned by the Task tool should follow the same tool usage rules as the main session:

  • Use Edit instead of sed/awk for file modifications
  • Use Read instead of cat/head/tail for reading files
  • Use Glob instead of ls/find for file search
  • Use Grep instead of grep/rg for content search

Related

  • #21696 - Main session also sometimes falls back to Bash commands

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗