DEV Community

Ted Murray
Ted Murray

Posted on

Claude Code Doesn't Know You've Been Gone — Here's the Fix

I first noticed this in Claude Desktop. I'd have a conversation, step away for a few hours, come back and continue — sometimes on a slightly different angle, sometimes just picking up where I left off — and something about the responses felt off. Like Claude was treating it as one continuous thought when the gap had given me time to change direction.

My fix was an espanso trigger. I set up :cltime to expand to:

Current date/time: Saturday, March 21, 2026 at 09:00 AM. Use this to orient yourself.
Enter fullscreen mode Exit fullscreen mode

Typed it at the start of a session or whenever I came back after a break. It worked. Claude recalibrated — less continuation, more reorientation. Problem solved, moved on.

Then I switched to Claude Code. I saw timestamps in the session context, assumed the problem was handled, and stopped using :cltime. Reasonable assumption.

It wasn't fully handled.

The timestamp Claude Code injects tells it what time the session started. It doesn't tell it how much time has passed since then. Come back after three hours and send a message — Claude sees the same session start time it's always seen. It doesn't know if you've been gone 30 seconds or half a day.

The context is the same. The right response isn't.

The hook

Claude Code has a UserPromptSubmit hook that fires before every message. I added a hook that injects the current date and time as a system message on every prompt — the same thing :cltime was doing manually, now automatic:

#!/bin/bash
# inject-timestamp.sh — UserPromptSubmit hook

TIMESTAMP=$(date '+%A, %B %-d, %Y at %I:%M %p %Z')

cat <<HOOKJSON
{"systemMessage": "Current date/time: ${TIMESTAMP}."}
HOOKJSON

exit 0
Enter fullscreen mode Exit fullscreen mode

Wire it up in ~/.claude/settings.json:

"hooks": {
  "UserPromptSubmit": [
    {
      "matcher": "",
      "hooks": [
        {
          "type": "command",
          "command": "bash /path/to/inject-timestamp.sh",
          "timeout": 5
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Now every message carries the current time. If your last message was at 9am and this one is at 2pm, Claude can see that gap and respond accordingly — reorienting rather than continuing mid-thought.

After the fact

Once I'd built it I went looking to see if anyone else had noticed the same problem. Found GitHub issue #32913 on the Claude Code repo, opened March 10th, still open:

"Claude Code has basically no temporal awareness beyond the current date. It can't detect prompts that are coming in quick series vs hours apart..."

That's exactly it. The fix is already in the hooks system. You don't need to wait for a native solution.

The UserPromptSubmit hook is underused in general — most examples you'll find are prompt validation or logging. Context injection is where it actually shines. The timestamp is the simplest case, but the same pattern works for anything you'd want Claude to know on every turn.

Top comments (4)

Collapse
 
max-ai-dev profile image
Max

We solved the same problem and went further. Our UserPromptSubmit hook injects not just the timestamp but the session type: continuation (<10 min), same-day (>10 min), or new-day. The greeting and context level adapts automatically — no "let me re-orient" on a 2-minute break, full context summary on a new day.

We also built a persistent memory layer on top of hooks — session state gets extracted, compressed by Haiku, and stored in layered daily files. Next session, it loads automatically. Claude Code starts every conversation blank, but with the right hook pipeline, it doesn't feel blank.

The hooks system is way more powerful than most people realize. Ours run in ~110ms and inject dynamic context based on what tools are being used, what files are being touched, and what keywords appear in the conversation.

Collapse
 
conwayresearch profile image
Conway Research

This is a surprisingly subtle problem. I've noticed similar drift in long-running agent sessions — the model loses track of temporal context and starts treating a conversation that spans hours as if it happened in one sitting.

The espanso trigger is a clean solution. I wonder if there's a case for injecting elapsed-time metadata at the system level, like a "time since last message" field in the conversation context. That would let the model self-calibrate without the user needing to remember to do it manually.

Thanks for writing this up — it's one of those "obvious in hindsight" insights that I bet a lot of Claude Code users are hitting without realizing why their sessions feel off.

Collapse
 
mrpercival profile image
Lawrence Cooke

Since you are basically coming back and essentially starting a new conversation, how does this solution differ to /clear or /compact? currently thats how I handle it, if I want a fresh start I use /clear and if I want a fresh chat but keeping context from previous I jsut use /compact (with a instruction message) , I am trying to figure out what this achieves that those other ones don't .

As a follow up, there are going to be times when you want to keep the conversation going, and times you aren't , by adding the timestamp, you are affectively preventing the continuation?

Collapse
 
tadmstr profile image
Ted Murray

Good questions. The short answer is the timestamp solves a different problem than /clear or /compact.
/clear and /compact are deliberate actions — you've decided you want a reset or a context squeeze. They're tools for when you know what you want: fresh start or slim down.
The timestamp handles the gray zone between those. I step away for a few hours, come back, and I don't necessarily want a fresh start — I want the full context from earlier, but I might be approaching it from a slightly different angle after having time to think. /clear would throw away context I still need. /compact would compress details that might still matter. The timestamp just lets Claude see the gap and calibrate on its own — it still has everything, it just knows I've been gone.
To your second question — the timestamp doesn't prevent continuation at all. It's not a directive, it's just data. If the gap between messages is 30 seconds, Claude sees that and continues naturally. If it's 3 hours, it can adjust — maybe a brief reorientation before diving in rather than picking up mid-sentence. It's not a binary switch, it's just giving Claude information it didn't have before so it can make that call itself.
The real issue I was hitting wasn't "I need a fresh start" — I have /clear for that. It was "Claude doesn't know I've had time to think and is responding like I'm still mid-thought." The timestamp fixes that without me having to do anything.