[BUG] gitStatus snapshot is stale at conversation start, causing incorrect context

Resolved 💬 2 comments Opened Feb 9, 2026 by SolusRGB Closed Mar 10, 2026

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?

The gitStatus provided in the system context is captured once when a conversation session is created and never refreshes. If commits land between session creation and the user's first message, the snapshot is stale and the agent operates on an incorrect mental model of the repository from the first turn.

Steps to Reproduce

  1. Make changes across many files (e.g., a 60+ file refactor)
  2. Commit all changes
  3. Start a new Claude Code conversation (or resume one created before the commit)
  4. Observe the gitStatus in the system context — it still shows the pre-commit state with 60+ modified files

Expected Behavior

gitStatus should reflect the current working tree state (clean after commit).

Actual Behavior

gitStatus shows 60 modified files that no longer exist as modifications. The agent then:

  1. Reads files to "verify" already-completed changes
  2. Attempts to validate work from a stale plan
  3. Wastes multiple turns before discovering via git log / git status that the work was already committed

The system-provided gitStatus is treated as authoritative context. When it's wrong, the agent builds an incorrect model of the repo state from turn one and may attempt redundant or conflicting work.

Proposed Fix

Any of these would resolve it:

  1. Lazy snapshot — Capture gitStatus when the user sends their first message, not at session creation
  2. Refresh on resume — If a session is resumed after a time gap, re-snapshot
  3. Timestamp the snapshot — Include capturedAt so the agent knows how stale it is and can decide to re-run git status
  4. Index-based invalidation — If .git/index mtime is newer than the snapshot, flag it as potentially stale

Environment

  • Claude Code version: v24.13.0
  • Model: Opus 4.6
  • OS: macOS (Darwin 24.6.0)
  • Repo: Monorepo with 18 workspace packages, ~60 files modified in the commit that caused the stale snapshot

View original on GitHub ↗

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