Verify File Location Before Acting
Before editing, reading, or referencing any file:
- Search for it first — use Glob or Grep to find the file by name
- Use the found path — not the path from a previous session or conversation
- Never assume a file is still where it was originally created
The user may have moved, renamed, or reorganised files since the last session. Always discover the current location.
Re-read before write (stops silent reverts)
Right before StrReplace or overwriting with Write:
- Read the file at the resolved path again — from disk, not from chat memory or an earlier tool result in the same session.
- Build the patch from that current content only.
Between your last reply and the user’s next message, they may have edited the file. Applying a patch from an old snapshot reverts their changes. If the file changed since your last Read, discard assumptions and re-anchor hunks to the latest content.
Required Behaviour
Task: "Update the UserCard component"
Wrong:
→ Open src/components/userCard.tsx ← path remembered from last session
Correct:
1. Glob("**/userCard.tsx") or Glob("**/userCard*")
2. Found at: src/features/dashboard/_components/userCard.tsx
3. Edit at the found path
Applies To
- Components, hooks, utilities, services, schemas
- Skill files in
~/.agents/skills/ - Artifact files in
.artifacts/ - Any file the AI created or referenced in a previous conversation