Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

What is PRECC?

PRECC (Predictive Error Correction for Claude Code) is a Rust tool that intercepts Claude Code bash commands via the official PreToolUse hook mechanism. It fixes errors before they happen, saving tokens and eliminating retry loops.

Free for community users.

The Problem

Claude Code wastes significant tokens on preventable mistakes:

  • Wrong-directory errors – Running cargo build in a parent directory that has no Cargo.toml, then retrying after reading the error.
  • Retry loops – A failed command produces verbose output, Claude reads it, reasons about it, and retries. Each cycle burns hundreds of tokens.
  • Verbose output – Commands like find or ls -R dump thousands of lines that Claude must process.

The Four Pillars

Context Fix (cd-prepend)

Detects when commands like cargo build or npm test run in the wrong directory and prepends cd /correct/path && before execution.

GDB Debugging

Detects opportunities to attach GDB for deeper debugging of segfaults and crashes, providing structured debug information instead of raw core dumps.

Session Mining

Mines Claude Code session logs for failure-fix pairs. When the same mistake recurs, PRECC already knows the fix and applies it automatically.

Automation Skills

A library of built-in and mined skills that match command patterns and rewrite them. Skills are defined as TOML files or SQLite rows, making them easy to inspect, edit, and share.

How It Works (30-Second Version)

  1. Claude Code is about to run a bash command.
  2. The PreToolUse hook sends the command to precc-hook as JSON on stdin.
  3. precc-hook runs the command through the pipeline (skills, directory correction, compression) in under 3 milliseconds.
  4. The corrected command is returned as JSON on stdout.
  5. Claude Code executes the corrected command instead.

Claude never sees the error. No tokens wasted.

Adaptive Compression

If a command fails after compression, PRECC automatically skips compression on the retry so Claude gets the full uncompressed output to debug with.

Live Usage Statistics

MetricValue
Hook invocations
Tokens saved
Saving ratio%
RTK rewrites
CD corrections
Hook latency ms (p50)

Figures are estimates. Each prevented failure avoids a full retry cycle: error output, model reasoning, and retry command. These numbers update automatically from anonymized telemetry.

Installation

Quick Install (Linux / macOS)

curl -fsSL https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.sh | bash

This downloads the latest release binary for your platform, verifies the SHA256 checksum, and places it in ~/.local/bin/.

After installation, initialize PRECC:

precc init

precc init registers the PreToolUse hook with Claude Code, creates the data directories, and initializes the skills database.

Install Options

SHA256 Verification

By default, the installer verifies the binary checksum against the published SHA256 sum. To skip verification (not recommended):

curl -fsSL https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.sh | bash -s -- --no-verify

Custom Install Prefix

Install to a custom location:

curl -fsSL https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.sh | bash -s -- --prefix /opt/precc

Companion Tools (–extras)

PRECC ships with optional companion tools. Install them with --extras:

curl -fsSL https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.sh | bash -s -- --extras

This installs:

ToolPurpose
RTKCommand rewriting toolkit
lean-ctxContext compression for CLAUDE.md and prompt files
nushellStructured shell for advanced pipelines
cocoindex-codeCode indexing for faster context resolution

Windows (PowerShell)

irm https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.ps1 | iex

Then initialize:

precc init

Manual Install

  1. Download the release binary for your platform from GitHub Releases.
  2. Verify the SHA256 checksum against the .sha256 file in the release.
  3. Place the binary in a directory on your PATH (e.g., ~/.local/bin/).
  4. Run precc init.

Updating

precc update

Force update to a specific version:

precc update --force --version 0.3.0

Enable automatic updates:

precc update --auto

Verifying Installation

$ precc --version
precc 0.3.0

$ precc savings
Session savings: 0 tokens (no commands intercepted yet)

If precc is not found, ensure ~/.local/bin is on your PATH.

Quickstart

Get PRECC running in 5 minutes.

Step 1: Install

curl -fsSL https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.sh | bash

Step 2: Initialize

$ precc init
[precc] Hook registered with Claude Code
[precc] Created ~/.local/share/precc/
[precc] Initialized heuristics.db with 8 built-in skills
[precc] Ready.

Step 3: Verify the Hook Is Active

$ precc skills list
  # Name               Type      Triggers
  1 cargo-wrong-dir    built-in  cargo build/test/clippy outside Rust project
  2 git-wrong-dir      built-in  git * outside a repo
  3 go-wrong-dir       built-in  go build/test outside Go module
  4 make-wrong-dir     built-in  make without Makefile in cwd
  5 npm-wrong-dir      built-in  npm/npx/pnpm/yarn outside Node project
  6 python-wrong-dir   built-in  python/pytest/pip outside Python project
  7 jj-translate       built-in  git * in jj-colocated repo
  8 asciinema-gif      built-in  asciinema rec

Step 4: Use Claude Code Normally

