Skip to content

JianyueLab/claude-code-codetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeTime for Claude Code

Track your AI coding activity from Claude Code on your CodeTime dashboard — projects, languages, files, and git branches, the same way the CodeTime editor extensions do.

This is a Claude Code plugin modeled on wakatime/claude-code-wakatime, but it talks to the CodeTime API directly (CodeTime has no companion CLI, so the plugin does the transcript parsing, git detection, throttling, and upload itself in pure Node — zero runtime dependencies).

Install

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

Update later with:

claude plugin marketplace update codetime

Configure your token

Get your upload token from CodeTime → Settings at https://codetime.dev, then set it one of two ways:

  1. Environment variable (takes precedence):

    export CODETIME_TOKEN="your-token"
  2. Config file ~/.codetime/config.json:

    { "token": "your-token" }

Without a token the plugin does nothing (it never blocks Claude Code).

How it works

The plugin registers hooks for PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, and SessionEnd. On each event it:

  1. Reads the hook payload from stdin.
  2. Throttles to at most one heartbeat per 60 seconds (state stored next to the session transcript).
  3. Builds a CodeTime event — project (working-dir name), file + language (from Edit/Write/Read tool input), git branch/origin, platform, and a read/write operation type.
  4. POSTs it to https://api.codetime.dev/v3/users/event-log with Authorization: Bearer <token>.

Environment variables

Variable Purpose
CODETIME_TOKEN Upload token (overrides the config file).
CODETIME_API_URL Override the API base URL (default https://api.codetime.dev).
CODETIME_DEBUG Set to true for verbose logging.
CODETIME_HOME Override the base dir for config/state/log (default $HOME).

Troubleshooting

  • Logs: ~/.codetime/codetime.log
  • Plugin load errors: claude --debug, or claude doctor
  • A 401 in the log means the token is wrong or missing.

Develop

bun install
bun run build        # bundles src/ → dist/index.js with esbuild
echo '{"hook_event_name":"PostToolUse","cwd":"'$PWD'","tool_name":"Write","tool_input":{"file_path":"'$PWD'/src/index.ts"}}' \
  | CODETIME_DEBUG=true CODETIME_API_URL=http://localhost:8080 CODETIME_TOKEN=test node dist/index.js

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors