← Back to koji-lens

Documentation

Quickstart, command reference, config, and FAQ for koji-lens.

Quickstart

Up and running in 30 seconds.

$ npm install -g @kojihq/lens
$ koji-lens summary
$ koji-lens serve

Requirements: Node.js 22+ / Claude Code session logs in ~/.claude/projects/.

Command reference

Five subcommands. Run koji-lens <command> --help for details.

koji-lens summary

Show cost / token / tool usage summary for a period. Ends with a TOTAL block (overall aggregation) plus a note for subscription users (cost is API-equivalent, not actual billing).

Flag / argDescription
--since <expr>Period (default: "24h"). E.g. 24h / 7d / 2w / ISO date
--format <format>Output format: text | json (default: text)
--dir <path>Claude Code log directory (default: config.logDir or ~/.claude/projects)
--usd-jpy <rate>USD → JPY conversion rate (default: config.usdJpy or 155)
--no-cacheDisable SQLite cache (full scan every time)

Example:

$ koji-lens summary --since 7d --format json

koji-lens sessions

List sessions in a period, one line per session. Pick a session ID from this list, then drill into details with the session command.

Flag / argDescription
--since <expr>Period (default: "7d")
--limit <n>Number of sessions (default: 20)
--dir <path>Claude Code log directory
--no-cacheDisable SQLite cache

Example:

$ koji-lens sessions --since 24h --limit 5

koji-lens session <id>

Show full details of one session ID. Subagent IDs (with the agent- prefix) are also accepted; that case shows the subagent under the parent session.

Flag / argDescription
--format <format>Output format: text | json
--dir <path>Claude Code log directory
--usd-jpy <rate>USD → JPY conversion rate
--no-cacheDisable SQLite cache

Example:

$ koji-lens session 055a662d-f09c-4541-b54c-7ad4a9130f3d

koji-lens serve

Launch a local web dashboard. Next.js standalone bundle is shipped with the CLI, so no extra install is needed. Cost trend charts, session list, and tool usage distribution are available.

Flag / argDescription
--port <port>Port number (default: 3210)

Example:

$ koji-lens serve --port 3210

koji-lens statusline

One-line statusline output for Claude Code's statusLine integration. Shows month-over-month spend trend (💚/💛/🚨/⚪) + prompt cache hit rate (💎/🧊/💧). --buddy adds a koji mascot (Lv1-10), --buddy-speech enables sayings (e.g., 🍙· < Your call...). --combined co-displays ccusage output. See the README statusline section for setup.