Open Claude Code and work as usual. PRECC runs silently in the background. When Claude issues a command that would fail, PRECC corrects it before execution.

Example: Wrong-Directory Cargo Build

Suppose your project is at ~/projects/myapp/ and Claude issues:

cargo build

from ~/projects/ (one level too high, no Cargo.toml there).

Without PRECC: Claude gets the error could not find Cargo.toml in /home/user/projects or any parent directory, reads it, reasons about it, then retries with cd myapp && cargo build. Cost: ~2,000 tokens wasted.

With PRECC: The hook detects the missing Cargo.toml, finds it in myapp/, and rewrites the command to:

cd /home/user/projects/myapp && cargo build

Claude never sees an error. Zero tokens wasted.

Step 5: Check Your Savings

After a session, see how many tokens PRECC saved:

$ precc savings
Session Token Savings
=====================
Total estimated savings: 4,312 tokens

Breakdown:
  Pillar 1 (cd prepends):       2,104 tokens  (3 corrections)
  Pillar 4 (skill activations):   980 tokens  (2 activations)
  RTK rewrites:                 1,228 tokens  (5 rewrites)

Next Steps

  • Skills – See all available skills and how to create your own.
  • Hook Pipeline – Understand what happens under the hood.
  • Savings – Detailed token savings analysis.

License

PRECC offers two tiers: Community (free) and Pro.

Community Tier (Free)

The Community tier includes:

  • All built-in skills (wrong-directory correction, jj translation, etc.)
  • Hook pipeline with full Pillar 1 and Pillar 4 support
  • Basic precc savings summary
  • Session mining with precc ingest
  • Unlimited local usage

Pro Tier

Pro unlocks additional features:

  • Detailed savings breakdownprecc savings --all with per-command analysis
  • GIF recordingprecc gif for creating animated terminal GIFs
  • IP geofence compliance – For regulated environments
  • Email reportsprecc mail report to send analytics
  • GitHub Actions analysisprecc gha for failed workflow debugging
  • Context compressionprecc compress for CLAUDE.md optimization
  • Priority support

Activating a License

$ precc license activate XXXX-XXXX-XXXX-XXXX --email you@example.com
[precc] License activated for you@example.com
[precc] Plan: Pro
[precc] Expires: 2027-04-03

Checking License Status

$ precc license status
License: Pro
Email:   you@example.com
Expires: 2027-04-03
Status:  Active

GitHub Sponsors Activation

If you sponsor PRECC through GitHub Sponsors, your license is activated automatically via your GitHub email. No key required – just ensure your sponsor email matches:

$ precc license status
License: Pro (GitHub Sponsors)
Email:   you@example.com
Status:  Active (auto-renewed)

Device Fingerprint

Each license is tied to a device fingerprint. View yours with:

$ precc license fingerprint
Fingerprint: a1b2c3d4e5f6...

If you need to transfer your license to a new machine, deactivate first:

precc license deactivate

Then activate on the new machine.

License Expired?

When a Pro license expires, PRECC reverts to Community tier. All built-in skills and core functionality continue to work. Only Pro-specific features become unavailable. See the FAQ for more details.

Hook Pipeline

The precc-hook binary is the core of PRECC. It sits between Claude Code and the shell, processing every bash command in under 5 milliseconds.

How Claude Code Invokes the Hook

Claude Code supports PreToolUse hooks – external programs that can inspect and modify tool inputs before execution. When Claude is about to run a bash command, it sends JSON to precc-hook on stdin and reads the response from stdout.

Pipeline Stages

Claude Code
    |
    v
+---------------------------+
| 1. Parse JSON stdin       |  Read the command from Claude Code
+---------------------------+
    |
    v
+---------------------------+
| 2. Skill matching         |  Query heuristics.db for matching skills (Pillar 4)
+---------------------------+
    |
    v
+---------------------------+
| 3. Directory correction   |  Resolve correct working directory (Pillar 1)
+---------------------------+
    |
    v
+---------------------------+
| 4. GDB check              |  Detect debug opportunities (Pillar 2)
+---------------------------+
    |
    v
+---------------------------+
| 5. RTK rewriting          |  Apply command rewrites for token savings
+---------------------------+
    |
    v
+---------------------------+
| 6. Emit JSON stdout       |  Return modified command to Claude Code
+---------------------------+
    |
    v
  Shell executes corrected command

Example: JSON Input and Output

Input (from Claude Code)

{
  "tool_input": {
    "command": "cargo build"
  }
}

PRECC detects that the current directory has no Cargo.toml, but ./myapp/Cargo.toml exists.

Output (to Claude Code)

{
  "hookSpecificOutput": {
    "updatedInput": {
      "command": "cd /home/user/projects/myapp && cargo build"
    }
  }
}

If no modification is needed, updatedInput.command is empty and Claude Code uses the original command.

Stage Details

Stage 1: Parse JSON

