Skip to content

Automatic time tracking for Claude Code

Last updated: November 2026

You run Claude Code in one terminal and Codex in another. An agent works for ten minutes while you read a diff. At the end of the month you can’t say where the hours went. The good news: Claude Code already writes down most of what you need. This guide shows where, how to hook into it, and which tools turn it into hours.

What Claude Code already records

Claude Code keeps a transcript of every session on your disk, one JSONL file per session under ~/.claude/projects/. Each line is a JSON object with a timestamp: your prompt, a tool call, a reply. So the start, the end and the project folder of every session are already there.

Claude Code also runs hooks: shell commands at fixed moments such as SessionStart, UserPromptSubmit, PreToolUse, Stop and SessionEnd. You configure them in ~/.claude/settings.json for all projects, or in .claude/settings.json or .claude/settings.local.json inside one repo. Each hook receives JSON on standard input, including the session id, the working directory and the path to the transcript.

Do it yourself with two hooks

If you only want raw times, two hooks are enough. Put this in ~/.claude/settings.json (it needs jq):

{
  "hooks": {
    "SessionStart": [{ "hooks": [{ "type": "command",
      "command": "jq -r '[now|todate, \"start\", .session_id, .cwd] | @tsv' >> ~/claude-time.tsv" }] }],
    "SessionEnd": [{ "hooks": [{ "type": "command",
      "command": "jq -r '[now|todate, \"end\", .session_id, .cwd] | @tsv' >> ~/claude-time.tsv" }] }]
  }
}

Every session now leaves a start and an end line with its folder. You still have to pair them, subtract idle time and map folders to clients. That part is where most people stop.

Tools that do it for you

  • WakaTime: install the open-source plugin with claude plugin marketplace add https://github.com/wakatime/claude-code-wakatime.git and claude plugin i claude-code-wakatime@wakatime, then put your API key in ~/.wakatime.cfg. You get a dashboard with time per project, language and branch. Your activity goes to WakaTime’s servers, behind an account.
  • trackmy.codes: a Mac app that detects Claude Code, Codex, Cursor and Antigravity, counts active time and makes a daily streak card. Local, no account. It has no clients or rates.
  • Døgn: a local time tracker for Mac, Windows and Linux. It reads the same sessions and puts each one on a client and project, so you can bill it. Details below.

How it works in Døgn

Open Settings › AI sessions and switch on Claude Code. Døgn writes a small hook script into ~/.claude and registers it in settings.json. Hooks you already have stay in place. Then, once per repo, tell Claude “Set up Døgn time tracking.” That creates a .dogn file that links the folder to a project. Without it, Døgn guesses the project from the folder name.

From then on each session runs as its own timer, next to any timer you started yourself. If a session goes quiet, Døgn stops it after the idle time you set. When it ends, Døgn asks: discard it, book the total, or book only the active time. For the description, Døgn hands up to six of your prompts, cut to 200 characters each, to your own claude command line and gets a one-line summary back. That call goes through your Claude account, under Anthropic’s terms. Optionally Claude Code shows the running timer in its status line.

The same works for Codex (hook in ~/.codex) and Antigravity (hook in ~/.gemini). Antigravity sessions get no automatic description. See Døgn for developers.

Questions, answered

Does Claude Code track time by itself?

Not as billable time. It keeps a timestamped transcript of every session on your disk, but it shows no time report. You need a hook or a separate tool to turn that into hours.

Where does Claude Code store my sessions?

In JSONL files under ~/.claude/projects/, one per session. They stay on your disk. Claude Code itself still sends your prompts to Anthropic to answer them, but no time tracking data leaves your computer unless a tool you install sends it.

Can I track parallel agents in several terminals?

Yes, because every session has its own id and transcript. A tracker that works per session keeps them on separate lines. Døgn runs one timer per session.

Which of these tools send data to a server?

WakaTime sends coding activity to its cloud. trackmy.codes uploads nothing. Døgn keeps your hours on your computer; for descriptions it calls your own claude or codex command line, which talks to that provider. A DIY hook writes wherever you point it.

Continue