# Claktor

Website: https://claktor.com/


## Less is more.

Claktor shows your coding agent refactoring opportunities. Less code for your team and your agents to maintain.

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

Linux, macOS, any coding agent.

Agent prompt: Install Claktor with `curl -fsSL https://claktor.com/install | sh`, then run `~/.claktor/bin/claktor guide` and follow it to make 10 refactors in this repository.

- [For agents](https://claktor.com/agents.md)
- [About Claktor](https://claktor.com/about)

## Claktor on steipete/Markdansi

```
$ claktor similar src --target root-typescript-production
57  2 disjoint families sharing src/stream.ts
  36  function·approximate ×4
      src/stream.ts
        133–139  flushTable
        141–147  flushFence        97%
        126–131  flushHeldHeader   76%
        119–124  emitRendered      58%
```

−180 tokens after the merged refactor: three flush functions became one, flushPending.

Works with TypeScript, JavaScript, Python, Rust.

## Agents write code faster than anyone can read it.

Every line that stays in the repository is a line the next engineer, and the next agent, has to read before they can act. Left alone, a codebase only grows.

- +81% more duplicated code blocks than three years ago. The highest level on record. (GitClear, 623M code changes, 2023 to 2026) [Why agents repeat logic](https://claktor.com/learn/why-coding-agents-repeat-logic)
- Your agents have to maintain it too. Every duplicated implementation is another place to look, change and test.
- Claktor removes 3× more than Claude Code alone. Per dollar, across four open-source repositories.

## How it works

1. Install. One line. Your agent reads the guide and maps your repository.
2. Find repeated logic. Our analysis engine uses parsers and fuzzy AST matching to rank repetition by what sharing it would save, even when names and syntax differ. [How the search works](https://claktor.com/learn/how-claktor-searches-a-codebase)
3. Measure the change. Your agent writes the logic once and runs your checks. Claktor reports how much code the change removed. [How the count works](https://claktor.com/learn/how-claktor-measures-code)

## Agents add code all day. Claktor subtracts.

Every change leaves the program smaller and easier to understand, for the people who maintain it and the agents that build on it. Cheaper to read, cheaper to change.

### Three flush functions became one.

Merged in [steipete/Markdansi #23](https://github.com/steipete/Markdansi/pull/23).

- 50 fewer production lines.
- 3 flush functions → 1.

Before, in src/stream.ts, the flush helpers:

```ts
const flushHeldHeader = () => {
  if (!heldTableHeader) return "";
  const md = heldTableHeader;
  heldTableHeader = null;
  return emitRendered(md);
};

const flushTable = () => {
  if (!inTable) return "";
  inTable = false;
  const md = tableBuffer;
  tableBuffer = "";
  return emitRendered(md);
};

const flushFence = () => {
  if (!fence) return "";
  fence = null;
  const md = fenceBuffer;
  fenceBuffer = "";
  return emitRendered(md);
};
```

After:

```ts
const flushPending = () => {
  if (!pending) return "";
  const md = pending.md;
  pending = null;
  return emitRendered(md);
};
```

Source excerpts: [MIT license](https://claktor.com/licenses/markdansi.txt).

## Refactoring, solved.

One line installs Claktor. Your agent takes it from there. [How to use Claktor](https://claktor.com/learn/how-to-use-claktor)

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

- Email: contact@claktor.com
- [GitHub](https://github.com/claktor/cli)
- [LinkedIn](https://www.linkedin.com/company/claktor)
- [X](https://x.com/claktor)
- [Brand](https://claktor.com/brand.md): colours, type, the mark and the files.

## 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).