Reads the full JSON object from stdin. Extracts tool_input.command. If parsing fails, the hook exits immediately and Claude Code uses the original command (fail-open design).

Stage 2: Skill Matching

Queries the SQLite heuristics database for skills whose trigger pattern matches the command. Skills are checked in priority order. Both built-in TOML skills and mined skills are evaluated.

Stage 3: Directory Correction

For build commands (cargo, go, make, npm, python, etc.), checks whether the expected project file exists in the current directory. If not, scans nearby directories for the closest match and prepends cd <dir> &&.

The directory scan uses a cached filesystem index with a 5-second TTL to stay fast.

Stage 4: GDB Check

If the command is likely to produce a crash (e.g., running a debug binary), PRECC can suggest or inject GDB wrappers to capture structured debug output instead of raw crash logs.

Stage 5: RTK Rewriting

Applies RTK (Rewrite Toolkit) rules that shorten verbose commands, suppress noisy output, or restructure commands for token efficiency.

Stage 6: Emit JSON

Serializes the modified command back to JSON and writes it to stdout. If no changes were made, the output signals Claude Code to use the original command.

Performance

The entire pipeline completes in under 5 milliseconds (p99). Key optimizations:

  • SQLite in WAL mode for lock-free concurrent reads
  • Pre-compiled regex patterns for skill matching
  • Cached filesystem scans (5-second TTL)
  • No network calls in the hot path
  • Fail-open: any error falls through to the original command

Testing the Hook Manually

You can invoke the hook directly:

$ echo '{"tool_input":{"command":"cargo build"}}' | precc-hook
{"hookSpecificOutput":{"updatedInput":{"command":"cd /home/user/myapp && cargo build"}}}

Skills

Skills are the pattern-matching rules that PRECC uses to detect and correct commands. They can be built-in (shipped as TOML files) or mined from session logs.

Built-in Skills

SkillTriggers OnAction
cargo-wrong-dircargo build/test/clippy outside a Rust projectPrepend cd to the nearest Cargo.toml directory
git-wrong-dirgit * outside a git repoPrepend cd to the nearest .git directory
go-wrong-dirgo build/test outside a Go modulePrepend cd to the nearest go.mod directory
make-wrong-dirmake without a Makefile in cwdPrepend cd to the nearest Makefile directory
npm-wrong-dirnpm/npx/pnpm/yarn outside a Node projectPrepend cd to the nearest package.json directory
python-wrong-dirpython/pytest/pip outside a Python projectPrepend cd to the nearest Python project
jj-translategit * in a jj-colocated repoRewrite to equivalent jj command
asciinema-gifasciinema recRewrite to precc gif

Listing Skills

$ precc skills list
  # Name               Type      Triggers
  1 cargo-wrong-dir    built-in  cargo build/test/clippy outside Rust project
  2 git-wrong-dir      built-in  git * outside a repo
  3 go-wrong-dir       built-in  go build/test outside Go module
  4 make-wrong-dir     built-in  make without Makefile in cwd
  5 npm-wrong-dir      built-in  npm/npx/pnpm/yarn outside Node project
  6 python-wrong-dir   built-in  python/pytest/pip outside Python project
  7 jj-translate       built-in  git * in jj-colocated repo
  8 asciinema-gif      built-in  asciinema rec
  9 fix-pytest-path    mined     pytest with wrong test path

Showing Skill Details

$ precc skills show cargo-wrong-dir
Name:        cargo-wrong-dir
Type:        built-in
Source:      skills/builtin/cargo-wrong-dir.toml
Description: Detects cargo commands run outside a Rust project and prepends
             cd to the directory containing the nearest Cargo.toml.
Trigger:     ^cargo\s+(build|test|clippy|run|check|bench|doc)
Action:      prepend_cd
Marker:      Cargo.toml
Activations: 12

Exporting a Skill to TOML

$ precc skills export cargo-wrong-dir
[skill]
name = "cargo-wrong-dir"
description = "Prepend cd for cargo commands outside a Rust project"
trigger = "^cargo\\s+(build|test|clippy|run|check|bench|doc)"
action = "prepend_cd"
marker = "Cargo.toml"
priority = 10

Editing a Skill

$ precc skills edit cargo-wrong-dir

This opens the skill definition in your $EDITOR. After saving, the skill is reloaded automatically.

The Advise Command

precc skills advise analyzes your recent session and suggests new skills based on repeated patterns:

$ precc skills advise
Analyzed 47 commands from the last session.

Suggested skills:
  1. docker-wrong-dir: You ran `docker compose up` outside the project root 3 times.
     Suggested trigger: ^docker\s+compose
     Suggested marker: docker-compose.yml

  2. terraform-wrong-dir: You ran `terraform plan` outside the infra directory 2 times.
     Suggested trigger: ^terraform\s+(plan|apply|init)
     Suggested marker: main.tf

Accept suggestion [1/2/skip]?

Clustering Skills

$ precc skills cluster

