ClaudeMods
☰
JA
● 0 人がオンライン ・閲覧 0 回
スポンサー作品を投稿
GitHub リポジトリ · 投稿者 0xGondarxyz

active-time

Claude Code と実際に過ごした時間(入力中と Claude の作業時間。アイドル状態のターミナルは除く)を数え、ステータスラインと /claude-time に表示する Claude Code mod。

0xGondarxyz@0xGondarxyz

0xGondarxyz/claude-code-mods/tree/main/active-time

翻訳済み

この mod について

active-time

Claude Code と実際に過ごした時間を数える Claude Code mod です。開いているだけのターミナルは数えません。バックグラウンドで動く開発サーバーも数えません。

この mod は active-time というフォルダーにあります。Claude Code では claude- で始まるプラグイン名が予約されているためです。コマンドは引き続き /claude-time です。

インストール

/plugin marketplace add 0xGondarxyz/claude-code-mods
/plugin install active-time@claude-code-mods

インストールせずに試すこともできます。

git clone https://github.com/0xGondarxyz/claude-code-mods
claude --plugin-dir claude-code-mods/active-time

Mods はサンドボックス化されません。Claude Code と同じアクセス権で動作します。この mod を含め、インストールする前に必ずソースを読んでください。

カウントされるもの

アクティブ時間には 2 種類あります。

  • you:プロンプトボックスに入力している時間です。間隔が 120 s 以下の編集は 1 つの区間になります。長く間を空けると新しい区間が始まります。プロンプトを送信すると区間を閉じます。
  • claude:Claude が作業している時間です。すべてのエージェントの各モデルリクエストと各ツール呼び出しが対象です(1 回のツール呼び出しは最大 10 分)。バックグラウンドのサブエージェントが作業している時間も含まれます。これらの間隔が 30 s 以下ならつながります。質問への回答待ちなど、ターンの待ち時間は含めず、その中のモデルリクエストとツール呼び出しだけを数えます。

合計は 2 種類の時間の和集合です。重なりは 1 回だけ数えます。同時に動く 2 つのセッションも 1 回だけ数えます。

ステータスライン

CC today 2h14m · week 11h05m

1 日の作業日は現地時間 05:00 から翌 05:00 までです。深夜以降の作業は前日の分になります。週は月曜日 05:00 に始まります。各ターン後と 60 s ごとに更新されます。

コマンド

/claude-time は次を表示します。

  • 今日、今週、今月の時間。それぞれ you と claude に分割
  • 過去 7 日間(1 日 1 行)
  • 今週のリポジトリ別(フォルダー名順の上位 5 件)

データの場所

各セッションは専用ファイルに書き込むため、互いに上書きしません。

~/.claude/active-time/<YYYY-MM-DD>_<sessionId>.json

内容は { "repo": "...", "intervals": [{ "s": ms, "e": ms, "k": "you" | "claude" }] } です。05:00 をまたぐセッションは作業日ごとに 1 ファイルを書き込み、<YYYY-MM-DD> が作業日になります。repo はセッションフォルダーの git のルート、またはフォルダー自身です。

リセットするにはフォルダーを削除します。

rm -r ~/.claude/active-time

トランスクリプトからのバックフィル

mod の読み込み前に始まったセッションは、過去 40 日分の ~/.claude/projects にあるトランスクリプトから再構築されます。Claude の時間だけが得られ、過去セッションの入力時間は復元できません。

  • 各トランスクリプト項目にはタイムスタンプがあります。連続する 2 つの項目の間で、2 つ目が実際のユーザープロンプトではなく間隔が 10 分以下なら、その間は claude 時間になります。プロンプトは待ち時間を開始します。より長い間隔も待ち時間です。30 s 以下の間隔はつながります。
  • ヘッドレスのトランスクリプト(claude -p、SDK)はスキップされます。
  • 結果は ~/.claude/active-time/<YYYY-MM-DD>_<sessionId>.bf.json に書き込まれます(同じ形に "source": "transcript" を加えたもの)。ライブファイルは変更されません。合計はすべてのファイルの和集合を取るため、両方の種類があっても 1 回だけ数えます。
  • インタラクティブセッションの開始時にバックグラウンドで実行され、その後 10 分おきに実行されます。前回の実行後に変更されたトランスクリプトだけが再読込されます。初回は時間がかかることがあります。
  • python3(/usr/bin/python3)と find が必要です。

