Demo, all content is generated
Question

Claude Code keeps saying 'File has not been read yet' and retries

Solved · 171 views · asked by emeka · edited

Lots of these lately:

Error: File has not been read yet. Read it first before writing to it.

and sometimes

File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.

It then reads the file and continues. Is something broken? It feels like it wastes time.

What I’ve tried

Updated Claude Code. Checked I don't have two sessions open on the same folder.

Comment

2 answers

Marked as helpful by the asker
thandeka · edited

Nothing broken, that's a safety check. It refuses to overwrite a file it hasn't seen (first message) or one that changed since it last read it (second message), so it doesn't wipe out your edits.

The second one usually means something else touches files while it works: format-on-save in your editor, a prettier hook, or you typing in the same file. If it's constant, turn off format-on-save for that project and let a hook format after Claude's edits instead.

Comment
Format on save in VS Code, yes. Turned it off for this workspace, messages mostly gone. emeka · edited
Nice. A PostToolUse prettier hook gives you the formatting back without the conflict. thandeka · edited
diego_mx · edited

Also happens when you switch git branches while Claude is working, or run two sessions in the same folder. If you want two in parallel, use a separate git worktree for each.

Comment