cclens
A lens onto your Claude Code usage. cclens reads your session transcripts and
live configuration, extracts them into a local SQLite store, and shows where
time, tokens, and effort are being wasted — and how to fix it: unused or heavy
config, recurring tool failures, where the work gets stuck, and the cost picture
behind it all.
The design intent lives in docs/specs/; this README is how to
run it.
Install / build
With Homebrew (macOS and Linux, Intel and arm):
brew install lambdalisue/cclens/cclens
With Cargo, from crates.io (builds from
source; bundled SQLite needs a C compiler):
cargo install cclens
With Nix (no toolchain to set up):
nix run github:lambdalisue/cclens -- doctor # run without installing
nix profile install github:lambdalisue/cclens # install `cclens` onto PATH
nix profile install github:lambdalisue/cclens/vX.Y.Z # a specific release
From source — dev tools are pinned by the Nix flake, tasks run via just:
nix develop # enter the dev shell (pinned rust, just, sqlite, …)
just # list tasks
just check # rustfmt --check + clippy (the CI gate)
just test # cargo test
just build # release binary at target/release/cclens
Plain Cargo also works (cargo build --release) if you have a recent stable
Rust; the flake just pins it. CI runs nix develop -c just check / just test.
Publishing a GitHub Release for a vX.Y.Z tag builds binaries for Linux, macOS,
and Windows (x86_64 and arm64 each), attaches them to that release with
.sha256 files, points the
lambdalisue/homebrew-cclens
tap at the new archives, and publishes the crate to crates.io. The release is
published before its assets are built, so the notes are visible for a few
minutes with nothing attached yet.
The tag is the only place a version is written down: the release workflow
rewrites version in Cargo.toml from it before building and publishing, so
the committed 0.0.0 is a placeholder and cutting a release never means
bumping a file first. The flake stamps it too, without being told the tag:
VERSION is marked export-subst, so the archive GitHub serves for the tag
carries the tag in it (see
nix-github-release).
The tap covers Linux and macOS only; on Windows, take the -pc-windows-msvc
archive for your arch from the release, or build from source. CLAUDE_CONFIG_DIR
names the config tree directly when it is set to a non-empty path, as it does
for Claude Code itself. Otherwise — including when the variable is set but
empty — ~/.claude is located through HOME, falling back to USERPROFILE
where Windows leaves HOME unset.
Claude Code plugin
The repository is also a Claude Code plugin marketplace
(.claude-plugin/ + plugins/cclens/),
so you can drive cclens from inside a Claude Code session:
/plugin marketplace add lambdalisue/cclens
/plugin install cclens@cclens
| Skill | What it does |
|---|
/cclens:doctor | Analyze and present the one-screen health check in the session. |
/cclens:optimize | The cclens optimize advisor, in the current session: investigate the findings to root cause and propose concrete config fixes. |
/cclens:query | Answer an ad-hoc usage question with read-only SQL over the store. |
The skills use the cclens binary when it is on PATH and fall back to
nix run github:lambdalisue/cclens otherwise. They read and write the same
per-user store as the CLI.
Quick start
# 1. Start here — a one-screen health check, split into what to fix globally
# (~/.claude) vs per project. Analyzes automatically on first run.
cclens doctor
# 2. Narrow to the layer you're optimizing.
cclens doctor --scope global
cclens doctor --scope project:<slug>
# 3. Act on the findings: hand them to an interactive `claude` session that
# investigates each root cause and proposes concrete fixes.
cclens optimize --scope global
Analysis reads your transcripts (~/.claude/projects) and live config —
~/.claude/* plus each analyzed project's own .claude/ / CLAUDE.md —
read-only and incrementally, writing the store. Nothing is sent anywhere;
the store is a local file. Every command takes --db <path>; it defaults to
${XDG_STATE_HOME:-~/.local/state}/cclens/cclens.db — one per-user store,
because what is analyzed spans every project, not the directory you run from.
Pass --db ./cclens.db if you deliberately want a project-local one (and
.gitignore it). Read commands refresh the store automatically before reporting
(unchanged transcripts are skipped, so this is fast) and print a freshness line
on stderr; pass --frozen to read the store exactly as it is. Running
cclens analyze yourself is only needed to refresh without reading.