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.
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
Wire it up in ~/.claude/settings.json:
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "bash /path/to/inject-timestamp.sh",
"timeout": 5
}
]
}
]
}
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 (0)