[BUG] Poor error handling and verification during multi-step file migration task
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
---
Title: Poor error handling and verification during multi-step file migration task
Description:
During a git hooks migration (Husky → Lefthook), Claude Code exhibited poor task management with multiple failures in file
verification, error recovery, and state tracking. The task eventually succeeded but only after user intervention to catch multiple
failures.
Environment:
- Claude Code version: [Latest]
- Task type: Multi-step file migration (removing old tool, installing new tool, modifying config files)
- Tools used: Write, Edit, Bash, Read
Steps to Reproduce:
- Ask Claude Code to migrate from one tool to another (e.g., Husky + lint-staged → Lefthook)
- Migration involves:
- Removing packages
- Installing new packages
- Creating new config files
- Editing existing config files
- Removing old directories
- Testing the setup
Expected Behavior:
- After each file modification, Claude should verify the change succeeded
- When Write tool is used, should immediately Read the file to confirm content
- When Edit tool fails, should re-read file and retry immediately
- When directory deletion is attempted, should verify complete removal
- Should not attempt to commit until ALL changes are verified
- Should not remove existing functionality without asking user first
Actual Behavior:
- Write tool failure not detected: Used Write tool to create lefthook.yml, but only the template was written (not the actual config).
Claude assumed success without verification. User had to catch this: "Look at lefthook.yml you numpty, it's got nothing in it!"
- Edit tool failures ignored: Multiple Edit tool calls failed with "File has been modified since read" but Claude didn't immediately
re-read and retry
- Incomplete directory deletion: Said .husky/ was removed but only deleted pre-commit file, left _/ subdirectory. Only caught later
with git status
- Removed functionality without asking: Removed vitest testing from git hooks because Biome docs example didn't show it. User had to
ask: "Why remove our testing? Wouldn't we want this still?"
- Multiple premature commit attempts: Tried to commit 3 times before all changes were actually complete and verified
- Poor state awareness: After Edit failures, didn't use git diff or re-read files to verify actual state
Impact:
- User frustration: "No, half your file edits failed!"
- Wasted time: Multiple failed attempts requiring user intervention
- Loss of trust: User had to manually verify every step
- Poor UX: User comment: "You really managed this change poorly"
Suggested Improvements:
- Mandatory verification after file operations:
- After Write: Always Read the file back
- After Edit: Always use git diff or Read to verify change
- After directory removal: Use ls/git status to confirm
- Better error recovery:
- If Edit fails with "file modified", immediately re-read and create new todo item
- Don't mark todos as complete until verification succeeds
- Use git status frequently during multi-file changes
- Pre-commit verification checklist:
- Before any git commit attempt, should:
- Run git status to see all changes
- Run git diff to verify changes are correct
- Read any newly created files to verify content
- Confirm all todos are actually complete
- Conservative approach to removing functionality:
- When example documentation doesn't show existing functionality, should ask user before removing
- Default to keeping existing behavior unless explicitly told to remove
- Better use of TodoWrite:
- Add verification steps as explicit todos
- Don't mark todos complete until verification passes
- Add "Verify all changes" as final todo before commit
Session Context:
This occurred during a continuation session (context limit reached). However, the issues aren't specific to continuation - they're
fundamental problems with verification and error handling during multi-step file operations.
User Quote:
"You really managed this change poorly, you should report this session as a bug"
---
What Should Happen?
Recover gracefully from errors in the write tool!
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce:
- Ask Claude Code to migrate from one tool to another (e.g., Husky + lint-staged → Lefthook)
- Migration involves:
- Removing packages
- Installing new packages
- Creating new config files
- Editing existing config files
- Removing old directories
- Testing the setup
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.28 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