Skip to main content
Glama
README.md
# codeprint

An afternoon experiment: index your own git history and serve your coding style back to
Claude over MCP, in the spirit of "write code like your favorite author," except the
author is you.

This is more novelty than daily tool. It works, but it is not something reached for
on every task; treat it as a proof of concept for style-conditioned code generation,
not a production pipeline.

## What it does

codeprint walks your authored commits, uses tree-sitter to snapshot each touched
function as it existed at that commit, dedupes to the latest version per symbol, and
drops anything you contributed less than half of (`--min-contribution`) so lightly
touched code never enters the profile. Each surviving function gets a one-line summary
from Claude, an embedding from Voyage, and a home in a local SQLite database
(`sqlite-vec` for the vector search). Everything is keyed by content hash, so
re-running only pays for new or changed code.

From that corpus, an LLM distills a tiered style rulebook (universal rules, then
per-language, then per-stack) and a separate pass classifies how you revise your own
code across successive commits into a refinement profile.

## Serve it to Claude

A local MCP server exposes the profile as tools:

- `get_style_rules(language?)`: the rulebook, filtered to the target language.
- `find_exemplars(task, language?, k?)`: your prior code most similar to a task, as
  few-shot exemplars.
- `get_refinement_patterns()`: how you revise and refactor your own code.

A companion skill (`skill/codeprint-style/`) wires these into Claude Code. It never
auto-triggers (`disable-model-invocation: true`); invoke it explicitly with
`/codeprint-style` when you want code written in your style.

## Setup

Requires Node 22+, `VOYAGE_API_KEY` for embeddings, and either `ANTHROPIC_API_KEY` or a
logged-in local `claude` CLI (LLM calls default to whichever is available; the
`claude`-CLI path runs headless `claude -p` so it bills against a Claude subscription
instead of API rates).

```sh
npm install && npm run build
```

## Index a repo

```sh
codeprint index ~/Documents/GitHub/myrepo \
  --profile matt \
  --author me@example.com me@work.com \
  --since 2024-01-01
```

## Serve to Claude

`.mcp.json` (or Claude Code MCP settings):

```json
{
  "mcpServers": {
    "codeprint": {
      "command": "codeprint",
      "args": ["serve", "--profile", "matt"]
    }
  }
}
```

Install the skill by copying `skill/codeprint-style/` into `~/.claude/skills/`.

## Other commands

- `codeprint distill`: re-run rulebook distillation without re-indexing.
- `codeprint refine`: classify revision history and distill refinement patterns.
- `codeprint eval`: a blind A/B harness that generates styled vs. baseline solutions
  to built-in tasks and has a separate judge model score and guess which is which.
- `codeprint site`: renders a shareable "coding personality" HTML page from the
  distilled profile.

## White paper

`report/` holds a longer write-up: architecture, the rulebook, honesty checks against
project-specific residue, blind eval results, and refinement findings, with a small
Bun static server (`report/server.ts`) to view it locally.