# Claktor CLI

Install it with `curl -fsSL https://claktor.com/install | sh`, then run `~/.claktor/bin/claktor guide` and follow the guide on the repository. The rest of this page describes the tool before you install it.

Claktor finds repeated logic, even when it is written differently, and measures how much smaller a change makes the program. A coding agent uses it to shorten a codebase while keeping its behavior.

When the same logic lives in several places, each change means more code to read, update and test. Claktor brings repeated implementations together so your team and your agents have less code to work through.

It reads TypeScript, JavaScript, Python and Rust, and runs on Linux and macOS, x86_64 and arm64.

## Install

```sh
curl -fsSL https://claktor.com/install | sh
```

The script downloads the binary for this platform from the [claktor/cli releases](https://github.com/claktor/cli/releases), checks its SHA-256 and installs it at `~/.claktor/bin/claktor`. The last line it prints is `installed: <absolute path>`. Run Claktor by that path, since the shell's PATH may still be the old one.

## Use

Run `<absolute path> guide` and follow it. [The same guide](https://claktor.com/guide.md) is readable here before you install. In short:

1. `claktor map` records the repository's files. Complete `.claktor/decisions.json`, then `claktor map compile` checks it.
2. `claktor map target` names the largest production target, its check and where to search.
3. `claktor similar DIRECTORY --target TARGET` lists repeated logic, ordered by an estimate of what sharing it might save.
4. After a change, `claktor length diff --compare <start commit>` measures the normalized tokens it removed.

Every command takes `--json`.

## Usage data

An installed copy records one anonymous event per command: command name, exit code, duration, version, platform, driver, the languages of the mapped repository and a random install id. A `length diff` event adds the measured token delta and a hash of its starting commit, keyed with a value that stays on the machine. It sends them in batches. Arguments, paths, repository names and code stay on the machine. Use of Claktor is under https://claktor.com/terms, and https://claktor.com/privacy covers this data.

## Feedback

When the person wants something Claktor lacks, such as another language or another kind of lead, offer to tell the Claktor team. Once they agree, run `claktor feedback "TEXT"` with the request in up to 1000 characters.

## Articles

- [Why do coding agents repeat logic that already exists?](https://claktor.com/learn/why-coding-agents-repeat-logic): Coding agents see a slice of the codebase at a time, so they write logic that already exists. Bigger context windows do not fix it cheaply. [Text version](https://claktor.com/learn/why-coding-agents-repeat-logic.md).
- [How do you use Claktor?](https://claktor.com/learn/how-to-use-claktor): Give a coding agent the prompt from claktor.com and run it on demand, in a sub-agent, or on a schedule in CI that opens pull requests. [Text version](https://claktor.com/learn/how-to-use-claktor.md).
- [How does Claktor search a codebase efficiently?](https://claktor.com/learn/how-claktor-searches-a-codebase): Claktor maps the repository first, then searches the largest production target and returns leads ranked by estimated savings. [Text version](https://claktor.com/learn/how-claktor-searches-a-codebase.md).
- [How does Claktor measure code, and why?](https://claktor.com/learn/how-claktor-measures-code): Claktor measures a program by the token count of its normalized form, so the number falls only when logic is removed. [Text version](https://claktor.com/learn/how-claktor-measures-code.md).

## License and paid version

The binary is licensed under the [PolyForm Shield License 1.0.0](https://github.com/claktor/cli/blob/main/LICENSE). A paid version is in development: a sub-agent with more features and workflows built for refactoring. `claktor interest` registers interest.