ヘッドレス実行

プロンプトに人がいないセッション(claude -p、SDK)は何も記録せず、ファイルもステータスラインも作りません。

制限

  • Claude Code がクラッシュしたとき開いたままの区間は失われます。
  • 許可の回答を待つツール呼び出しは Claude の時間に含まれます(最大 10 分)。
  • 入力の検出はメインのプロンプトボックスだけです。
  • 合計はウォールクロック時間であり、課金時間ではありません。

インストール

まず作者の README で marketplace とプラグイン名を確認してください。コマンドはリポジトリの構成によって変わる場合があります。

claude plugin marketplace add 0xGondarxyz/claude-code-mods
claude plugin install active-time
原文 / README

active-time

A Claude Code mod that counts the time you really spend with Claude Code. An open terminal does not count. A dev server running in the background does not count.

The mod lives in a folder named active-time because Claude Code reserves plugin names that start with claude-. The command is still /claude-time.

Install

/plugin marketplace add 0xGondarxyz/claude-code-mods
/plugin install active-time@claude-code-mods

Or try it without installing:

git clone https://github.com/0xGondarxyz/claude-code-mods
claude --plugin-dir claude-code-mods/active-time

Mods are not sandboxed. They run with the same access as Claude Code. Read the source before you install any mod, including this one.

What counts

Two kinds of active time:

  • you: you write in the prompt box. Edits with a gap of 120 s or less form one interval. A longer pause starts a new one. Submitting a prompt closes the interval.
  • claude: Claude works. This is each model request and each tool call of any agent of any agent (one tool call counts at most 10 minutes). Background subagents count while they work. Gaps of 30 s or less between these join. The wait of a turn (for example on a question) does not count, only the model requests and tool calls inside it.

The total is the union of both kinds. Overlaps count once. Two sessions that work at the same time count once.

Status line

CC today 2h14m · week 11h05m

A day is a work day from 05:00 to 05:00 local time, so work after midnight counts for the day before. The week starts on Monday 05:00. It updates after each turn and every 60 s.

Command

/claude-time shows:

  • today, this week and this month, each split into you and claude
  • the last 7 days, one line each
  • this week per repo (top 5, by folder name)

Where the data lives

Each session writes its own file, so sessions never overwrite each other:

~/.claude/active-time/<YYYY-MM-DD>_<sessionId>.json

Content: { "repo": "...", "intervals": [{ "s": ms, "e": ms, "k": "you" | "claude" }] }. A session that crosses 05:00 writes one file per work day, and <YYYY-MM-DD> is the work day. The repo is the git top level of the session folder, or the folder itself.

To reset, delete the folder:

rm -r ~/.claude/active-time

Backfill from transcripts

Sessions that started before the mod loaded are rebuilt from the transcripts in ~/.claude/projects, for the last 40 days. This gives Claude time only. Typing time of old sessions cannot be recovered.

  • Each transcript entry has a timestamp. For two entries in a row, the time between them counts as claude time when the second one is not a real user prompt and the gap is 10 minutes or less. A prompt starts a wait. A longer gap is a wait too. Gaps of 30 s or less join.
  • Headless transcripts (claude -p, the SDK) are skipped.
  • Results go to ~/.claude/active-time/<YYYY-MM-DD>_<sessionId>.bf.json (same shape plus "source": "transcript"). Live files are never touched. Totals take the union of all files, so a session with both kinds counts once.
  • It runs in the background at the start of an interactive session, then every 10 minutes. Only transcripts changed since the last run are read again. The first run can take a while.
  • It needs python3 (/usr/bin/python3) and find.

Headless runs

Sessions without a person at the prompt (claude -p, the SDK) record nothing, write no file and show no status line.

Limits

  • Intervals still open when Claude Code crashes are lost.
  • A tool call that waits for your permission answer counts as Claude time (up to the 10 minute cap).
  • Typing is seen only in the main prompt box.
  • Totals are wall clock, not billed time.

関連作品