Groups similar mined skills together to help identify redundant or overlapping patterns.

Mined vs. Built-in Skills

Built-in skills ship with PRECC and are defined in skills/builtin/*.toml. They cover the most common wrong-directory mistakes.

Mined skills are created by precc ingest or the precc-learner daemon from your session logs. They are stored in ~/.local/share/precc/heuristics.db and are specific to your workflow. See Mining for details.

Savings

PRECC tracks estimated token savings from every interception. Use precc savings to see how much waste PRECC has prevented.

Quick Summary

$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Breakdown:
  Pillar 1 (cd prepends):         <span data-stat="session_p1_tokens">3,204</span> tokens  (<span data-stat="session_p1_count">6</span> corrections)
  Pillar 4 (skill activations):   <span data-stat="session_p4_tokens">1,560</span> tokens  (<span data-stat="session_p4_count">4</span> activations)
  RTK rewrites:                   <span data-stat="session_rtk_tokens">2,749</span> tokens  (<span data-stat="session_rtk_count">11</span> rewrites)
  Lean-ctx wraps:                 <span data-stat="session_lean_tokens">1,228</span> tokens  (<span data-stat="session_lean_count">2</span> wraps)

Detailed Breakdown (Pro)

$ precc savings --all
Session Token Savings (Detailed)
================================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Command-by-command:
  #  Time   Command                          Saving   Source
  1  09:12  cargo build                      534 tk   cd prepend (cargo-wrong-dir)
  2  09:14  cargo test                       534 tk   cd prepend (cargo-wrong-dir)
  3  09:15  git status                       412 tk   cd prepend (git-wrong-dir)
  4  09:18  npm install                      824 tk   cd prepend (npm-wrong-dir)
  5  09:22  find . -name "*.rs"              387 tk   RTK rewrite (output truncation)
  6  09:25  cat src/main.rs                  249 tk   RTK rewrite (lean-ctx wrap)
  7  09:31  cargo clippy                     534 tk   cd prepend (cargo-wrong-dir)
  ...

Pillar Breakdown:
  Pillar 1 (context resolution):   <span data-stat="session_p1_tokens">3,204</span> tokens  <span data-stat="session_p1_pct">36.6</span>%
  Pillar 2 (GDB debugging):            0 tokens   0.0%
  Pillar 3 (mined preventions):        0 tokens   0.0%
  Pillar 4 (automation skills):    <span data-stat="session_p4_tokens">1,560</span> tokens  <span data-stat="session_p4_pct">17.8</span>%
  RTK rewrites:                    <span data-stat="session_rtk_tokens">2,749</span> tokens  <span data-stat="session_rtk_pct">31.5</span>%
  Lean-ctx wraps:                  <span data-stat="session_lean_tokens">1,228</span> tokens  <span data-stat="session_lean_pct">14.1</span>%

How Savings Are Estimated

Each correction type has an estimated token cost based on what would have happened without PRECC:

Correction TypeEstimated SavingReasoning
cd prepend~500 tokensError output + Claude reasoning + retry
Skill activation~400 tokensError output + Claude reasoning + retry
RTK rewrite~250 tokensVerbose output that Claude would have to read
Lean-ctx wrap~600 tokensLarge file contents compressed
Mined prevention~500 tokensKnown failure pattern avoided

These are conservative estimates. Actual savings are often higher because Claude’s reasoning about errors can be verbose.

Cumulative Savings

Savings persist across sessions in the PRECC database. Over time, you can track the total impact:

$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Lifetime savings: <span data-stat="total_tokens_saved">142,389</span> tokens across <span data-stat="total_sessions">47</span> sessions

Compress

precc compress shrinks CLAUDE.md and other context files to reduce token usage when Claude Code loads them. This is a Pro feature.

Basic Usage

$ precc compress .
[precc] Scanning directory: .
[precc] Found 3 context files:
         CLAUDE.md (2,847 tokens -> 1,203 tokens, -57.7%)
         ARCHITECTURE.md (4,112 tokens -> 2,044 tokens, -50.3%)
         ALTERNATIVES.md (3,891 tokens -> 1,967 tokens, -49.5%)
[precc] Total: 10,850 tokens -> 5,214 tokens (-51.9%)
[precc] Files compressed. Use --revert to restore originals.

Dry Run

Preview what would change without modifying files:

$ precc compress . --dry-run
[precc] Dry run -- no files will be modified.
[precc] CLAUDE.md: 2,847 tokens -> 1,203 tokens (-57.7%)
[precc] ARCHITECTURE.md: 4,112 tokens -> 2,044 tokens (-50.3%)
[precc] ALTERNATIVES.md: 3,891 tokens -> 1,967 tokens (-49.5%)
[precc] Total: 10,850 tokens -> 5,214 tokens (-51.9%)

Reverting

Originals are backed up automatically. To restore them:

$ precc compress --revert
[precc] Restored 3 files from backups.

What Gets Compressed

The compressor applies several transformations:

  • Removes redundant whitespace and blank lines
  • Shortens verbose phrasing while preserving meaning
  • Condenses tables and lists
  • Strips comments and decorative formatting
  • Preserves all code blocks, paths, and technical identifiers

The compressed output is still human-readable – it is not minified or obfuscated.

Targeting Specific Files

$ precc compress CLAUDE.md
[precc] CLAUDE.md: 2,847 tokens -> 1,203 tokens (-57.7%)

Reports

precc report generates an analytics dashboard summarizing PRECC activity and token savings.

Generating a Report

$ precc report
PRECC Report -- 2026-04-03
==========================

Sessions analyzed: 12
Commands intercepted: 87
Total token savings: 42,389

Top skills by activation:
  1. cargo-wrong-dir     34 activations   17,204 tokens saved
  2. npm-wrong-dir       18 activations    9,360 tokens saved
  3. git-wrong-dir       12 activations    4,944 tokens saved
  4. RTK rewrite         15 activations    3,750 tokens saved
  5. python-wrong-dir     8 activations    4,131 tokens saved

Savings by pillar:
  Pillar 1 (context resolution):  28,639 tokens  67.6%
  Pillar 4 (automation skills):    7,000 tokens  16.5%
  RTK rewrites:                    3,750 tokens   8.8%
  Lean-ctx wraps:                  3,000 tokens   7.1%

Recent corrections:
  2026-04-03 09:12  cargo build -> cd myapp && cargo build
  2026-04-03 09:18  npm test -> cd frontend && npm test
  2026-04-03 10:05  git status -> cd repo && git status
  ...

Emailing a Report

Send the report to an email address (requires mail setup, see Email):

$ precc report --email
[precc] Report sent to you@example.com

The recipient address is read from ~/.config/precc/mail.toml. You can also use precc mail report EMAIL to send to a specific address.

Report Data

Reports are generated from the local PRECC database at ~/.local/share/precc/history.db. No data leaves your machine unless you explicitly email the report.

Mining

PRECC mines Claude Code session logs to learn failure-fix patterns. When it sees the same mistake again, it applies the fix automatically.

Ingesting Session Logs

Ingest a Single File

$ precc ingest ~/.claude/logs/session-2026-04-03.jsonl
[precc] Parsing session-2026-04-03.jsonl...
[precc] Found 142 commands, 8 failure-fix pairs
[precc] Stored 8 patterns in history.db
[precc] 2 new skill candidates identified

Ingest All Logs

$ precc ingest --all
[precc] Scanning ~/.claude/logs/...
[precc] Found 23 session files (14 new, 9 already ingested)
[precc] Parsing 14 new files...
[precc] Found 47 failure-fix pairs across 14 sessions
[precc] Stored 47 patterns in history.db
[precc] 5 new skill candidates identified

Force Re-ingest

To re-process files that were already ingested:

$ precc ingest --all --force
[precc] Re-ingesting all 23 session files...

How Mining Works

  1. PRECC reads the session JSONL log file.
  2. It identifies command pairs where the first command failed and the second was a corrected retry.
  3. It extracts the pattern (what went wrong) and the fix (what Claude did differently).
  4. Patterns are stored in ~/.local/share/precc/history.db.
  5. When a pattern reaches a confidence threshold (seen multiple times), it becomes a mined skill in heuristics.db.

Example Pattern

Failure: pytest tests/test_auth.py
Error:   ModuleNotFoundError: No module named 'myapp'
Fix:     cd /home/user/myapp && pytest tests/test_auth.py
Pattern: pytest outside project root -> prepend cd

The precc-learner Daemon

The precc-learner daemon runs in the background and watches for new session logs automatically:

$ precc-learner &
[precc-learner] Watching ~/.claude/logs/ for new sessions...
[precc-learner] Processing session-2026-04-03-1412.jsonl... 3 new patterns

The daemon uses file system notifications (inotify on Linux, FSEvents on macOS) so it reacts immediately when a session ends.

From Patterns to Skills

Mined patterns graduate to skills when they meet these criteria:

  • Seen at least 3 times across sessions
  • Consistent fix pattern (same type of correction each time)
  • No false positives detected

You can review skill candidates with:

$ precc skills advise

See Skills for details on managing skills.

Data Storage

  • Failure-fix pairs: ~/.local/share/precc/history.db
  • Graduated skills: ~/.local/share/precc/heuristics.db

Both are SQLite databases in WAL mode for safe concurrent access.

Email

PRECC can send reports and files via email. This requires a one-time SMTP setup.

Setup

$ precc mail setup
SMTP host: smtp.gmail.com
SMTP port [587]: 587
Username: you@gmail.com
Password: ********
From address [you@gmail.com]: you@gmail.com
[precc] Mail configuration saved to ~/.config/precc/mail.toml
[precc] Sending test email to you@gmail.com...
[precc] Test email sent successfully.

Configuration File

The configuration is stored at ~/.config/precc/mail.toml:

[smtp]
host = "smtp.gmail.com"
port = 587
username = "you@gmail.com"
password = "app-password-here"
from = "you@gmail.com"
tls = true

You can edit this file directly:

$EDITOR ~/.config/precc/mail.toml

For Gmail, use an App Password rather than your account password.

Sending Reports

$ precc mail report team@example.com
[precc] Generating report...
[precc] Sending to team@example.com...
[precc] Report sent.

Sending Files

$ precc mail send colleague@example.com output.log
[precc] Sending output.log to colleague@example.com...
[precc] Sent (14.2 KB).

SSH Relay Support

If your machine cannot reach an SMTP server directly (e.g., behind a corporate firewall), PRECC supports relaying through an SSH tunnel:

[smtp]
host = "localhost"
port = 2525

[ssh_relay]
host = "relay.example.com"
user = "you"
remote_port = 587
local_port = 2525

PRECC will establish the SSH tunnel automatically before sending.

GIF Recording

precc gif creates animated GIF recordings of terminal sessions from bash scripts. This is a Pro feature.

Basic Usage

$ precc gif script.sh 30s
[precc] Recording script.sh (max 30s)...
[precc] Running: echo "Hello, world!"
[precc] Running: cargo build --release
[precc] Running: cargo test
[precc] Recording complete.
[precc] Output: script.gif (1.2 MB, 24s)

The first argument is a bash script containing the commands to run. The second argument is the maximum recording length.

Script Format

The script is a standard bash file:

#!/bin/bash
echo "Building project..."
cargo build --release
echo "Running tests..."
cargo test
echo "Done!"

Input Simulation

For interactive commands, provide input values as additional arguments:

$ precc gif interactive-demo.sh 60s "yes" "my-project" "3"

Each additional argument is fed as a line of stdin when the script prompts for input.

Output Options

The output file is named after the script by default (script.gif). The GIF uses a dark terminal theme with standard 80x24 dimensions.

Why GIF Instead of asciinema?

The asciinema-gif built-in skill automatically rewrites asciinema rec to precc gif. GIF files are more portable – they display inline in GitHub READMEs, Slack, and email without requiring a player.

GitHub Actions Analysis

precc gha analyzes failed GitHub Actions runs and suggests fixes. This is a Pro feature.

Usage

Pass the URL of a failed GitHub Actions run:

$ precc gha https://github.com/myorg/myrepo/actions/runs/12345678
[precc] Fetching run 12345678...
[precc] Run: CI / build (ubuntu-latest)
[precc] Status: failure
[precc] Failed step: Run cargo test

[precc] Log analysis:
  Error: test result: FAILED. 2 passed; 1 failed
  Failed test: tests::integration::test_database_connection
  Cause: thread 'tests::integration::test_database_connection' panicked at
         'called Result::unwrap() on an Err value: Connection refused'

[precc] Suggested fix:
  The test requires a database connection but the CI environment does not
  start a database service. Add a services block to your workflow:

    services:
      postgres:
        image: postgres:15
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: test

What It Does

  1. Parses the GitHub Actions run URL to extract the owner, repo, and run ID.
  2. Fetches the run logs via the GitHub API (uses GITHUB_TOKEN if set, otherwise public access).
  3. Identifies the failed step and extracts the relevant error lines.
  4. Analyzes the error and suggests a fix based on common CI failure patterns.

Supported Failure Patterns

  • Missing service containers (databases, Redis, etc.)
  • Incorrect runner OS or architecture
  • Missing environment variables or secrets
  • Dependency installation failures
  • Test timeouts
  • Permission errors
  • Cache misses causing slow builds

Geofence

PRECC includes IP geofence compliance checking for regulated environments. This is a Pro feature.

Overview

Some organizations require that development tools only operate within approved geographic regions. PRECC’s geofence feature verifies that the current machine’s IP address falls within an allowed region list.

Checking Compliance

$ precc geofence check
[precc] Current IP: 203.0.113.42
[precc] Region: US-East (Virginia)
[precc] Status: COMPLIANT
[precc] Policy: us-east-1, us-west-2, eu-west-1

If the machine is outside the allowed regions:

$ precc geofence check
[precc] Current IP: 198.51.100.7
[precc] Region: AP-Southeast (Singapore)
[precc] Status: NON-COMPLIANT
[precc] Policy: us-east-1, us-west-2, eu-west-1
[precc] Warning: Current region is not in the allowed list.

Refreshing Geofence Data

$ precc geofence refresh
[precc] Fetching updated IP geolocation data...
[precc] Updated. Cache expires in 24h.

Viewing Geofence Info

$ precc geofence info
Geofence Configuration
======================
Policy file:    ~/.config/precc/geofence.toml
Allowed regions: us-east-1, us-west-2, eu-west-1
Cache age:      2h 14m
Last check:     2026-04-03 09:12:00 UTC
Status:         COMPLIANT

Clearing Cache

$ precc geofence clear
[precc] Geofence cache cleared.

Configuration

The geofence policy is defined in ~/.config/precc/geofence.toml:

[geofence]
allowed_regions = ["us-east-1", "us-west-2", "eu-west-1"]
check_on_init = true
block_on_violation = false

Set block_on_violation = true to prevent PRECC from operating when outside allowed regions.

Telemetry

PRECC supports opt-in anonymous telemetry to help improve the tool. No data is collected unless you explicitly consent.

Opting In

$ precc telemetry consent
[precc] Telemetry enabled. Thank you for helping improve PRECC.
[precc] You can revoke consent at any time with: precc telemetry revoke

Opting Out

$ precc telemetry revoke
[precc] Telemetry disabled. No further data will be sent.

Checking Status

$ precc telemetry status
Telemetry: disabled
Last sent: never

Previewing What Would Be Sent

Before opting in, you can see exactly what data would be collected:

$ precc telemetry preview
Telemetry payload (this session):
{
  "version": "0.3.0",
  "os": "linux",
  "arch": "x86_64",
  "skills_activated": 12,
  "commands_intercepted": 87,
  "pillars_used": [1, 4],
  "avg_hook_latency_ms": 2.3,
  "session_count": 1
}

What Is Collected

  • PRECC version, OS, and architecture
  • Aggregate counts: commands intercepted, skills activated, pillars used
  • Average hook latency
  • Session count

What Is NOT Collected

  • No command text or arguments
  • No file paths or directory names
  • No project names or repository URLs
  • No personally identifiable information (PII)
  • No IP addresses (the server does not log them)

Environment Variable Override

To disable telemetry without running a command (useful in CI or shared environments):

export PRECC_NO_TELEMETRY=1

This takes precedence over the consent setting.

Data Destination

Telemetry data is sent to https://telemetry.peria.ai/v1/precc over HTTPS. The data is used solely to understand usage patterns and prioritize development.

Command Reference

Complete reference for all PRECC commands.


precc init

Initialize PRECC and register the hook with Claude Code.

precc init

Options:
  (none)

Effects:
  - Registers PreToolUse:Bash hook with Claude Code
  - Creates ~/.local/share/precc/ data directory
  - Initializes heuristics.db with built-in skills
  - Prompts for telemetry consent

precc ingest

Mine session logs for failure-fix patterns.

precc ingest [FILE] [--all] [--force]

Arguments:
  FILE            Path to a session log file (.jsonl)

Options:
  --all           Ingest all session logs from ~/.claude/logs/
  --force         Re-process files that were already ingested

Examples:
  precc ingest session.jsonl
  precc ingest --all
  precc ingest --all --force

precc skills

Manage automation skills.

precc skills list

precc skills list

List all active skills (built-in and mined).

precc skills show

precc skills show NAME

Show detailed information about a specific skill.

Arguments:
  NAME            Skill name (e.g., cargo-wrong-dir)

precc skills export

precc skills export NAME

Export a skill definition as TOML.

Arguments:
  NAME            Skill name

precc skills edit

precc skills edit NAME

Open a skill definition in $EDITOR.

Arguments:
  NAME            Skill name

precc skills advise

precc skills advise

Analyze recent sessions and suggest new skills based on repeated patterns.

precc skills cluster

precc skills cluster

Group similar mined skills to identify redundant or overlapping patterns.

precc report

Generate an analytics report.

precc report [--email]

Options:
  --email         Send the report via email (requires mail setup)

precc savings

Show token savings.

precc savings [--all]

Options:
  --all           Show detailed per-command breakdown (Pro)

precc compress

Compress context files to reduce token usage.

precc compress [DIR] [--dry-run] [--revert]

Arguments:
  DIR             Directory or file to compress (default: current directory)

Options:
  --dry-run       Preview changes without modifying files
  --revert        Restore files from backup

precc license

Manage your PRECC license.

precc license activate

precc license activate KEY --email EMAIL

Arguments:
  KEY             License key (XXXX-XXXX-XXXX-XXXX)

Options:
  --email EMAIL   Email address associated with the license

precc license status

precc license status

Display current license status, plan, and expiration.

precc license deactivate

precc license deactivate

Deactivate the license on this machine.

precc license fingerprint

precc license fingerprint

Display the device fingerprint for this machine.

precc mail

Email functionality.

precc mail setup

precc mail setup

Interactive SMTP configuration. Saves to ~/.config/precc/mail.toml.

precc mail report

precc mail report EMAIL

Send a PRECC analytics report to the specified email address.

Arguments:
  EMAIL           Recipient email address

precc mail send

precc mail send EMAIL FILE

Send a file as an email attachment.

Arguments:
  EMAIL           Recipient email address
  FILE            Path to the file to send

precc update

Update PRECC to the latest version.

precc update [--force] [--version VERSION] [--auto]

Options:
  --force             Force update even if already on latest
  --version VERSION   Update to a specific version
  --auto              Enable automatic updates

precc telemetry

Manage anonymous telemetry.

precc telemetry consent

Opt in to anonymous telemetry.

precc telemetry revoke

precc telemetry revoke

Opt out of telemetry. No further data will be sent.

precc telemetry status

precc telemetry status

Show current telemetry consent status.

precc telemetry preview

precc telemetry preview

Display the telemetry payload that would be sent (without sending it).

precc geofence

IP geofence compliance (Pro).

precc geofence check

precc geofence check

Check if the current machine is in an allowed region.

precc geofence refresh

precc geofence refresh

Refresh the IP geolocation cache.

precc geofence clear

precc geofence clear

Clear the geofence cache.

precc geofence info

precc geofence info

Display geofence configuration and current status.

precc gif

Record animated GIFs from bash scripts (Pro).

precc gif SCRIPT LENGTH [INPUTS...]

Arguments:
  SCRIPT          Path to a bash script
  LENGTH          Maximum recording duration (e.g., 30s, 2m)
  INPUTS...       Optional input lines for interactive prompts

Examples:
  precc gif demo.sh 30s
  precc gif interactive.sh 60s "yes" "my-project"

precc gha

Analyze failed GitHub Actions runs (Pro).

precc gha URL

Arguments:
  URL             GitHub Actions run URL

Example:
  precc gha https://github.com/org/repo/actions/runs/12345678

precc cache-hint

Display cache hint information for the current project.

precc cache-hint

precc trial

Start a Pro trial.

precc trial EMAIL

Arguments:
  EMAIL           Email address for the trial

precc nushell

Launch a Nushell session with PRECC integration.

precc nushell

FAQ

Is PRECC safe to use?

Yes. PRECC uses the official Claude Code PreToolUse hook mechanism – the same extension point that Anthropic designed for exactly this purpose. The hook:

  • Runs entirely offline (no network calls in the hot path)
  • Completes in under 5 milliseconds
  • Is fail-open: if anything goes wrong, the original command runs unmodified
  • Only modifies commands, never executes them itself
  • Stores data locally in SQLite databases

Does PRECC work with other AI coding tools?

PRECC is designed specifically for Claude Code. It relies on the PreToolUse hook protocol that Claude Code provides. It does not work with Cursor, Copilot, Windsurf, or other AI coding tools.

What data does telemetry send?

Telemetry is opt-in only. When enabled, it sends:

  • PRECC version, OS, and architecture
  • Aggregate counts (commands intercepted, skills activated)
  • Average hook latency

It does not send command text, file paths, project names, or any personally identifiable information. You can preview the exact payload with precc telemetry preview before opting in. See Telemetry for full details.

How do I uninstall PRECC?

??faq_uninstall_a_intro??

  1. Remove the hook registration:

    # Delete the hook entry from Claude Code's settings
    # (precc init added it; removing it disables PRECC)
    
  2. Remove the binary:

    rm ~/.local/bin/precc ~/.local/bin/precc-hook ~/.local/bin/precc-learner
    
  3. Remove data (optional):

    rm -rf ~/.local/share/precc/
    rm -rf ~/.config/precc/
    

My license expired. What happens?

PRECC reverts to the Community tier. All core functionality continues to work:

  • Built-in skills remain active
  • Hook pipeline runs normally
  • precc savings shows the summary view
  • precc ingest and session mining work

Pro features become unavailable until you renew:

  • precc savings --all (detailed breakdown)
  • precc compress
  • precc gif
  • precc gha
  • precc geofence
  • Email reports

The hook does not seem to be running. How do I debug?

??faq_debug_a_intro??

  1. Check that the hook is registered:

    precc init
    
  2. Test the hook manually:

    echo '{"tool_input":{"command":"cargo build"}}' | precc-hook
    
  3. Check that the binary is on your PATH:

    which precc-hook
    
  4. Check Claude Code’s hook configuration in ~/.claude/settings.json.

Does PRECC slow down Claude Code?

No. The hook completes in under 5 milliseconds (p99). This is imperceptible compared to the time Claude spends reasoning and generating responses.

Can I use PRECC in CI/CD?

PRECC is designed for interactive Claude Code sessions. In CI/CD, there is no Claude Code instance to hook into. However, precc gha can analyze failed GitHub Actions runs from any environment.

How do mined skills differ from built-in skills?

Built-in skills ship with PRECC and cover common wrong-directory patterns. Mined skills are learned from your specific session logs – they capture patterns unique to your workflow. Both are stored in SQLite and evaluated identically by the hook pipeline.

Can I share skills with my team?

Yes. Export any skill to TOML with precc skills export NAME and share the file. Team members can place it in their skills/ directory or import it into their heuristics database.

Alte limbi