Flag / argDescription
--mode <density>minimal | normal | detailed (default: normal)
--buddyAppend the koji mascot at the tail (Lv1-10 evolves with total session count)
--buddy-speechShow buddy sayings (5 states × 10 levels = 50 lines)
--buddy-type <type>Mascot type (currently `koji` only; owl / cat coming later)
--buddy-locale <ja|en>Saying locale (default: ja). Persistent: KOJI_LENS_BUDDY_LOCALE env var
--buddy-onlyShow only the buddy (suppresses spend/cache/state). Implies --buddy --buddy-speech
--combinedCo-display ccusage statusline before koji-lens output (cross-platform; falls back gracefully if ccusage isn't installed)
--no-stateSuppress the agent state icon (⚡/💤/🛑)
--no-spendSuppress the spend trend signal (💚/💛/🚨/⚪)
--no-cache-rateSuppress the cache hit rate signal (💎 X%)
--format <format>Output format: text | json

Example:

$ koji-lens statusline --mode minimal --combined --buddy --buddy-speech

koji-lens hook <state>

Cross-platform replacement for set-state.ps1 / set-state.sh. Updates ~/.koji-lens/state.json so the statusline can show ⚡/💤/🛑. Use directly inside Claude Code hooks (no shell script required).

Flag / argDescription
<state>thinking | running | idle | awaiting_approval

Example:

$ koji-lens hook running

koji-lens compare --before <range> --after <range>

Compare two periods (e.g., before vs after switching from Opus to Sonnet) to surface cost / token / model distribution deltas with rule-based insights.

Flag / argDescription
--before <range>Source period (e.g., 7d, 30d, ISO date range)
--after <range>Target period
--format <format>Output format: text | json

Example:

$ koji-lens compare --before 30d --after 7d

koji-lens trend

Weekly trend view. Shows changes in cache efficiency, p95 response time, and other time-series metrics. --with-attribution (Pro) flags vendor- vs user-attributed regressions.

Flag / argDescription
--weeks <n>Number of weeks (default: 12)
--with-attributionPro: append vendor / user attribution

Example:

$ koji-lens trend --weeks 8

koji-lens budget --budget <usd>

Monthly budget tracker. Shows month-to-date cumulative cost + linear forecast + over-budget warning. Multi-project budgets and config persistence available (Pro).

Flag / argDescription
--budget <usd>Monthly budget in USD (required)
--with-alertsPro: trigger budget alerts
--project <key>Pro: per-project budget
--listPro: list all per-project budgets

Example:

$ koji-lens budget --budget 200

koji-lens export

Export usage data as CSV / JSON. Stdout output or file output. Aligned with the data ownership policy (everything stays local; no external transmission).

Flag / argDescription
--format <format>csv | json (default: json)
--since <expr>Period (e.g., 30d)
--out <path>Output file path (stdout if omitted)

Example:

$ koji-lens export --format csv --since 30d --out usage.csv

koji-lens config <action> [key] [value]

Operate ~/.koji-lens/config.json from the CLI.

Flag / argDescription
<action>One of: get | set | unset | list | path
[key]Config key (logDir | usdJpy)
[value]Config value (only for set)

Example:

$ koji-lens config set usdJpy 158

Config

Settings are saved to ~/.koji-lens/config.json. Check the path with koji-lens config path.

logDirstring

Path to Claude Code logs. Defaults to ~/.claude/projects when unset. Override this when the install path differs (macOS / Windows / Linux).

usdJpynumber

USD → JPY conversion rate. Defaults to 155 when unset. Update manually if you want the latest rate.

List current settings: koji-lens config list / Set or update: koji-lens config set usdJpy 158

FAQ

Does the cost display make sense for Claude Pro / Max (subscription) users?

The displayed cost is API-equivalent (token count × Anthropic public API price). Subscription users pay a flat fee, so treat the displayed cost as a "usage indicator" and a "decision aid for choosing between Sonnet and Opus." The TOTAL block in summary output also shows a note to that effect.

When does the cache get refreshed?

The CLI checks each JSONL file's mtime and re-parses only sessions that changed. Use --no-cache to force a full scan. The cache DB is stored at ~/.koji-lens/cache.db. Cache hits are about 6× faster in practice.

Can I see the parent / child relationship for subagents?

Yes. Subagent session IDs are identified by the agent-* prefix, and the file path follows the structure <main-session-id>/subagents/agent-<id>.jsonl. Pass an agent- ID to the session command to drill into the subagent alone.

Are prompt bodies or API keys sent anywhere?

No. Everything runs locally on your machine. The SQLite cache deliberately does not store prompt bodies (only the metadata needed for aggregation). Safe to use under "no cloud" policies.

Does it work with Cursor / Cline / Aider?

Currently Claude Code only, but the internal design is adapter-based, and Cursor / Cline / Aider support is in OSS development. Track progress via GitHub Issues.

What's added in the Pro plan?

The Pro plan, launching late May 2026, will add cloud sync (unlimited history) / multi-device sync / CSV / JSON export / weekly / monthly email reports, and more. All Free plan features remain available. Get notified at the waitlist.

Where do I report bugs or feature requests?

GitHub Issues or Bluesky @kojihq.com — feel free to drop a message. The support email is also support@kojihq.com.

More