Docs · Practices
What your Claude Code sessions cost, and what to change
A Claude Code plugin that reads your repository's own sessions on your machine, shows what they cost, and proposes each change with the numbers behind it. It writes only the ones you pick.
What does selan-practices do?
selan-practices reads the transcripts Claude Code keeps on your machine for the
repository you are in and counts what the sessions did: what every request carried, which commands
ran and how often, which skills were used, and which checks ran before a commit.
From those counts it proposes changes to how the repository is set up for Claude Code. Each proposal quotes the line it came from and the saving over the period covered. Something the sessions did once is not a proposal. On a repository with no sessions yet, see Start here. The glossary explains the files and settings it talks about.
How do I install it?
On the Selan CLI it is already installed. Anywhere else, run these two lines inside Claude Code:
/plugin marketplace add selan-ai/selan-practices
/plugin install selan-practices@selan-practices
It needs python3 on your PATH, and nothing else. The source is public and
MIT licensed at
github.com/selan-ai/selan-practices.
Start Claude Code inside the repository you want to look at: each command reads the sessions of the
directory it runs in, and no other.
Where do I start on a new repository?
/selan-practices:setup
Works on a new repository with no history, from the files alone.
What it shows. Five lines at most: the stack, the checks it has, whether a red
pipeline blocks a merge, its AGENTS.md or CLAUDE.md, and how many
sessions there are to learn from.
What it proposes. A plan of at most five items, each with a plain sentence on what
it is and why it helps. It skips what is already in place. The items come from one list, in this
order: an AGENTS.md, turning on merge enforcement, moving a check that runs only after
merge onto merge requests, code review, and dead-code detection as a suggestion. Where a
component does the item, the plan names it.
You pick, it writes. Answer with the numbers you want, or “all”. It makes those changes, runs each one's check and shows you the diff. It never commits. With fewer than five sessions, it ends by saying to run it again in two weeks.
How do I install a component?
/selan-practices:install code-review
/selan-practices:install dead-code
Each component adds one practice. With no name, the command lists both and says which is installed.
| Component | What it adds |
|---|---|
code-review |
An agent that reviews every merge request and writes a severity table with a fix per finding. See Code review. |
dead-code |
Finds code nothing reaches, locally and in CI. The tool depends on the stack: knip for TypeScript and JavaScript, deadcode for Go, vulture for Python, clippy for Rust, Periphery for Swift, detekt for Kotlin, PMD for Java. On Kotlin and Java it finds unused private code and resources, not an unused public API. |
It reads the repository's AGENTS.md (or CLAUDE.md) and CI file first and
follows their conventions, such as runner tags and the package manager. It says in three lines
what it will add, adds it, runs the component's own verification and shows you the diff. It never
commits.
A component that needs a secret never asks for its value. It names
the CI variable to create, where, and with which flags (masked, protected). For
code-review that is SELAN_TOKEN, or
ANTHROPIC_API_KEY without Selan.
What can it audit after a few weeks?
The next three commands read what the sessions did, so they need a few weeks of them.
1. What does every request pay for?
/selan-practices:context-audit
What it looks at. AGENTS.md (or CLAUDE.md) is sent with
every request, so its size times your request count is often the largest single cost. The audit
also counts command output filtered after the fact, work done in another repository, large and
generated files read, and paths AGENTS.md names that no longer exist.
A real finding. One repository had a 444-line CLAUDE.md,
sent with every request. In another, sessions ran
npx tsc | grep -v node_modules 1,988 times: the whole type check output,
cut down after it had already been produced.
What it proposes. An AGENTS.md under 200 lines, with sections that
only one kind of task needs moved into a rule file or a skill. For the filtered command, one quiet
script that prints only what the filter kept, named in AGENTS.md in place of the
command.
2. Which skills are actually used?
/selan-practices:skill-audit
What it looks at. Every skill and agent a session had (the repository's, your
personal ones and plugins'): which ran, which failed, and which were worked around, where a session
ran a skill's own commands by hand. It also flags two skills with the same name, and throwaway
scripts written to /tmp in session after session.
A real finding. A project skill had the same name as one in the developer's own
~/.claude. Only the personal one ever ran, so sessions kept writing their own watch
scripts in /tmp instead of using the project skill's.
What it proposes. Rename or merge one of the two, keeping the one that holds the scripts the sessions needed. It never deletes a personal or plugin skill: it tells you what to remove.
3. What does done mean in this repository?
/selan-practices:quality-gates
What it looks at. The repository's checks, cheapest first: format, lint, typecheck, build, unit, integration, e2e, budget, secrets, review. For each it shows where it runs: a local command someone has to remember, a hook, a CI job that only advises, or a CI job that blocks the merge. From the transcripts it counts commits made with no check since the last edit, and the CI failures sessions ran into.
A real finding. A site whose only check ran after merge, so a broken change was already merged when it failed. And nine repositories where a red pipeline did not block the merge, because the project setting that requires a green pipeline was off.
What it proposes. A blocking job on merge requests for a check that only ran after
merge. For the merge setting, which is not a file, it names the setting to turn on: “Pipelines must
succeed” on GitLab, required status checks on GitHub. Where commits often go in unchecked, a hook
that runs the quick check before git commit.
How does it work?
setup and the three audits each work in two turns:
- It proposes. Each change says what to change, quotes the line from the report it comes from, and names the file it touches. An audit also gives the numbers, largest saving first. It ends with one question: which ones to apply.
- You pick. Answer with the numbers you want, or none.
- It writes. It makes only those changes and shows you the diff. It never commits.
If a repository has no sessions yet, an audit says so and stops; Start here works from the files.
Your transcripts never leave your machine. A standard-library Python script reads
them locally and prints a summary of counts; the session sees that summary, not the transcripts.
To read the merge setting, quality-gates also asks GitLab or GitHub through
glab or gh, with your own login.
Glossary
| Term | What it is |
|---|---|
AGENTS.md |
A file at the root of the repository that Claude Code sends with every request: commands, rules and traps every session needs. Claude Code reads CLAUDE.md instead where a repository has one. |
.claude/rules/ with paths: |
Rule files that load only when a file matching their paths: is read, so a rule for one directory costs nothing elsewhere. |
| Skill | A named, multi-step procedure, often with a script beside it, loaded only when it is called or relevant. |
| Hook | A command Claude Code runs on its own at a set moment, such as before a git commit, and that can block it. |
| Quality gate | A check a change must pass, and the place it runs: a local command, a hook, or a CI job that blocks the merge. |