Skip to content

Codex Wakatime

Codex plugin for Wakatime

Install: npm install -g codex-wakatime

Works with Codex · 31 GitHub stars

Install

$npm install -g codex-wakatime

Install command taken from the project's README or registry entry. Always review code before running it.

codex-wakatime

WakaTime integration for OpenAI Codex CLI. Track AI coding activity and time spent.

[!TIP] Also check out opencode-wakatime for OpenCode!

Features

  • Automatic time tracking for Codex CLI sessions
  • File-level activity detection via message parsing
  • 60-second heartbeat rate limiting
  • Automatic WakaTime CLI installation and updates
  • Cross-platform support (macOS, Linux, Windows)

Prerequisites

  1. WakaTime account and API key
  2. WakaTime API key configured in ~/.wakatime.cfg:
    [settings]
    api_key = your-api-key-here
    
  3. Codex CLI installed

Installation

# Install the package
npm install -g codex-wakatime

# Configure Codex hooks
codex-wakatime --install

This enables Codex lifecycle hooks and adds Stop and PostToolUse hooks to your ~/.codex/config.toml. If an older notify = ["codex-wakatime"] entry exists, it is migrated to hooks. Other notify commands are preserved.

How It Works

┌─────────────────────────────────────────────────────────────┐
│                     Codex CLI Session                        │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│              Stop / PostToolUse hooks                        │
│   Codex sends hook payloads with:                             │
│   - session-id, turn-id                                      │
│   - cwd (working directory)                                  │
│   - last-assistant-message on Stop                           │
│   - apply_patch input on PostToolUse                         │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                   codex-wakatime                             │
│   1. Parse hook JSON from stdin                              │
│   2. Extract file paths from apply_patch or assistant text   │
│   3. Check 60-second rate limit                              │
│   4. Send heartbeat(s) to WakaTime                           │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                   WakaTime Dashboard                         │
│   View your AI coding metrics at wakatime.com                │
└─────────────────────────────────────────────────────────────┘

Codex Hooks

Event Purpose
Stop Sends a turn-level heartbeat after each Codex turn completes
PostToolUse (apply_patch) Sends file-level write heartbeats for patch edits

Legacy agent-turn-complete notify payloads are still supported for existing manual setups.

File Detection Patterns

The plugin extracts edited files directly from apply_patch hook payloads. For turn-level fallback heartbeats, it extracts file paths from the assistant's response using these patterns:

  • Code block headers: ```typescript:src/index.ts
  • Backtick paths: `src/file.ts`
  • Action patterns: Created src/file.ts, Modified package.json
  • Quoted paths: "src/file.ts" or 'src/file.ts'

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

PluginDev tools+6,803 this week

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related