---
title: "Claude Code Doesn't Know What Time It Is — So I Fixed It"
summary: "Claude Code can't tell whether you left for two minutes or eight hours, so it picks up stale threads as if nothing changed. claude-prompt-timer is a small hook that tells it how long you've been away. Install it in three steps and confirm it works in one."
canonical: "https://cisoexpert.com/tools/claude-prompt-timer"
publishedAt: 2026-04-09
---

# Claude Code Doesn't Know What Time It Is — So I Fixed It

# Claude Code Doesn't Know What Time It Is — So I Fixed It

Claude Code doesn't know if you stepped away for two minutes or eight hours. I'd come back from lunch, type a follow-up, and it would carry on mid-thought from a discussion an hour old. It didn't recheck assumptions or ask whether anything had shifted.

**The fix isn't a better model. It's handing the model the one fact it's missing: how much time has passed.**

Why this matters: when an AI coding agent resumes a stale thread, it builds on a picture of the project that may no longer be true — files you edited by hand, a branch someone merged, a decision you changed over lunch. Anyone running long Claude Code sessions, or rolling the tool out to a team, ends up with work built on outdated assumptions and pays to redo it. So I built [`claude-prompt-timer`](https://github.com/davidmoneil/claude-prompt-timer), a small hook I run in my own sessions every day.

## What it does

A **hook** is a script Claude Code runs automatically at a fixed point in its lifecycle. This one is a `UserPromptSubmit` hook. According to the [Claude Code hooks reference](https://code.claude.com/docs/en/hooks), that event fires when you submit a prompt, before Claude processes it, and what the hook prints on success is added to Claude's context.

On each prompt the hook:

1. Reads the timestamp of your previous prompt from a small local state file
2. Calculates the elapsed time and records the new timestamp
3. Classifies the gap and injects one line of context

I set the bands around how my own workday breaks up:

| Elapsed time | What Claude sees |
|---|---|
| Under 2 minutes | Timestamp only |
| 2–30 minutes | Elapsed time |
| 30 minutes – 2 hours | "Short break" |
| 2–8 hours | "Extended break, context may need refresh" |
| Over 8 hours | "Long gap, context may have shifted significantly" |
| New session | "First prompt of session" |

Per the [README](https://github.com/davidmoneil/claude-prompt-timer), it needs Node.js 12+, has zero external dependencies, uses `Intl.DateTimeFormat` to detect your timezone, and keeps its state in `~/.claude/prompt-timer-state.json`. I wrote it with no API calls: just the clock and some basic math.

## Status, version and license

- **Version:** 1.0, the initial public release, pushed to GitHub on 2026-04-09.
- **Status:** maintained. I run it in my own sessions every day and fix what I find.
- **Provenance and license:** I wrote it, and the full source lives in the [public repo](https://github.com/davidmoneil/claude-prompt-timer). It's MIT licensed, so you can use, fork and modify it freely.

## Install it in three steps

The repo is set up as a plugin marketplace. Claude Code's [plugin docs](https://code.claude.com/docs/en/discover-plugins) describe the two-step flow: add a marketplace, then install a plugin from it.

1. **Add the marketplace** inside Claude Code:
   ```
   /plugin marketplace add davidmoneil/claude-prompt-timer
   ```
2. **Install the plugin:**
   ```
   /plugin install prompt-timer@claude-prompt-timer
   ```
   Or run `/plugin`, find `prompt-timer` in the available plugins, and install it from there.
3. **Restart your session** so the hook loads. It starts tracking from your next prompt, and there's nothing to configure.

Rather not use the marketplace? The [README](https://github.com/davidmoneil/claude-prompt-timer) also covers cloning the repo and loading it with `--plugin-dir`, or wiring the script into `settings.json` yourself as a `UserPromptSubmit` hook.

## Confirm it's working

Two quick checks:

- **Ask Claude.** After a break, ask "How long has it been since my last prompt?" If the hook is running, Claude answers with the elapsed time instead of guessing.
- **Check the debug log.** Start a session with `claude --debug` and look for the `UserPromptSubmit` hook run and its output.

## What I've seen so far

When Claude sees "extended break, context may need refresh," my sessions change. Before continuing, it rechecks what it assumed, asks a clarifying question, or re-reads a file, rather than barrelling ahead.

That's my observation from my own work, not a controlled test. I haven't run paired sessions with and without the timer, and Anthropic doesn't document this as a model behavior. Try it, and judge the results against your own sessions.

## Limits you should know

- **Surfaces.** I run it in the CLI. There's a [reported bug](https://github.com/anthropics/claude-code/issues/49063) where `UserPromptSubmit` context doesn't reach Claude in the VS Code extension.
- **One state file.** The README says the file holds the last prompt timestamp and a session ID. So it tracks the gap between your prompts, not per-project activity.
- **It informs; it doesn't enforce.** The hook tells Claude time has passed. What Claude does with that is still up to the model.
- **Local only.** State lives in your home directory. Read the script before you install it, which is good practice for any hook.

## Where time-awareness goes next

Once a hook knows the gap, other automation can branch on it. On a long gap it could re-read key project files, run a status check, look for new commits, or surface issues filed while you were away. I haven't built these yet. They're the obvious next experiments.

Security people will recognize the pattern. Break-glass access works because the system knows *when* something is happening, not just *what*, and adjusts its posture to match. How I see it: an agent that knows you've been gone eight hours should be more careful than one that saw you two minutes ago.

## Try it

**Good (5 minutes):** Install the plugin, and after your next break ask Claude how long it's been.

**Better (this week):** Watch how your sessions resume after long gaps. Notice when Claude rechecks something it would otherwise have assumed, and decide whether the bands fit how your day actually breaks up.

**Best (this month):** Fork it and chain one action onto long gaps, such as a context refresh or a `git status` check. Then ask what other signals your agents are missing. Time is one of the cheapest to supply.

If you find it misbehaving, open an issue on the repo. I'd rather be corrected than confident.

---

*David O'Neil is a CISO and builder who runs Claude Code on real projects daily. His open-source tools bring defense-in-depth principles to AI-assisted development.*
