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:
projects/<project>/<session>.jsonl: “Full conversation transcript: every message, tool call, and tool result”. The data usage page says Claude Code clients “store session transcripts locally in plaintext under~/.claude/projects/for 30 days by default”, and: “Adjust the period withcleanupPeriodDays.”history.jsonl: “Every prompt you've typed, with timestamp and project path.” It is listed under kept until you delete them.
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:
- A gap of more than 45 minutes between events ends a stretch of work.
- Each stretch runs from its first event to 10 minutes after its last (a 10-minute pad), or to the session's end if that comes first. A lone prompt counts 10 minutes.
- Opening Claude Code without sending a prompt counts nothing.
- “Claude” time is each turn, from its start to its end.
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.
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:
❯ /hourslip add 30m acme "Call with ACME"
⎿ hourslip: Added 0h30 by hand for ACME Corp on 2026-10-08. Reports label it "added by hand".
❯ /hourslip
⎿ hourslip: Week of 2026-10-05
Thu 10-08 ACME Corp 0h40 (Claude 0h00)
Total ACME Corp 0h40
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
- Time away from Claude Code is not seen unless added by hand with
/hourslip add: meetings, calls, testing in a browser, thinking away from the keyboard. - Hours exist only for time spent in Claude Code with the mod loaded. A session where an organization policy disables mods records nothing.
- A stretch ends 10 minutes after its last event. Reading or testing for longer than that without a prompt counts only up to that pad.
- Timestamps come from your own clock and are trusted: the hours are a lower bound, not a tamper-proof record.
- hourslip has been checked only on Windows; macOS and Linux have not been checked.
Related
- All guides
- A sample hourslip report
- Manage costs effectively, Claude Code docs
- Install hourslip, free