[Bug] Read tool line-number prefix causes Claude to write short-wrapped lines in Edit replacements

Resolved 💬 3 comments Opened Mar 20, 2026 by grittygrease Closed Mar 24, 2026

Description

The Read tool displays file content with a line-number prefix (e.g., 1152→), which adds ~8 characters of visual width. When Claude then writes replacement text via the Edit tool, it calibrates line width to what it sees (including the prefix), producing lines wrapped at ~55-60 characters instead of the intended 72.

Impact

This is systematic. In a single session editing two IETF Internet-Draft files (kramdown-rfc markdown, 72-char line limit), Claude produced 739 short-wrapped lines in one file and 808 in another, across 12 PRs and 50+ Edit operations. Every replacement string was 8-15 characters too narrow.

Reproduction

  1. Open a file with 72-char wrapped prose
  2. Use Read to view a section
  3. Use Edit to replace a paragraph with new text
  4. Check line widths with awk
  5. Observe: replacement text is wrapped at ~55-65 chars, not 72

Expected behavior

Claude should produce replacement text at the correct target width regardless of the Read tool display prefix. Options:

  1. Make the line-number prefix visually distinct enough that width calibration is not affected (e.g., use a fixed narrow format)
  2. Strip the prefix from the context provided to the model for Edit operations
  3. Include metadata telling the model the prefix width so it can compensate

Workaround

A PostToolUse hook that runs a reflow script after every Edit to a target file. This fixes the output but adds latency and complexity.

Environment

  • Claude Code 2.1.80
  • macOS Darwin 25.3.0
  • File type: kramdown-rfc markdown (.md)

View original on GitHub ↗

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