hourslip

How to track time spent in Claude Code

Last updated . Claude Code docs checked 2026-10-08.

The short answer. Claude Code reports how long a session has run and how long it waited for the model: run /usage (or its alias /cost), or show the duration in your status line. Both are totals for one session. For hours per day or per project, read the timestamps Claude Code keeps on disk, export its active-time metric, run a timer, or use a plugin that records as you work.

What Claude Code itself shows

The commands reference lists /cost as “Alias for /usage”. The costs page says: “The Session block at the top of /usage shows detailed token usage statistics for your current session.” Its example:

Total cost:            $0.55
Total duration (API):  6m 20s
Total duration (wall): 6h 33m 10s
Total code changes:    0 lines added, 0 lines removed
Usage by model:
   claude-sonnet-4-6:  1.2k input, 5.3k output, 940.0k cache read, 50.0k cache write ($0.55)

Two durations, then: wall time and API time. The same page adds: “These totals reset when /clear starts a new session”.

The status line can show the same kind of numbers all the time. Its field cost.total_duration_ms is “Total wall-clock time the session has been running, in milliseconds. Accumulates across resumes and doesn't include time while the session isn't running”, and cost.total_api_duration_ms is “Total time spent waiting for API responses in milliseconds”.

That answers how long a session has been going. Neither number names a client or a ticket.

Active time, from telemetry

Claude Code can export metrics through OpenTelemetry, one of which is claude_code.active_time.total, in seconds. The monitoring docs describe it: “Tracks actual time spent actively using Claude Code, excluding idle time. This metric is incremented during user interactions, such as typing and reading responses, and during CLI processing, such as tool execution and AI response generation.” You need somewhere to send it; the setup on that page starts with export CLAUDE_CODE_ENABLE_TELEMETRY=1 and an exporter.

The timestamps on disk

Claude Code writes its application data under ~/.claude. Two kinds of file matter here:

From the prompt timestamps per project you can rebuild a day by hand: group prompts that are close together and count each group as one stretch of work. hourslip, below, does that as you work.

WakaTime

WakaTime has a Claude Code plugin. Its README (checked 2026-10-08): “Track your AI usage, lines of code generated, time spent prompting AI, etc. using the WakaTime plugin for Claude Code.” It installs as a Claude Code plugin:

claude plugin marketplace add https://github.com/wakatime/claude-code-wakatime.git
claude plugin i claude-code-wakatime@wakatime

The WakaTime page for Claude Code (checked 2026-10-08) starts with “Create a free account, then connect Claude Code using the instructions below.”

A timer

A stopwatch, or any time tracker you start when you sit down and stop when you get up. It also counts what happens outside Claude Code: the call with the client, the testing in a browser. It knows only what you remember to start and stop, and you split it by client yourself.

Hours per client and ticket: hourslip

hourslip is a Claude Code mod (a plugin of function hooks) that records when you send prompts and when Claude's turns start and end, with the folder and the git branch; never prompt text or file contents. The folder gives the client (from paths you set) and the branch gives the ticket: feat/ACME-182-login gives ACME-182. It counts time like this:

For example, a prompt at 9:00 that Claude works on until 9:20, then nothing until a prompt at 11:00, gives 9:00–9:30 and 11:00–11:10: 40 minutes, of which Claude worked 20. Had the second prompt come at 10:00, the gap would be under 45 minutes and the morning would be one stretch, 9:00–10:10.

How hourslip counts a morning A prompt at 9:00, Claude working until 9:20, and a prompt at 11:00 give two measured stretches, 9:00 to 9:30 and 11:00 to 11:10, 40 minutes in all. Claude's turn covers 9:00 to 9:20. Measured: 40 minutes Claude working: 20 minutes 9:00 10:00 11:00
The 10 minutes after each last event count; the gap between the stretches does not.

The status line shows today's time for the client of the folder you are in. After one prompt in a sample project (ACME Corp, branch feat/ACME-182-login) it read ⏱ ACME Corp · ACME-182 · 0h10 today. Time away from Claude Code is added by hand, and /hourslip shows the week:

Captured in Claude Code 2.1.293 on Windows, 2026-10-08, with a sample client (hourslip 0.2.2). The status line read 0h40 as soon as the 30 minutes were added, before the next prompt.

Every hourslip report carries the same line: “Measured from Claude Code activity. Time outside Claude Code, such as meetings or manual testing, appears only where it was added by hand, and is labelled so.”

What hourslip does not do