Giới thiệu
PRECC là gì?
PRECC (Sửa lỗi dự đoán cho Claude Code) là một công cụ Rust chặn các lệnh bash của Claude Code thông qua cơ chế PreToolUse hook chính thức. Nó sửa lỗi trước khi chúng xảy ra, tiết kiệm token và loại bỏ các vòng lặp thử lại.
Miễn phí cho người dùng cộng đồng.
Vấn đề
Claude Code lãng phí đáng kể token vào những lỗi có thể phòng tránh:
- Lỗi sai thư mục – Chạy
cargo buildtrong thư mục cha không cóCargo.toml, sau đó thử lại sau khi đọc lỗi. - Vòng lặp thử lại – Một lệnh thất bại tạo ra đầu ra dài dòng, Claude đọc nó, suy luận và thử lại. Mỗi chu kỳ đốt hàng trăm token.
- Đầu ra dài dòng – Các lệnh như
findhoặcls -Rxuất ra hàng nghìn dòng mà Claude phải xử lý.
Bốn trụ cột
Sửa ngữ cảnh (cd-prepend)
Phát hiện khi các lệnh như cargo build hoặc npm test chạy trong thư mục sai và thêm cd /đường/dẫn/đúng && trước khi thực thi.
Gỡ lỗi GDB
Phát hiện cơ hội đính kèm GDB để gỡ lỗi sâu hơn các segfault và crash, cung cấp thông tin gỡ lỗi có cấu trúc thay vì core dump thô.
Khai thác phiên
Khai thác nhật ký phiên Claude Code để tìm các cặp lỗi-sửa. Khi cùng lỗi xảy ra lần nữa, PRECC đã biết cách sửa và áp dụng tự động.
Kỹ năng tự động hóa
Một thư viện các kỹ năng tích hợp và đã khai thác khớp với các mẫu lệnh và viết lại chúng. Kỹ năng được định nghĩa dưới dạng tệp TOML hoặc hàng SQLite, giúp dễ kiểm tra, chỉnh sửa và chia sẻ.
Cách hoạt động (phiên bản 30 giây)
- Claude Code sắp chạy một lệnh bash.
- PreToolUse hook gửi lệnh tới
precc-hookdưới dạng JSON qua stdin. precc-hookchạy lệnh qua pipeline (kỹ năng, sửa thư mục, nén) trong vòng dưới 3 mili giây.- Lệnh đã sửa được trả về dưới dạng JSON qua stdout.
- Claude Code thực thi lệnh đã sửa thay vì lệnh gốc.
Các lỗi vặt được gộp lại; lý do viết lại được kèm trong phản hồi của hook, nên mỗi chỉnh sửa đều có thể kiểm tra được — không âm thầm.
Ranh giới an toàn
PRECC chỉ viết lại khi tương đương ngữ nghĩa được bảo toàn có thể chứng minh hoặc người dùng có thể xác minh. Các lệnh phá hủy (rm, git push --force, git reset --hard) không bao giờ bị viết lại, ngay cả khi một kỹ năng khớp. Mọi biến đổi phải có giới hạn — lệnh viết lại phải chứa các token cốt lõi của lệnh gốc. Các viết lại không giới hạn tự động được hoàn tác. Mỗi viết lại được áp dụng đều được ghi nhật ký và hiển thị để bạn có thể kiểm tra, vô hiệu hóa hoặc hoàn tác.
Nén thích ứng
Nếu một lệnh thất bại sau khi nén, PRECC tự động bỏ qua nén ở lần thử tiếp theo để Claude nhận được đầu ra đầy đủ không nén để gỡ lỗi.
Thống kê sử dụng trực tiếp
Phiên bản hiện tại –:
| Chỉ số | Giá trị |
|---|---|
| Token tiết kiệm được | – |
| Tỷ lệ tiết kiệm | –% |
| Độ trễ hook | – ms (p50) |
| Người dùng | – |
| crates.io downloads | – |
crates.io downloads count CI, docs.rs and mirror traffic — they are not a measure of unique users.
Tiết kiệm theo phiên bản
Những con số này tự động cập nhật từ dữ liệu đo từ xa ẩn danh.
Liên kết
- GitHub: https://github.com/peri-a-i/precc-cc
- Trang web: https://peria.ai
- Tài liệu: https://precc.cc
Cài đặt
Cài đặt nhanh (Linux / macOS)
curl -fsSL https://peria.ai/install.sh | bash
Lệnh này tải xuống bản phát hành mới nhất cho nền tảng của bạn, xác minh mã SHA256 và đặt vào ~/.local/bin/.
Sau khi cài đặt, khởi tạo PRECC:
precc init
precc init đăng ký hook PreToolUse với Claude Code, tạo các thư mục dữ liệu và khởi tạo cơ sở dữ liệu kỹ năng.
Tùy chọn cài đặt
Xác minh SHA256
Mặc định, trình cài đặt xác minh mã checksum của tệp nhị phân với SHA256 đã công bố. Để bỏ qua xác minh (không khuyến nghị):
curl -fsSL https://peria.ai/install.sh | bash -s -- --no-verify
Tiền tố cài đặt tùy chỉnh
Cài đặt vào vị trí tùy chỉnh:
curl -fsSL https://peria.ai/install.sh | bash -s -- --prefix /opt/precc
OpenCLI (–opencli) — WebFetch token savings
PRECC can also install OpenCLI, a third-party Node.js tool that turns ~148 websites (HackerNews, Reddit, arxiv, bilibili, zhihu, x.com, …) into structured-output commands. When installed, PRECC’s two built-in webfetch-opencli-* skills auto-rewrite raw curl/wget calls into the corresponding opencli <site> command for 5–50× smaller output.
precc init --opencli
This runs npm install -g @jackwener/opencli (requires Node.js 20+) and prints the URL for OpenCLI’s optional Chrome extension. The extension is only needed to reuse logged-in cookies on private pages; public sources work without it.
Skipping --opencli keeps PRECC fully self-contained — the auto-rewrite skill inlines a command -v opencli check that falls back to the original command when OpenCLI isn’t installed, so the skill is safe to ship default-on.
The Chrome extension requests broad permissions (debugger, <all_urls>, cookies). Operators should review them before installing it; --opencli only handles the npm package, not the extension.
Công cụ đi kèm (–extras)
PRECC đi kèm với các công cụ tùy chọn. Cài đặt chúng với --extras:
curl -fsSL https://peria.ai/install.sh | bash -s -- --extras
Lệnh này cài đặt:
| Công cụ | Mục đích |
|---|---|
| RTK | Bộ công cụ viết lại lệnh |
| lean-ctx | Nén ngữ cảnh cho CLAUDE.md và các tệp prompt |
| nushell | Shell có cấu trúc cho pipeline nâng cao |
| cocoindex-code | Lập chỉ mục mã để giải quyết ngữ cảnh nhanh hơn |
Windows (PowerShell)
irm https://peria.ai/install.ps1 | iex
Sau đó khởi tạo:
precc init
Cài đặt thủ công
- Tải xuống tệp nhị phân cho nền tảng của bạn từ GitHub Releases.
- Xác minh mã SHA256 với tệp
.sha256trong bản phát hành. - Đặt tệp nhị phân vào thư mục trong
PATHcủa bạn (ví dụ:~/.local/bin/). - Chạy
precc init.
Cập nhật
precc update
Buộc cập nhật lên phiên bản cụ thể:
precc update --force --version 0.3.0
Bật cập nhật tự động:
precc update --auto
Cài đặt trên OpenClaw / ClawHub
PRECC đi kèm một manifest plugin tại plugins/openclaw/openclaw.plugin.json (id precc-token-saver). Khi một bản phát hành công khai được công bố, quy trình GitHub Actions clawhub-publish.yml sẽ đẩy gói skill lên registry của ClawHub, để người dùng cuối có thể cài đặt PRECC qua CLI của ClawHub thay vì qua trình cài đặt curl:
# ClawHub CLI
clawhub install precc
# Or pin the plugin manifest (id: precc-token-saver) via OpenClaw's
# plugin marketplace UI or its CLI equivalent.
Cách hiển thị mức tiết kiệm trên OpenClaw
Mọi giao diện báo cáo của PRECC hoạt động trên Claude Code đều hoạt động trên OpenClaw — precc savings, precc savings --all, dòng trạng thái được bản địa hóa (đặt PRECC_LANG=zh và dòng này hiển thị theo ngôn ngữ của bạn), và nhật ký kiểm tra ghi đè cục bộ đều đọc từ cùng các cơ sở dữ liệu SQLCipher trên máy của bạn. Một đặc tả riêng tại docs/symposium-plan/openclaw-savings-reporting.md mô tả một trường có cấu trúc preccSavings trong tương lai trong mỗi phản hồi hook cộng với một thông báo kết thúc phiên một dòng tại ngưỡng mặc định $0.05; phần đó vẫn chưa được phát hành.
Xác minh cài đặt
$ precc --version
precc 0.3.0
$ precc savings
Session savings: 0 tokens (no commands intercepted yet)
Nếu không tìm thấy precc, hãy đảm bảo ~/.local/bin nằm trong PATH của bạn.
Bắt đầu nhanh
Khởi chạy PRECC trong 5 phút.
Bước 1: Cài đặt
curl -fsSL https://peria.ai/install.sh | bash
Bước 2: Khởi tạo
$ precc init
[precc] Hook registered with Claude Code
[precc] Created ~/.local/share/precc/
[precc] Initialized heuristics.db with 8 built-in skills
[precc] Ready.
Bước 3: Xác minh hook đang hoạt động
$ 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
Bước 4: Sử dụng Claude Code bình thường
Mở Claude Code và làm việc bình thường. PRECC chạy ngầm trong nền. Khi Claude phát ra lệnh sẽ thất bại, PRECC sửa nó trước khi thực thi.
Ví dụ: Cargo Build sai thư mục
Giả sử dự án của bạn ở ~/projects/myapp/ và Claude ra lệnh:
cargo build
từ ~/projects/ (cao hơn một cấp, không có Cargo.toml ở đó).
Không có PRECC: Claude nhận lỗi could not find Cargo.toml in /home/user/projects or any parent directory, đọc, suy luận, rồi thử lại với cd myapp && cargo build. Chi phí: ~2.000 token lãng phí.
Với PRECC: Hook phát hiện thiếu Cargo.toml, tìm thấy trong myapp/ và viết lại lệnh thành:
cd /home/user/projects/myapp && cargo build
Claude không bao giờ thấy lỗi. Không lãng phí token nào.
Bước 5: Kiểm tra tiết kiệm của bạn
Sau một phiên làm việc, xem PRECC đã tiết kiệm bao nhiêu token:
$ 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)
Bước tiếp theo
- Kỹ năng – Xem tất cả kỹ năng có sẵn và cách tạo kỹ năng riêng.
- Pipeline Hook – Hiểu những gì xảy ra bên trong.
- Tiết kiệm – Phân tích chi tiết tiết kiệm token.
Giấy phép
PRECC cung cấp hai cấp: Community (miễn phí) và Pro.
Cấp Community (miễn phí)
Cấp Community bao gồm:
- Tất cả kỹ năng tích hợp (sửa thư mục sai, dịch jj, v.v.)
- Pipeline hook với hỗ trợ đầy đủ Pillar 1 và Pillar 4
- Tóm tắt cơ bản
precc savings - Khai thác phiên với
precc ingest - Sử dụng cục bộ không giới hạn
Cấp Pro
Pro mở khóa các tính năng bổ sung:
- Phân tích chi tiết tiết kiệm –
precc savings --allvới phân tích theo lệnh - Ghi GIF –
precc gifđể tạo GIF động terminal - Tuân thủ geofence IP – Cho môi trường được quản lý
- Báo cáo email –
precc mail reportđể gửi phân tích - Phân tích GitHub Actions –
precc ghađể gỡ lỗi workflow thất bại - Nén ngữ cảnh –
precc compressđể tối ưu hóa CLAUDE.md - Hỗ trợ ưu tiên
Kích hoạt giấy phép
$ 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
Kiểm tra trạng thái giấy phép
$ precc license status
License: Pro
Email: you@example.com
Expires: 2027-04-03
Status: Active
Kích hoạt GitHub Sponsors
Nếu bạn tài trợ PRECC qua GitHub Sponsors, giấy phép được kích hoạt tự động qua email GitHub của bạn. Không cần khóa – chỉ cần đảm bảo email tài trợ khớp:
$ precc license status
License: Pro (GitHub Sponsors)
Email: you@example.com
Status: Active (auto-renewed)
Dấu vân tay thiết bị
Mỗi giấy phép được gắn với dấu vân tay thiết bị. Xem của bạn với:
$ precc license fingerprint
Fingerprint: a1b2c3d4e5f6...
Nếu bạn cần chuyển giấy phép sang máy mới, hãy hủy kích hoạt trước:
precc license deactivate
Sau đó kích hoạt trên máy mới.
Giấy phép hết hạn?
Khi giấy phép Pro hết hạn, PRECC quay lại cấp Community. Tất cả kỹ năng tích hợp và chức năng cốt lõi tiếp tục hoạt động. Chỉ các tính năng dành riêng cho Pro trở nên không khả dụng. Xem FAQ để biết thêm chi tiết.
Đường ống Hook
Binary precc-hook là cốt lõi của PRECC. Nó nằm giữa Claude Code và shell, xử lý mọi lệnh bash trong vòng dưới 5 mili giây.
Cách Claude Code gọi Hook
Claude Code hỗ trợ các hook PreToolUse – chương trình bên ngoài có thể kiểm tra và sửa đổi đầu vào công cụ trước khi thực thi. Khi Claude sắp chạy lệnh bash, nó gửi JSON đến precc-hook qua stdin và đọc phản hồi từ stdout.
Các giai đoạn Pipeline
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
Ví dụ: Đầu vào và đầu ra JSON
Đầu vào (từ Claude Code)
{
"tool_input": {
"command": "cargo build"
}
}
PRECC phát hiện thư mục hiện tại không có Cargo.toml, nhưng ./myapp/Cargo.toml tồn tại.
Đầu ra (đến Claude Code)
{
"hookSpecificOutput": {
"updatedInput": {
"command": "cd /home/user/projects/myapp && cargo build"
}
}
}
Nếu không cần sửa đổi, updatedInput.command sẽ trống và Claude Code sử dụng lệnh gốc.
Chi tiết các giai đoạn
Giai đoạn 1: Phân tích JSON
Đọc toàn bộ đối tượng JSON từ stdin. Trích xuất tool_input.command. Nếu phân tích thất bại, hook thoát ngay lập tức và Claude Code sử dụng lệnh gốc (thiết kế fail-open).
Giai đoạn 2: Khớp kỹ năng
Truy vấn cơ sở dữ liệu heuristic SQLite để tìm các kỹ năng có mẫu kích hoạt khớp với lệnh. Các kỹ năng được kiểm tra theo thứ tự ưu tiên. Cả kỹ năng TOML tích hợp và kỹ năng đã khai thác đều được đánh giá.
Giai đoạn 3: Sửa thư mục
Đối với các lệnh build (cargo, go, make, npm, python, v.v.), kiểm tra xem tệp dự án mong đợi có tồn tại trong thư mục hiện tại không. Nếu không, quét các thư mục lân cận để tìm kết quả khớp gần nhất và thêm cd <dir> && vào đầu.
Quá trình quét thư mục sử dụng chỉ mục hệ thống tệp được lưu trong bộ nhớ đệm với TTL 5 giây để duy trì tốc độ.
Giai đoạn 4: Kiểm tra GDB
Nếu lệnh có khả năng gây ra sự cố (ví dụ: chạy binary debug), PRECC có thể đề xuất hoặc chèn các wrapper GDB để thu thập đầu ra debug có cấu trúc thay vì log crash thô.
Giai đoạn 5: Viết lại RTK
Áp dụng các quy tắc RTK (Rewrite Toolkit) để rút ngắn lệnh dài dòng, loại bỏ đầu ra nhiễu hoặc tái cấu trúc lệnh để tiết kiệm token.
Giai đoạn 6: Phát JSON
Tuần tự hóa lệnh đã sửa đổi thành JSON và ghi ra stdout. Nếu không có thay đổi, đầu ra báo hiệu cho Claude Code sử dụng lệnh gốc.
Hiệu suất
Toàn bộ pipeline hoàn thành trong dưới 5 mili giây (p99). Các tối ưu hóa chính:
- SQLite ở chế độ WAL cho đọc đồng thời không khóa
- Các mẫu regex biên dịch trước để khớp kỹ năng
- Quét hệ thống tệp được lưu trong bộ nhớ đệm (TTL 5 giây)
- Không có cuộc gọi mạng trong đường dẫn nóng
- Fail-open: mọi lỗi đều chuyển về lệnh gốc
Kiểm tra Hook thủ công
Bạn có thể gọi hook trực tiếp:
$ echo '{"tool_input":{"command":"cargo build"}}' | precc-hook
{"hookSpecificOutput":{"updatedInput":{"command":"cd /home/user/myapp && cargo build"}}}
Kỹ năng
Kỹ năng là các quy tắc khớp mẫu mà PRECC sử dụng để phát hiện và sửa lệnh. Chúng có thể là tích hợp sẵn (phân phối dưới dạng tệp TOML) hoặc khai thác từ nhật ký phiên.
Kỹ năng tích hợp
| Kỹ năng | Kích hoạt khi | Hành động |
|---|---|---|
cargo-wrong-dir | cargo build/test/clippy ngoài dự án Rust | Thêm cd đến thư mục Cargo.toml gần nhất |
git-wrong-dir | git * ngoài kho git | Thêm cd đến thư mục .git gần nhất |
go-wrong-dir | go build/test ngoài module Go | Thêm cd đến thư mục go.mod gần nhất |
make-wrong-dir | make khi không có Makefile trong thư mục hiện tại | Thêm cd đến thư mục Makefile gần nhất |
npm-wrong-dir | npm/npx/pnpm/yarn ngoài dự án Node | Thêm cd đến thư mục package.json gần nhất |
python-wrong-dir | python/pytest/pip ngoài dự án Python | Thêm cd đến dự án Python gần nhất |
jj-translate | git * trong kho jj đồng vị trí | Viết lại thành lệnh jj tương đương |
asciinema-gif | asciinema rec | Viết lại thành precc gif |
Liệt kê kỹ năng
$ 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
Hiển thị chi tiết kỹ năng
$ 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
Xuất kỹ năng sang 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
Chỉnh sửa kỹ năng
$ precc skills edit cargo-wrong-dir
Thao tác này mở định nghĩa kỹ năng trong $EDITOR của bạn. Sau khi lưu, kỹ năng được tải lại tự động.
Lệnh Advise
precc skills advise phân tích phiên gần đây của bạn và đề xuất kỹ năng mới dựa trên các mẫu lặp lại:
$ 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]?
Gom nhóm kỹ năng
$ precc skills cluster
Nhóm các kỹ năng khai thác tương tự lại với nhau để giúp xác định các mẫu trùng lặp hoặc chồng chéo.
Kỹ năng khai thác và kỹ năng tích hợp
Kỹ năng tích hợp được phân phối cùng PRECC và được định nghĩa trong skills/builtin/*.toml. Chúng bao gồm các lỗi thư mục sai phổ biến nhất.
Kỹ năng khai thác được tạo bởi precc ingest hoặc daemon precc-learner từ nhật ký phiên của bạn. Chúng được lưu trong ~/.local/share/precc/heuristics.db và đặc thù cho quy trình làm việc của bạn. Xem Khai thác để biết chi tiết.
Tiết kiệm
PRECC theo dõi token tiết kiệm ước tính từ mỗi lần chặn. Dùng precc savings để xem PRECC đã ngăn được bao nhiêu lãng phí.
Tóm tắt nhanh
$ 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)
Phân tích chi tiết (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>%
Cách ước tính tiết kiệm
Mỗi loại sửa lỗi có chi phí token ước tính dựa trên những gì sẽ xảy ra nếu không có PRECC:
| Loại sửa lỗi | Tiết kiệm ước tính | Lý do |
|---|---|---|
| cd prepend | ~500 tokens | Đầu ra lỗi + suy luận của Claude + thử lại |
| Kích hoạt kỹ năng | ~400 tokens | Đầu ra lỗi + suy luận của Claude + thử lại |
| RTK rewrite | ~250 tokens | Đầu ra dài dòng mà Claude phải đọc |
| Lean-ctx wrap | ~600 tokens | Nội dung tệp lớn được nén |
| Phòng ngừa khai thác | ~500 tokens | Mẫu lỗi đã biết được tránh |
Đây là ước tính thận trọng. Tiết kiệm thực tế thường cao hơn vì suy luận của Claude về lỗi có thể rất dài dòng.
Tiết kiệm tích lũy
Tiết kiệm được lưu giữ qua các phiên trong cơ sở dữ liệu PRECC. Theo thời gian, bạn có thể theo dõi tổng tác động:
$ 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
Thanh trạng thái
Sau khi cài đặt, PRECC thêm một mục statusLine vào ~/.claude/settings.json để thanh trạng thái Claude Code hiển thị các chỉ số phiên trực tiếp:
$0.42 spent | 1.2M in/out | 📊 last cmd: −1.2K | PRECC: 7 fixes | 5.8ms avg | this session: 320 saved over 7 cmds (~$0.05) | lifetime: 8.9K saved over 217 cmds (~$2.85)
Đặt PRECC_LANG để hiển thị nhãn bằng ngôn ngữ của bạn — xem chương Bản địa hóa.
Mỗi đoạn:
| Đoạn | Nguồn | Ý nghĩa | Đặt lại khi khởi động lại phiên? |
|---|---|---|---|
$0.42 spent | cost.total_cost_usd | Chi phí phiên tích lũy do Claude Code báo cáo | Có |
1.2M in/out | total_input_tokens + total_output_tokens | Token đầu vào (không bộ nhớ đệm) + đầu ra trong phiên | Có |
📊 last cmd: −1.2K | Phép đo của PRECC cho lệnh Bash gần nhất | Khoản tiết kiệm thực tế khi chạy lại lệnh gốc | Không (giữ qua các phiên) |
PRECC: 7 fixes | metrics.log | Số lần chỉnh sửa trong phiên này — chỉ đếm số lượng, không ước tính token giả | Có |
5.8ms avg | Độ trễ p50 của hook PRECC | Thời gian PRECC xử lý mỗi lệnh gọi công cụ | Có |
bash 18% of total | post_observations.log | Tỷ lệ token phiên đến từ đầu ra Bash — làm rõ vì sao khoản tiết kiệm của PRECC tự nhiên chỉ là một phần của tổng chi phí (PRECC chỉ tối ưu đầu ra Bash) | Có |
this session: 320 saved over 7 cmds (~$0.05) | .lifetime_summary.json − baseline | Chênh lệch thực theo phiên. Ẩn khi chênh lệch bằng 0 (đầu phiên) | Có (đường cơ sở được chụp lại) |
lifetime: 8.9K saved over 217 cmds (~$2.85) | .lifetime_summary.json | Tổng số token đã tiết kiệm và số lệnh đã đo lại kể từ lần đầu cài đặt PRECC, cộng với giá trị USD ước tính theo mức giá hiện tại trên mỗi token | Không |
Đoạn lifetime: được đặt cuối cùng để nó là đoạn đầu tiên bị cắt nếu giao diện Claude Code cắt thanh ở mép phải.
Vì sao chi phí và số token không chia được cho nhau
1.2M in/out được hiển thị không phải là mẫu số tạo ra $0.42 spent. cost.total_cost_usd của Claude Code được tính từ phân tích đầy đủ token của API — đầu vào cơ bản, đầu ra, cộng với đọc cache và tạo cache. Số lượng token cache tích lũy toàn phiên không được hiển thị trong schema statusline, vì vậy PRECC chỉ có thể hiển thị phần nhìn thấy (không phải cache).
Trong các phiên dài có nhiều lần đọc lại tệp, đọc cache có thể bằng 10× số token nhìn thấy. Đó là lý do ghép cặp chúng thành tỷ lệ sẽ gây hiểu lầm — thay vào đó, PRECC hiển thị chúng dưới dạng các đoạn độc lập.
Vì sao PRECC không tính chi phí
Số tiền chi phí là quyền uy. PRECC đọc nguyên văn cost.total_cost_usd từ JSON mà Claude Code đẩy vào lệnh trạng thái qua stdin. Đó cũng chính là số mà Claude Code tính vào ngân sách đăng ký/sử dụng của bạn. Bạn có thể xác minh bất cứ lúc nào bằng lệnh slash tích hợp /cost — cả hai nên khớp nhau.
Điều gì thúc đẩy chi phí
Đối với Claude Opus 4.6:
| Token type | Standard (≤200k context) | 1M context tier |
|---|---|---|
| Input | $15 / MTok | $30 / MTok |
| Output | $75 / MTok | $150 / MTok |
| Cache write | $18.75 / MTok | $37.50 / MTok |
| Cache read | $1.50 / MTok | $3 / MTok |
Những yếu tố thúc đẩy lớn nhất trong các phiên dài thường là token đầu ra (loại đắt nhất trên mỗi token, đặc biệt ở cấp ngữ cảnh 1M), đọc cache lặp lại (rẻ riêng lẻ nhưng tích lũy nhanh qua nhiều lượt) và tạo cache (ghi một lần cho mỗi lần đọc tệp với tỷ lệ ~1.25× tốc độ đầu vào cơ bản). PRECC giảm chi phí token nhìn thấy bằng cách nén đầu ra Bash (đoạn 📊 last cmd: hiển thị khoản tiết kiệm theo từng lệnh), nhưng không thể giảm đọc cache của các tệp mà Claude đã tải.
Số đếm phiên ổn định
Đoạn “PRECC: N fixes” đếm các sự kiện kể từ thời điểm bắt đầu phiên được lưu trữ, ghi vào ~/.local/share/precc/sessions/<session_id>.start ở lần làm mới statusline đầu tiên của mỗi phiên. Điều này khiến số đếm đơn điệu — nó không thể giảm giữa phiên ngay cả khi cost.total_duration_ms thiếu trong một lần làm mới cụ thể.
Ảnh chụp toàn thời gian tự động làm mới
Đoạn lifetime: đọc ~/.local/share/precc/.lifetime_summary.json, được ghi lại sau mỗi phép đo PostToolUse và sau mỗi lần gọi precc savings. Đoạn this session: đọc cùng tệp lifetime nhưng trừ đi đường cơ sở từng phiên được lưu khi làm mới đầu tiên của mỗi phiên. Không cần làm mới thủ công — các tệp tự cập nhật.
Tắt thanh trạng thái
Nếu bạn muốn giữ thanh trạng thái hiện có, hãy đặt lệnh statusLine của riêng bạn trong ~/.claude/settings.json. Trình cài đặt PRECC sẽ phát hiện giá trị tùy chỉnh và để nguyên nó trong các bản cập nhật tiếp theo.
Để chỉ tắt dòng 📊 PRECC trên mỗi tương tác (trong additionalContext), đặt PRECC_QUIET=1 trong môi trường shell của bạn.
Related research
PRECC’s three savings mechanisms each have a counterpart in the recent literature. These are related work — the ideas PRECC’s design draws on. Their reported figures are their measurements, not PRECC’s: PRECC only ever quotes numbers measured on your own machine (see “measured, not estimated”, above).
- Output/trajectory trimming (PRECC’s
diet+ bash-output compression) — Reducing Cost of LLM Agents with Trajectory Reduction (AgentDiet), FSE 2026, arXiv:2509.23586. Removes redundant/expired trajectory content post-hoc; reports −39.9–59.7% input tokens. PRECC applies the same idea pre-execution and deterministically (no extra LLM call). - Skills as programs (PRECC’s mined + builtin rewrite skills) — Harnessing LLM Agents with Skill Programs, arXiv:2605.17734. Frames reusable agent skills as executable program functions — the same analogy behind PRECC’s command-rewrite skills (a pattern → a deterministic rewrite).
- Context compression (PRECC’s
compress+lean-ctxwrapping) — Compress the Context, Keep the Commitments: A Formal Framework for Verifiable LLM Context Compression, arXiv:2605.17304. Recent work on compressing context without losing required information — the property PRECC’s deterministic, cache-stable rewrites aim to preserve.
Nén
precc compress thu nhỏ CLAUDE.md và các tệp ngữ cảnh khác để giảm sử dụng token khi Claude Code tải chúng. Đây là tính năng Pro.
Sử dụng cơ bản
$ 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.
Chạy thử
Xem trước những gì sẽ thay đổi mà không sửa đổi tệp:
$ 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%)
Hoàn nguyên
Các tệp gốc được sao lưu tự động. Để khôi phục chúng:
$ precc compress --revert
[precc] Restored 3 files from backups.
Những gì được nén
Bộ nén áp dụng nhiều phép biến đổi:
- Xóa khoảng trắng và dòng trống thừa
- Rút ngắn cách diễn đạt dài dòng nhưng giữ nguyên ý nghĩa
- Cô đọng bảng và danh sách
- Loại bỏ chú thích và định dạng trang trí
- Giữ nguyên tất cả khối mã, đường dẫn và định danh kỹ thuật
Đầu ra nén vẫn đọc được – không bị rút gọn hay làm rối.
Nhắm mục tiêu tệp cụ thể
$ precc compress CLAUDE.md
[precc] CLAUDE.md: 2,847 tokens -> 1,203 tokens (-57.7%)
Báo cáo
precc report tạo bảng điều khiển phân tích tóm tắt hoạt động PRECC và token tiết kiệm được.
Tạo báo cáo
$ 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
...
Gửi báo cáo qua email
Gửi báo cáo đến địa chỉ email (yêu cầu thiết lập mail, xem Email):
$ precc report --email
[precc] Report sent to you@example.com
Địa chỉ người nhận được đọc từ ~/.config/precc/mail.toml. Bạn cũng có thể dùng precc mail report EMAIL để gửi đến địa chỉ cụ thể.
Dữ liệu báo cáo
Báo cáo được tạo từ cơ sở dữ liệu PRECC cục bộ tại ~/.local/share/precc/history.db. Không có dữ liệu nào rời khỏi máy của bạn trừ khi bạn gửi báo cáo qua email.
Khai thác
PRECC khai thác nhật ký phiên Claude Code để học các mẫu lỗi-sửa. Khi gặp lại cùng một lỗi, nó tự động áp dụng cách sửa.
Nhập nhật ký phiên
Nhập một tệp đơn
$ 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
Nhập tất cả nhật ký
$ 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
Buộc nhập lại
Để xử lý lại các tệp đã nhập:
$ precc ingest --all --force
[precc] Re-ingesting all 23 session files...
Cách khai thác hoạt động
- PRECC đọc tệp nhật ký JSONL của phiên.
- Nó xác định các cặp lệnh trong đó lệnh đầu tiên thất bại và lệnh thứ hai là lần thử lại đã sửa.
- Nó trích xuất mẫu (điều gì sai) và cách sửa (Claude đã làm gì khác).
- Các mẫu được lưu trong
~/.local/share/precc/history.db. - Khi một mẫu đạt ngưỡng tin cậy (gặp nhiều lần), nó trở thành kỹ năng khai thác trong
heuristics.db.
Ví dụ mẫu
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
Daemon precc-learner
Daemon precc-learner chạy nền và tự động theo dõi nhật ký phiên mới:
$ precc-learner &
[precc-learner] Watching ~/.claude/logs/ for new sessions...
[precc-learner] Processing session-2026-04-03-1412.jsonl... 3 new patterns
Daemon sử dụng thông báo hệ thống tệp (inotify trên Linux, FSEvents trên macOS) nên phản ứng ngay khi phiên kết thúc.
Từ mẫu đến kỹ năng
Các mẫu khai thác được nâng cấp thành kỹ năng khi đáp ứng các tiêu chí sau:
- Xuất hiện ít nhất 3 lần qua các phiên
- Mẫu sửa nhất quán (cùng loại sửa mỗi lần)
- Không phát hiện dương tính giả
Bạn có thể xem xét các ứng viên kỹ năng với:
$ precc skills advise
Xem Skills để biết chi tiết về quản lý kỹ năng.
Lưu trữ dữ liệu
- Cặp lỗi-sửa:
~/.local/share/precc/history.db - Kỹ năng đã nâng cấp:
~/.local/share/precc/heuristics.db
Cả hai đều là cơ sở dữ liệu SQLite ở chế độ WAL để truy cập đồng thời an toàn.
PRECC có thể gửi báo cáo và tệp qua email. Điều này yêu cầu cấu hình SMTP một lần.
Cài đặt
$ 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.
Tệp cấu hình
Cấu hình được lưu tại ~/.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
Bạn có thể chỉnh sửa tệp này trực tiếp:
$EDITOR ~/.config/precc/mail.toml
Đối với Gmail, hãy sử dụng Mật khẩu ứng dụng thay vì mật khẩu tài khoản.
Gửi báo cáo
$ precc mail report team@example.com
[precc] Generating report...
[precc] Sending to team@example.com...
[precc] Report sent.
Gửi tệp
$ precc mail send colleague@example.com output.log
[precc] Sending output.log to colleague@example.com...
[precc] Sent (14.2 KB).
Hỗ trợ chuyển tiếp SSH
Nếu máy của bạn không thể truy cập trực tiếp máy chủ SMTP (ví dụ: sau tường lửa công ty), PRECC hỗ trợ chuyển tiếp qua đường hầm SSH:
[smtp]
host = "localhost"
port = 2525
[ssh_relay]
host = "relay.example.com"
user = "you"
remote_port = 587
local_port = 2525
PRECC sẽ tự động thiết lập đường hầm SSH trước khi gửi.
Ghi GIF
precc gif tạo bản ghi GIF động của phiên terminal từ các script bash. Đây là tính năng Pro.
Cách sử dụng cơ bản
$ 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)
Đối số đầu tiên là một script bash chứa các lệnh cần chạy. Đối số thứ hai là thời lượng ghi tối đa.
Định dạng script
Script là một tệp bash tiêu chuẩn:
#!/bin/bash
echo "Building project..."
cargo build --release
echo "Running tests..."
cargo test
echo "Done!"
Mô phỏng đầu vào
Đối với các lệnh tương tác, cung cấp giá trị đầu vào làm đối số bổ sung:
$ precc gif interactive-demo.sh 60s "yes" "my-project" "3"
Mỗi đối số bổ sung được cung cấp dưới dạng một dòng stdin khi script yêu cầu đầu vào.
Tùy chọn đầu ra
Tệp đầu ra được đặt tên theo script mặc định (script.gif). GIF sử dụng giao diện terminal tối với kích thước chuẩn 80x24.
Tại sao GIF thay vì asciinema?
Kỹ năng tích hợp asciinema-gif tự động viết lại asciinema rec thành precc gif. Tệp GIF dễ di chuyển hơn – chúng hiển thị trực tiếp trong GitHub README, Slack và email mà không cần trình phát.
Phân tích GitHub Actions
precc gha phân tích các lần chạy GitHub Actions thất bại và đề xuất sửa chữa. Đây là tính năng Pro.
Cách sử dụng
Truyền URL của lần chạy GitHub Actions thất bại:
$ 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
Chức năng
- Phân tích URL chạy GitHub Actions để trích xuất chủ sở hữu, kho lưu trữ và ID chạy.
- Lấy nhật ký chạy qua API GitHub (sử dụng
GITHUB_TOKENnếu được đặt, nếu không thì truy cập công khai). - Xác định bước thất bại và trích xuất các dòng lỗi liên quan.
- Phân tích lỗi và đề xuất sửa chữa dựa trên các mẫu lỗi CI phổ biến.
Các mẫu lỗi được hỗ trợ
- Thiếu container dịch vụ (cơ sở dữ liệu, Redis, v.v.)
- Hệ điều hành hoặc kiến trúc runner không chính xác
- Thiếu biến môi trường hoặc secrets
- Lỗi cài đặt phụ thuộc
- Hết thời gian chờ kiểm thử
- Lỗi quyền truy cập
- Cache miss gây ra build chậm
Hàng rào địa lý
PRECC bao gồm kiểm tra tuân thủ hàng rào địa lý IP cho các môi trường được quản lý. Đây là tính năng Pro.
Tổng quan
Một số tổ chức yêu cầu các công cụ phát triển chỉ hoạt động trong các vùng địa lý được phê duyệt. Tính năng hàng rào địa lý của PRECC xác minh rằng địa chỉ IP của máy hiện tại nằm trong danh sách vùng được phép.
Kiểm tra tuân thủ
$ 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
Nếu máy nằm ngoài các vùng được phép:
$ 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.
Làm mới dữ liệu hàng rào địa lý
$ precc geofence refresh
[precc] Fetching updated IP geolocation data...
[precc] Updated. Cache expires in 24h.
Xem thông tin hàng rào địa lý
$ 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
Xóa bộ nhớ đệm
$ precc geofence clear
[precc] Geofence cache cleared.
Cấu hình
Chính sách hàng rào địa lý được định nghĩa trong ~/.config/precc/geofence.toml:
[geofence]
allowed_regions = ["us-east-1", "us-west-2", "eu-west-1"]
check_on_init = true
block_on_violation = false
Đặt block_on_violation = true để ngăn PRECC hoạt động khi nằm ngoài các vùng được phép.
Đo lường từ xa
PRECC hỗ trợ đo lường từ xa ẩn danh tùy chọn để giúp cải thiện công cụ. Không có dữ liệu nào được thu thập trừ khi bạn đồng ý rõ ràng.
Đồng ý tham gia
$ precc telemetry consent
[precc] Telemetry enabled. Thank you for helping improve PRECC.
[precc] You can revoke consent at any time with: precc telemetry revoke
Từ chối tham gia
$ precc telemetry revoke
[precc] Telemetry disabled. No further data will be sent.
Kiểm tra trạng thái
$ precc telemetry status
Telemetry: disabled
Last sent: never
Xem trước dữ liệu sẽ được gửi
Trước khi đồng ý, bạn có thể xem chính xác dữ liệu nào sẽ được thu thập:
$ 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
}
Dữ liệu được thu thập
- Phiên bản PRECC, hệ điều hành và kiến trúc
- Số liệu tổng hợp: lệnh bị chặn, kỹ năng được kích hoạt, trụ cột được sử dụng
- Độ trễ hook trung bình
- Số phiên
Dữ liệu KHÔNG được thu thập
- Không có văn bản lệnh hoặc đối số
- Không có đường dẫn tệp hoặc tên thư mục
- Không có tên dự án hoặc URL kho lưu trữ
- Không có thông tin nhận dạng cá nhân (PII)
- Không có địa chỉ IP (máy chủ không ghi lại chúng)
Ghi đè bằng biến môi trường
Để tắt đo lường từ xa mà không cần chạy lệnh (hữu ích trong CI hoặc môi trường dùng chung):
export PRECC_NO_TELEMETRY=1
Điều này được ưu tiên hơn cài đặt đồng ý.
Đích đến dữ liệu
Dữ liệu đo lường từ xa được gửi tới https://telemetry.peria.ai/v1/precc qua HTTPS. Dữ liệu chỉ được sử dụng để hiểu các mẫu sử dụng và ưu tiên phát triển.
Dự đoán chi phí token
PRECC tích hợp một oracle dự đoán chi phí token để các kế hoạch nhiều bước có thể lập ngân sách bằng token thay vì thời gian thực. Ghi lại một dự đoán trước mỗi bước, ghi nhận giá trị thực sau khi hoàn thành, và tập dữ liệu sẽ huấn luyện một bộ dự đoán tích hợp ngày càng chính xác hơn theo thời gian.
Ghi lại một dự đoán
Truyền một mô tả một dòng của bước đã lên kế hoạch. PRECC phân loại nó (feat / fix / test / refactor / measurement / doc / chore / unknown), ước tính số token và in ra một id mà bạn sẽ dùng để khép vòng.
$ precc predict "Implement read-deltas with mtime check"
id=42 category=feat predicted=5680 tokens (confidence=0.50, model=trained-v1)
Record actual when done: precc predict --record 42 <actual_tokens>
Ghi nhận giá trị thực
Sau khi bước hoàn tất, tra cứu số token thực tế từ chân trang phiên hoặc telemetry và truyền lại qua id.
$ precc predict --record 42 6300
Recorded actual=6300 tokens for prediction id=42.
Huấn luyện trained-v1
Khi bạn có ít nhất mười dự đoán đã đóng, hãy khớp hồi quy ridge trained-v1 trên log10(actual) so với log10(độ dài mô tả) cộng với một biến giả phân loại one-hot. Phép khớp ở dạng đóng (Cholesky trên phương trình chuẩn với ridge λ=1) và chạy trong vài mili giây.
$ precc predict --train
Trained trained-v1 on 22 closed predictions (λ=1).
Model file : ~/.local/share/precc/predict_model.json
Confidence : 0.50
Intercept : +1.0016
log_desc : +1.2339
Categories :
unknown +0.4811
doc +0.4474
measurement +0.3422
test +0.1071
refactor +0.0326
feat +0.0071
fix -0.1096
chore -0.3063
Sau khi huấn luyện, mỗi lệnh precc predict mới sẽ tự động dùng trained-v1 cho đến khi bạn xóa hoặc thay thế tệp mô hình. Các dự đoán cũ giữ nguyên model_version ban đầu để bạn có thể so sánh các bộ dự đoán theo thời gian.
Kiểm tra độ chính xác của bộ dự đoán
precc predict --eval báo cáo sai số phần trăm tuyệt đối trung bình (MAPE) tổng thể và theo từng loại, chỉ tính trên các dự đoán đã đóng (các hàng có cả giá trị dự đoán và giá trị thực).
$ precc predict --eval
Predictions logged : 30
With actuals (closed): 22
Mean predicted : 1483 tokens
Mean actual : 47238 tokens
MAPE (statistical) : 76.4%
By category:
category n predicted actual MAPE
feat 6 4605 5250 26.2%
unknown 4 1597 30526 52.6%
test 4 924 38900 56.4%
...
Liệt kê các dự đoán gần đây
precc predict --list hiển thị các hàng gần đây theo thứ tự thời gian đảo ngược. Các hàng đang mở (chưa có giá trị thực) sẵn sàng để đóng.
$ precc predict --list --limit 5
id ts category predicted actual conf description
30 2026-05-09 09:40:51 feat 5348 - 0.50 Run the synthetic-fleet pilot...
29 2026-05-09 08:56:48 test 1050 - 0.60 Train predictor: trained-v1...
28 2026-05-09 07:44:18 test 915 150000 0.60 Implement minimal task-12...
Tại sao là token, không phải thời gian thực
Ước lượng thời gian không thể đo được sau sự việc và không thể cộng dồn giữa các máy hoặc các phiên. Số lượng token mang tính xác định, có thể so sánh, và phát triển một tập dữ liệu được gắn nhãn giúp cải thiện bộ dự đoán sau mỗi vòng khép kín. Mục đích của oracle là biến việc ước lượng từ trò đoán thành một phép đo.
Dữ liệu nằm ở đâu
Tất cả dữ liệu dự đoán được lưu trữ cục bộ trên máy của bạn. Không có gì được tải lên.
~/.local/share/precc/
├── metrics.db — predictions table (oracle DB)
└── predict_model.json — trained-v1 coefficients (after `--train`)
Bản địa hóa
PRECC hiển thị dòng trạng thái và các chuỗi phản hồi ngắn bằng 28 ngôn ngữ. Bản dịch được biên dịch vào nhị phân, nên việc chọn ngôn ngữ không tốn thêm I/O lúc chạy hook.
Đặt ngôn ngữ
Đặt biến môi trường PRECC_LANG thành mã ngôn ngữ được hỗ trợ. Giá trị này thắng mọi nguồn khác.
$ PRECC_LANG=zh precc savings
$ export PRECC_LANG=ja
Lưu trữ qua consent.toml
Thêm [ui] preferred_language = "ja" (hoặc bất kỳ mã được hỗ trợ nào) vào ~/.config/precc/consent.toml để giữ lựa chọn này qua các shell mà không cần xuất biến môi trường.
# ~/.config/precc/consent.toml
[ui]
preferred_language = "ja"
Thứ tự phân giải
PRECC kiểm tra PRECC_LANG trước, sau đó là [ui] preferred_language trong consent.toml, rồi mới quay về tiếng Anh. Tín hiệu đầu tiên khác rỗng sẽ thắng và được cache suốt vòng đời tiến trình.
1. PRECC_LANG (environment variable)
2. consent.toml ([ui] preferred_language)
3. "en" (default)
Phạm vi hỗ trợ
Bảng dịch chứa 28 cột ngôn ngữ. Các ô không thể xác minh thủ công được để trống và sẽ quay về tiếng Anh khi tra cứu, thay vì hiển thị nội dung bịa. Nếu bạn có thể cải thiện một bản dịch, hãy gửi lên upstream.
en es de zh fr pt ja vi nl hu ar fa tr ko
th my mn bo pl ru zt da sv fi it is2 ro cs
Vì sao vẫn nhanh
Bản dịch được lưu dưới dạng mảng const tại thời điểm biên dịch bên trong nhị phân precc-core, không nằm trong SQLite. Hook chỉ thực hiện một lần tra cứu mảng trong bộ nhớ, nên dịch không tốn chi phí đo được so với ngân sách hook < 5 ms p99.
Sơ đồ tư duy
Trang này được tạo tự động từ mindmap.db — một bản chụp SQLite của tất cả các phiên phát triển PRECC và git commit đã ghi lại. Mỗi hàng đều truy nguyên về nguồn của nó (commit:<sha>, session:<id>, hoặc doc:<path>).
Tổng quan
- Phiên đã phân tích: 22
- Tin nhắn: 14023
- Lệnh gọi công cụ: 5072
- Commit: 205
- Khoảng thời gian: 2026-03-20T07:04:14.787Z → 2026-04-19T11:50:10.153Z
- Công sức (token):
- đầu vào: 27928
- đầu ra: 2750669
- ghi cache: 43349705
- đọc cache: 1936351239
Tính năng
| Phạm vi | Tiêu đề | Trạng thái | Commit | Token | Đầu tiên | Cuối cùng | Nguồn |
|---|---|---|---|---|---|---|---|
bench | feat(bench): SWE-bench Verified/Lite driver scaffolding | stabilizing | 4 | 4344299 | 2026-04-17 | 2026-04-17 | commit:5bdd027d |
benchmark_gate.sh | feat: benchmark_gate.sh + pin tb dataset to 0.1.1 | shipped | 1 | 4344299 | 2026-04-17 | 2026-04-17 | commit:99fa9a74 |
real | feat: real lean-ctx (not stub), wider campaign, doc updates | shipped | 2 | 29821152 | 2026-04-07 | 2026-04-17 | commit:6095720a |
precc_mode=benchmark | feat: PRECC_MODE=benchmark toggle + pairwise benchmark harness | shipped | 1 | 4344299 | 2026-04-17 | 2026-04-17 | commit:50c5a30f |
add | feat: add precc update self-update command | shipped | 14 | 42557107 | 2026-03-09 | 2026-04-17 | commit:e5542fba |
negotiable | feat: negotiable rewrites, skill decay, explain/undo — response to critic | shipped | 1 | 4344299 | 2026-04-17 | 2026-04-17 | commit:6fda67e4 |
statusline | feat: statusline shows actual session token consumption + cost | stabilizing | 3 | 25424915 | 2026-04-08 | 2026-04-13 | commit:4f65556d |
public | feat: public repo commits attributed to Ce-cyber-art | shipped | 1 | 25382119 | 2026-04-10 | 2026-04-10 | commit:0e4840e4 |
short | feat: short install URL https://peria.ai/install.sh | shipped | 1 | 25382119 | 2026-04-09 | 2026-04-09 | commit:615d3d06 |
rewrite | feat: rewrite Pillar 2b (ccc) and Pillar 3 (compress) in Rust for single-binary deployment | shipped | 2 | 38118074 | 2026-03-20 | 2026-04-08 | commit:78621579 |
shorten | feat: shorten statusline segments to fit narrower terminals | shipped | 1 | 25382119 | 2026-04-08 | 2026-04-08 | commit:ef2c88b4 |
drop | feat: drop fake token estimate, append cost estimate to lifetime segment | stabilizing | 2 | 25382119 | 2026-04-08 | 2026-04-08 | commit:2702f3f9 |
update | feat: update pricing to $5/6mo + $10/yr, add webhook server | stabilizing | 9 | 38118074 | 2026-02-25 | 2026-04-08 | commit:2d366031 |
clearer | feat: clearer statusline labels — meas:, drop confusing %, add bash share | shipped | 1 | 25382119 | 2026-04-08 | 2026-04-08 | commit:4cd837b7 |
stable | feat: stable machine_hash for telemetry dedup | stabilizing | 2 | 25382119 | 2026-04-08 | 2026-04-08 | commit:3073f428 |
lifetime | feat: lifetime savings segment in statusline | shipped | 1 | 25382119 | 2026-04-08 | 2026-04-08 | commit:9af422e8 |
precc | feat: precc analyze frequencies — data-driven rule gap discovery | shipped | 3 | 25382119 | 2026-04-07 | 2026-04-08 | commit:d6f24c50 |
per-interaction | feat: per-interaction PRECC savings line in PostToolUse | shipped | 1 | 25382119 | 2026-04-08 | 2026-04-08 | commit:e3bc282e |
webhook | feat: webhook auto-regenerates stats.json on telemetry POST | stabilizing | 2 | 29134186 | 2026-03-31 | 2026-04-08 | commit:912b75f3 |
per-email | feat: per-email aggregation for telemetry | shipped | 1 | 25382119 | 2026-04-08 | 2026-04-08 | commit:14c95e7d |
v0.3.3 | feat: v0.3.3 — companion tools default-on, install-script clarity | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:48fca046 |
measurement | feat: measurement campaign script — real per-mode measurements | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:36760587 |
quote-aware | feat: quote-aware chain split + sysadmin tool whitelist (54.2% → 55.5%) | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:f6580598 |
; | feat: ; chain support + ssh inner-command parsing for measurement | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:10093218 |
expand | feat: expand is_safe_to_rerun coverage + measurement timeout/cache | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:c5a7ea79 |
multi-mode | feat: multi-mode adaptive compression with failure learning | shipped | 1 | 25382119 | 2026-04-07 | 2026-04-07 | commit:81475afc |
measured | feat: measured savings in telemetry, detailed live stats, update nudge | shipped | 1 | 25382119 | 2026-04-06 | 2026-04-06 | commit:06907091 |
scientific | feat: scientific token savings measurement, telemetry dedup, 28-language docs | shipped | 1 | 25382119 | 2026-04-06 | 2026-04-06 | commit:78a20ef2 |
v0.3.2 | feat: v0.3.2 — hook safety, adaptive compression, on-demand metrics import | shipped | 1 | 25382119 | 2026-04-05 | 2026-04-05 | commit:a0c0c882 |
self-hosted | feat: self-hosted telemetry endpoint at peria.ai, install UX improvements | shipped | 1 | 2565703 | 2026-04-04 | 2026-04-04 | commit:8212a18e |
auto-update | feat: auto-update consent prompt on init and manual update | shipped | 1 | 1924302 | 2026-04-02 | 2026-04-02 | commit:818be6dd |
use | perf: use pre-built binaries for lean-ctx and nushell installation | stabilizing | 4 | 10170252 | 2026-03-09 | 2026-03-31 | commit:8c612e55 |
authorize | feat: authorize peria.ai server for license key generation | shipped | 2 | 1186364 | 2026-03-31 | 2026-03-31 | commit:53dfe832 |
license | feat: license keys, SMTP mail-agent, updated business plan and demos | stabilizing | 2 | 10170252 | 2026-03-09 | 2026-03-31 | commit:b07c9dfb |
lean-ctx | feat: lean-ctx integration for deep output compression | shipped | 1 | 1186364 | 2026-03-31 | 2026-03-31 | commit:07361e62 |
integrate | feat: integrate three-pillar savings from precc-cc (cocoindex-code, token-saver, ClawHub) | shipped | 2 | 10170252 | 2026-03-20 | 2026-03-31 | commit:af4205f1 |
windows | feat: Windows build via CI, deploy triggers workflow | stabilizing | 2 | 2533692 | 2026-03-29 | 2026-03-29 | commit:7404761b |
monthly | feat: monthly usage report via email for Pro users | shipped | 1 | 2533692 | 2026-03-28 | 2026-03-28 | commit:77ad78bc |
nushell | feat: nushell what-if analysis, skill clustering, comment blocker, bash unwrap (v0.2.6) | shipped | 1 | 2337941 | 2026-03-27 | 2026-03-27 | commit:803df684 |
geofence | feat: geofence compliance guard, 3rd-party skill Claude interaction tracking (v0.2.5) | shipped | 1 | 2337941 | 2026-03-26 | 2026-03-26 | commit:0c9fc765 |
stripe | feat: Stripe payment integration, context pressure, GHA analysis | shipped | 2 | 2457088 | 2026-03-21 | 2026-03-22 | commit:8eb16f78 |
context | feat: context pressure warning, GHA analysis, statusline context % | shipped | 1 | 2166141 | 2026-03-20 | 2026-03-20 | commit:894621ba |
statusline, | feat: statusline, squash deploy, ClaWHub metadata, SHA256 checksums | shipped | 1 | 2166141 | 2026-03-20 | 2026-03-20 | commit:7ab15883 |
gumroad | feat: Gumroad license verification via API (v0.2.2) | shipped | 1 | 0 | 2026-03-13 | 2026-03-13 | commit:75c5e480 |
per-user | feat: per-user email-based license keys with Gumroad webhook (v0.2.2) | shipped | 1 | 0 | 2026-03-13 | 2026-03-13 | commit:6d056958 |
posttooluse | feat: PostToolUse observability + comprehensive test coverage (v0.2.1) | shipped | 1 | 0 | 2026-03-12 | 2026-03-12 | commit:6e33b7e4 |
multi-tool | feat: multi-tool hook dispatch, subagent propagation & Read/Grep filters (v0.2.0) | shipped | 1 | 0 | 2026-03-12 | 2026-03-12 | commit:1bf5a108 |
skill | feat: skill advisor, sharing credits, telemetry & Rust actionbook (v0.1.9) | shipped | 1 | 0 | 2026-03-12 | 2026-03-12 | commit:d41d310e |
fire | feat: fire anonymous update-check ping on precc update (opt-out via PRECC_NO_TELEMETRY=1) | shipped | 1 | 0 | 2026-03-10 | 2026-03-10 | commit:7acce69d |
enforce | feat: enforce license tier gates (Free/Pro) on ingest, mined skills, gif, mail, savings | shipped | 1 | 0 | 2026-03-10 | 2026-03-10 | commit:a7bd23e3 |
translate | feat: translate git commands to jj (Jujutsu) in colocated repos | shipped | 1 | 0 | 2026-03-09 | 2026-03-09 | commit:d8a29e48 |
rtk | feat(rtk): sync rewrite rules with upstream RTK v0.27.2 | shipped | 1 | 0 | 2026-03-09 | 2026-03-09 | commit:ad7dca0e |
apply | feat: apply skill portfolio per command for maximum token savings | shipped | 1 | 0 | 2026-03-09 | 2026-03-09 | commit:b2490073 |
pitch | feat(pitch): add bilingual EN/ZH PowerPoint pitch deck | shipped | 2 | 0 | 2026-02-27 | 2026-02-28 | commit:8876c4b7 |
hook | perf(hook): skip heuristics.db open via plain-text prefix cache | shipped | 1 | 0 | 2026-02-27 | 2026-02-27 | commit:89537483 |
init | feat(init): embed builtin skills in binary via include_str! | shipped | 1 | 0 | 2026-02-26 | 2026-02-26 | commit:3a837b13 |
cli | feat(cli): add precc skills export command | shipped | 2 | 0 | 2026-02-26 | 2026-02-26 | commit:59beea8d |
gdb | feat(gdb): re-enable Pillar 2 GDB hook suggestion | shipped | 1 | 0 | 2026-02-26 | 2026-02-26 | commit:a8428025 |
skills | feat(skills): add git wrong-dir skill and context mapping | stabilizing | 2 | 0 | 2026-02-25 | 2026-02-25 | commit:352474e1 |
metrics | feat(metrics): record hook latency, rtk_rewrite, cd_prepend via append-log | shipped | 1 | 0 | 2026-02-25 | 2026-02-25 | commit:9bf31d12 |
demo | feat(demo): add investor demo suite | shipped | 1 | 0 | 2026-02-25 | 2026-02-25 | commit:c818a0ac |
security | feat(security): SQLCipher encryption, binary hardening, multi-platform CI | shipped | 1 | 0 | 2026-02-25 | 2026-02-25 | commit:efd3dfc8 |
ingest | feat(ingest): add –force flag to re-mine already-recorded sessions | shipped | 1 | 0 | 2026-02-22 | 2026-02-22 | commit:85cc8f6f |
Phụ thuộc (module precc-core)
advisor→db,promote,skillsdiet→lean_ctxmetrics→dbmining→skillsmode_selector→db,modemulti_probe→diet,lean_ctx,mode,nushell,post_observe,rtknushell→lean_ctx,mining,rtkpromote→db,skillsrtk→lean_ctxsharing→db,license,skillsskill_advisor→mining,nushellskills→dbtelemetry→db,license,mining
Kế hoạch & Công việc
Kế hoạch (yêu cầu thiết kế/kiến trúc)
- [proposed] indeed the measurement needs to be based on precc-cc’s established KPI’s. If the two ideas are so close, perhaps you can draft a plan to integrate them (algorithmatically) step-by-step, then start to use Rust (consistent with Precc) to impl… —
session:905ff169(2026-04-18) - [proposed] 西班牙语网站上有人评价:中文翻譯(繁體): —
session:781fe484(2026-04-16) - [proposed] That’s a really solid framing — using pre-tool-call hooks as quality gates instead of just optimization is a big shift in mindset. You’re essentially moving from “make the model cheaper” to “make the system more correct,” whic… —
session:ebd81938(2026-04-05) - [proposed] Plan the integration of both tools, make sure we don’t take their credit and maintain a clear interface so that once it evolves, we can get smaller changes to integrate with their future changes —
session:43541885(2026-03-31) - [proposed] for the benchmark, we need to prepare a table to record the comparison for existing historical scenarios, as a “what-if” analysis because there is no way to measure the results for future usages. For this requirement, plan out a step-by-ste… —
session:5761d7ca(2026-03-27) - [proposed] while bash could be improved using RTK, would its replacement with nushell a better choice for Claude Code? If so, plan an option for replacing bash with nushell to gain better accuracy and hence potentially more token savings by some small… —
session:5761d7ca(2026-03-27)
Công việc (mục TaskCreate / TodoWrite)
- completed: 89
- in_progress: 3
- deleted: 2
30 công việc gần nhất:
- [completed] Re-ingest and review residual pending — Run precc mindmap build after the fix, then classify the actually-pending tasks (done-but-unclosed vs genuinely-unfinished). —
session:0925455d(2026-04-19) - [completed] Fold TaskCreate/TaskUpdate + dedupe TodoWrite — Replay TaskCreate/TaskUpdate events per (session_id, taskId) to derive final status. For TodoWrite, keep only the last call per session. —
session:0925455d(2026-04-19) - [completed] Run ingest and produce MINDMAP.md — Execute ingest on local sessions + git, then render output to docs/MINDMAP.md. —
session:0925455d(2026-04-19) - [completed] Wire precc mindmap CLI subcommand — Add ingest/render subcommands to precc-cli. —
session:0925455d(2026-04-19) - [completed] Write mindmap render module — Query DB and render nested markdown mindmap with KPIs, features, plans, blockers. —
session:0925455d(2026-04-19) - [completed] Write mindmap ingest module — Parse JSONL sessions + git log, extract messages/tokens/commands/decisions into SQLite. —
session:0925455d(2026-04-19) - [completed] Design SQLite mindmap schema — Tables: sessions, messages, commands, features, plans, tasks, kpis, decisions, dependencies. Every row traces to source (session_id+uuid or commit sha). —
session:0925455d(2026-04-19) - [in_progress] Step 4: HeaderSlicePass + kernel corpus — Shallow-clone Linux kernel, adapt filter for kernel conventions (Fixes: tag, selftests/ and kunit test-surface detection, .c/.h classification). Measure how many recent fix commits ship with a test an… —
session:905ff169(2026-04-19) - [completed] Step 6: concurrency extraction — Add Pipeline::run_parallel_applies that parallelizes applies() via std::thread::scope when pass count ≥ threshold. Falls back to serial below threshold (thread-spawn overhead > savings). Benchmark s… —
session:905ff169(2026-04-19) - [completed] [parallel] AST-aware #[test] extractor — Use syn (Rust) or tree-sitter-rust (Python) to detect added #[test] fns in a commit diff and emit a test-only patch. Gates fail→pass verification on this repo. Not blocking; parallel work for the Ru… —
session:905ff169(2026-04-19) - [completed] Step 7: precc skvm report tooling — Wire had_solid_hit into metrics log. Add
precc skvm reportthat surfaces pass activation counts, cache hit rate, hook-latency percentiles. Read from metrics.db + skvm_solid_cache. Closes the observa… —session:905ff169(2026-04-19) - [completed] Wire SolidificationPass into live hook — Add stage_solidification_lookup (front, short-circuits on hit) and stage_solidification_record (end) to Pipeline. Gate behind PRECC_SOLIDIFY. Add had_solid_hit flag. Open cache via db::open_metrics fo… —
session:905ff169(2026-04-19) - [completed] Step 3: solidification cache — skvm::solid module: Cache (SQLite-backed) with lookup/record, Key with normalization, SolidificationPass at pipeline front. Gated by PRECC_SOLIDIFY=1. Tests with in-memory DB. No wiring into live hook… —
session:905ff169(2026-04-19) - [completed] Wire CdPrependPass into hook’s stage_context — Replace the direct context::resolve/apply calls in precc-hook::Pipeline::stage_context with CdPrependPass via HookIR. Verify no hook tests regress; full cargo test green. —
session:905ff169(2026-04-19) - [completed] Step 2: migrate cd_prepend through Pass trait — Re-express the existing cd-prepend stage as a Pass impl that reuses the current context resolution. Diff-test: on a fixture corpus, the new pass must produce byte-identical output to the legacy path. … —
session:905ff169(2026-04-19) - [completed] Step 5 preview: CrateSlicePass sketch — Implement CrateSlicePass in precc-core::skvm::passes::crate_slice. Detects
cargo <build\|test\|check\|clippy>without -p, reads cachedcargo metadata, narrows to -p when unambiguous. Wire a minimal K… —session:905ff169(2026-04-19) - [completed] Step 1: Pass trait + HookIR — precc-core::skvm::{pass, ir}. Pass trait with name/capability/applies/run. HookIR holds command, cwd, and mutable output. Capability enum: Detect|Rewrite|Slice|Verify. No behavior change; no passes re… —
session:905ff169(2026-04-19) - [completed] Step 0: baseline harness — Add precc-core::skvm::baseline module +
precc report --skvm-baselinesubcommand. Snapshots K1 (hook latency p50/p99), K3 (token savings total), activation counts from metrics.db into a named baselin… —session:905ff169(2026-04-19) - [completed] Build K3-only replay corpus — For each of the 82 fix-surface commits, derive ground-truth set of changed crates and emit realistic cargo commands. CrateSlicePass evaluation will read this corpus and measure narrowing precision/rec… —
session:905ff169(2026-04-18) - [deleted] Run verifier over 33 candidates — Execute verifier, collect verdicts. Apply size gate to verified set. Emit precc_self_corpus.jsonl. —
session:905ff169(2026-04-18) - [deleted] Write fail-at-parent verifier — Per candidate: git worktree at parent, apply only test-file diff, cargo test (expect added tests FAIL), reset + apply full commit, cargo test (expect PASS). Per-worktree CARGO_TARGET_DIR to avoid tras… —
session:905ff169(2026-04-18) - [completed] Classify test surface of 33 candidates — Split candidates into pure_test_path (tests/ only) vs mixed_file_test (production + #[test] in same file). Reports count by class. Cheap, no cargo. —
session:905ff169(2026-04-18) - [completed] Run first Terminal-bench batch (5 tasks) — Execute scripts/benchmark.sh –tasks 5 using OAuth token from subscription as ANTHROPIC_API_KEY. Verify arm A (vanilla) works, then arm B (PRECC), then compare.json. —
session:781fe484(2026-04-17) - [completed] Add precc explain and precc undo — explain –since 1h: lists recent rewrites with diff + skill + confidence (reads stash + rewrite_log). undo <id>: re-disables the skill that produced rewrite id. —
session:781fe484(2026-04-16) - [completed] Confidence decay on retry-after-rewrite — post_observe: if same command class is retried within 60s after a PRECC rewrite, decrement skill confidence by 0.05 (or count as false-correction event). Below SUGGEST_THRESHOLD (0.3) skill auto-disab… —
session:781fe484(2026-04-16) - [completed] Add precc skills disable/enable per-project — CLI commands to disable a skill in the current project (writes to .precc/disabled-skills file at project root). Hook reads this list and skips matching skills. —
session:781fe484(2026-04-16) - [completed] Make every rewrite visible via additionalContext — In precc-hook, whenever the pipeline produces a non-trivial rewrite (cd-prepend, skill, RTK, lean-ctx, nushell, diet), append a one-line summary “PRECC rewrote: <orig> -> <new> [reason]” to additional… —
session:781fe484(2026-04-16) - [completed] Soften overstated claims in intro — Replace “Claude never sees the error. No tokens wasted.” with measured language matching README. Update strings_intro.sql and re-translate the new key for all 28 langs. —
session:781fe484(2026-04-16) - [completed] Fix per-language html lang and dir — build-book.sh must rewrite book.toml language= and text-direction= per language so generated pages have correct lang/dir attributes. RTL for ar, fa. —
session:781fe484(2026-04-16) - [completed] Rebuild book and verify — Run scripts/build-book.sh to regenerate introduction.md per language, verify first lines now show translations —
session:781fe484(2026-04-16)
Điểm nghẽn (tín hiệu lỗi/kẹt do người dùng báo cáo)
- look at all the historical session logs and executed commands to summarize a mark down document like Mindmap showing (1) the features, status, decisions, dependencies, and effort (tokens releated to its development); (2) the plans, tasks, s… —
session:0925455d(2026-04-19) - check if it is working? why precc savings –all doesn’t work? —
session:ebd81938(2026-04-13) - i tried that url it doesn’t work? —
session:ebd81938(2026-04-08) - why I can’t see the “last: “ messages? —
session:ebd81938(2026-04-08) - not yet. I would wait to get more data from telemetry to update the website. But now you need to investigate on those “unmeasured” cases, why we cannot measure them? —
session:ebd81938(2026-04-07) - regarding the live usage statistics https://precc.cc/en/#live-usage-statistics, we need to report the percentages based on the duration of releases, i.e., how much saving was made by which release (otherwise it is easy to mislead readers to… —
session:ebd81938(2026-04-06) - https://precc.cc cannot find the server —
session:ebd81938(2026-04-05) - can see key_id mk_1TDiUmFxhHEidPnDw5esdOMa, but cannot reveal or see the sk_live_… —
session:d65ad15f(2026-04-01) - PS C:\Users\y00577373> iwr -useb https://raw.githubusercontent.com/peria-ai/precc-cc/main/scripts/install.ps1 | iex —
session:10175339(2026-03-30) - why can’t you create peria-ai or peri-a-i organizations —
session:10175339(2026-03-28) - the hello_world_do example has the following errors: NPU run failed. —
session:3b5e2947(2026-03-22)
Quyết định và lý do
- feat(bench): clean-subset metrics (exclude timeouts & infra failures) — When one arm times out or the agent fails to install, the resulting tokens/pass numbers aren’t measuring PRECC — they’re measuring tb’s source:
commit:5bdd027d(commit 2026-04-17) - fix(bench): drop –include-hook-events (causes 401 Invalid API key) — Adding
--include-hook-eventsto the tb agent command caused Claude Code to return api_error_status=401 on first turn, even though the source:commit:025995d9(commit 2026-04-17) - feat: PRECC_MODE=benchmark toggle + pairwise benchmark harness — Problem (from reviewer): the “trivial vs semantic” error-shaping claim is rhetoric without a measurable boundary. A rewriter that saves tokens source:
commit:50c5a30f(commit 2026-04-17) - docs: update savings.md.tpl + README to match new statusline labels — - Σ → meas: throughout - New ‘bash X% of total’ segment row in segment table source:
commit:2d366031(commit 2026-04-08) - feat: clearer statusline labels — meas:, drop confusing %, add bash share — Three statusline UX changes from user feedback: 1. Lifetime segment renamed from ‘Σ 8.9K (22% over 217)’ to source:
commit:4cd837b7(commit 2026-04-08) - docs: explain statusline cost vs token semantics in book + README — Adds a ‘Status Bar’ section to docs/book/templates/savings.md.tpl and README.md explaining: source:
commit:6028b64c(commit 2026-04-08) - feat: v0.3.3 — companion tools default-on, install-script clarity — The single biggest change: install.sh now installs companion tools (lean-ctx, RTK, nushell, cocoindex-code) BY DEFAULT instead of source:
commit:48fca046(commit 2026-04-07) - feat: quote-aware chain split + sysadmin tool whitelist (54.2% → 55.5%) — Three improvements that increase measurable Bash invocation coverage: 1. Quote-aware top-level chain split source:
commit:f6580598(commit 2026-04-07) - fix: command_class env stripping, skill validation, ssh/journalctl/kubectl diet rules — 1. command_class strips env prefixes and noise: - RUST_BACKTRACE=1 cargo test → “cargo test” source:
commit:f4220343(commit 2026-04-07) - feat: multi-mode adaptive compression with failure learning — New modules: - mode.rs: CompressionMode enum (basic/diet/nushell/lean-ctx/rtk/adaptive-expand) source:
commit:81475afc(commit 2026-04-07) - test: comprehensive tests for ccc and compress modules (319 → 386 tests) — ccc.rs: +20 tests covering edge cases for is_eligible (flags, whitespace, empty input), extract_pattern (no path, multiple flags, boundary length), source:
commit:448430e2(commit 2026-03-20) - feat(gdb): re-enable Pillar 2 GDB hook suggestion — - Add open_history_readonly() to db.rs (same pattern as heuristics) - Add count_recent_failures() to gdb.rs: queries failure_fix_pairs for source:
commit:a8428025(commit 2026-02-26) - fix(mining): correct summary counters and orphaned events on –force re-mine — Three bugs fixed: 1. mine_session returned Skipped for sessions with no Bash events even source:
commit:3ef089d8(commit 2026-02-22) - 1. Compiled Rust Binary vs Shell Script — Decision: Replace the
rtk-rewrite.shshell script hook with a compiled Rust binary (precc-hook). Alternatives considered: source:doc:ALTERNATIVES.md - 2. SQLite vs Key-Value Store — Decision: Use SQLite for both
history.dbandheuristics.db. Alternatives considered: source:doc:ALTERNATIVES.md - 3. Workspace of 4 Crates vs Monolith — Decision: Structure the project as a Cargo workspace with 4 crates:
precc-core,precc-hook,precc-cli,precc-learner. Alternatives considered: source:doc:ALTERNATIVES.md - 4. GDB Hook Integration vs Standalone CLI — Decision: Implement GDB debugging as a CLI command (
precc debug) rather than as an automatic hook rewrite. Alternatives considered: source:doc:ALTERNATIVES.md - 5. Background Daemon vs On-Demand Mining — Decision: Support both modes —
precc-learnerdaemon for continuous mining,precc ingestfor on-demand. Alternatives considered: source:doc:ALTERNATIVES.md - 6. Confidence Thresholds — Decision: Three-tier confidence system: auto-apply (≥ 0.7), suggest (0.3-0.7), hidden (< 0.3). Alternatives considered: source:
doc:ALTERNATIVES.md - 7. RTK Subsumption Strategy — Decision: Port RTK’s rewriting logic into
precc-coreas the final pipeline stage, rather than running both hooks in sequence. Alternatives considered: source:doc:ALTERNATIVES.md - 8. Skill Storage Format — Decision: TOML files for built-in skills, SQLite rows for mined/user skills. Alternatives considered: source:
doc:ALTERNATIVES.md - 9. Session Log Format — Decision: Read Claude Code’s native JSONL format directly rather than converting to a custom format. Rationale: Claude Code already writes detailed session logs in JSONL format at
~/.claude/projects/*/. Creating a custom format would mean: source:doc:ALTERNATIVES.md
KPI theo thời gian
| Chỉ số | Đơn vị | Đầu tiên | Mới nhất | Δ | Mẫu | Nguồn cuối |
|---|---|---|---|---|---|---|
at | x | 0.1 | 1.25 | +1.15 | 2 | commit:4f65556d |
build | ms | 3 | 480 | +477 | 2 | commit:f84bab49 |
hook | ms | 5 | 3 | -2 | 2 | commit:f81e4543 |
precc | tokens | 423 | 87 | -336 | 2 | commit:e3bc282e |
saved | ms | 4.8 | 6.3 | +1.5 | 2 | commit:ec17f16c |
Công sức theo phiên (top 10 theo token)
| Phiên | Đầu → Cuối | TN | đầu vào | đầu ra | Ghi cache | Đọc cache |
|---|---|---|---|---|---|---|
ebd81938 | 2026-04-04 → 2026-04-13 | 4517 | 4547 | 686622 | 24690950 | 1020430414 |
781fe484 | 2026-04-16 → 2026-04-17 | 1434 | 1341 | 603596 | 3739362 | 259708120 |
10175339 | 2026-03-28 → 2026-03-30 | 1318 | 1176 | 102469 | 2430047 | 110606429 |
5761d7ca | 2026-03-26 → 2026-03-28 | 1180 | 4363 | 137056 | 2196522 | 116605673 |
550c7bab | 2026-03-20 → 2026-03-22 | 1064 | 1466 | 104943 | 2059732 | 92991217 |
905ff169 | 2026-04-18 → 2026-04-19 | 650 | 1698 | 496929 | 1572668 | 63432376 |
d65ad15f | 2026-03-31 → 2026-04-04 | 752 | 558 | 78099 | 1845645 | 58334554 |
3b5e2947 | 2026-03-22 → 2026-03-23 | 1162 | 896 | 128068 | 1526203 | 102403205 |
0925455d | 2026-04-19 → 2026-04-19 | 440 | 830 | 262128 | 1226054 | 32943523 |
43541885 | 2026-03-31 → 2026-03-31 | 566 | 7353 | 82683 | 1096328 | 41667559 |
Sử dụng PRECC với Cursor
PRECC được xây dựng như một hook PreToolUse cho Claude Code, nhưng thư viện skill nền tảng — cargo-wrong-dir, git-wrong-dir, npm-wrong-dir, jj-translate, và các skill liên quan — không phụ thuộc vào trình soạn thảo. Chỉ với một đoạn shell nhỏ, bạn có thể định tuyến mọi lệnh được gõ trong terminal tích hợp của Cursor qua precc-hook, để cùng các phép viết lại giúp tiết kiệm token trên Claude Code cũng tiết kiệm token trên Cursor.
Requires
precc≥ 0.3.45. Earlier versions don’t plant the integration scripts under<data_dir>/integrations/cursor/. Runprecc updateto upgrade if you have an older release.
Phạm vi hỗ trợ
Tích hợp này bắt được các lệnh bạn gõ vào terminal của Cursor. Trên zsh, nó tự động viết lại dòng lệnh trước khi nhấn Enter; trên bash, nó chỉ có thể cảnh báo (bẫy DEBUG được kích hoạt sau khi lệnh đã được chốt). Các lệnh mà agent của Cursor sinh ra dưới dạng subprocess bash -c không nạp tệp init của shell tương tác, nên hook không nhìn thấy chúng; để lấp khoảng trống này cần một shim PATH, hiện chưa có trong thư mục này. Các lời gọi công cụ phi-shell của Cursor (chỉnh sửa tệp, tìm kiếm mã) cũng nằm ngoài phạm vi.
Cài đặt
zsh (tự động viết lại)
source ~/.local/share/precc/integrations/cursor/precc-preexec.zsh
Chạy precc init một lần — lệnh này sẽ đặt script tại đường dẫn nêu trên (sử dụng <data_dir> từ kho lưu trữ của precc, nên CLAUDE_CONFIG_DIR và các cơ chế cách ly hồ sơ khác đều được tôn trọng). Sau đó thêm dòng source vào ~/.zshrc. precc-hook và jq phải có trong PATH; script sẽ không thực thi gì cả một cách êm xuôi nếu thiếu một trong hai.
bash (chỉ cảnh báo)
source ~/.local/share/precc/integrations/cursor/precc-preexec.bash
Chạy precc init một lần — lệnh này sẽ đặt script tại đường dẫn nêu trên. Sau đó thêm dòng source vào ~/.bashrc. Bẫy DEBUG sẽ in gợi ý viết lại ra stderr mà không áp dụng nó; bạn có thể sao chép gợi ý thủ công.
Xác minh
Trong terminal của Cursor, cd /tmp (hoặc bất kỳ nơi nào nằm ngoài một dự án Rust) và gõ một lệnh build Rust rồi nhấn Enter. Trên zsh, bộ đệm dòng lệnh sẽ tự đổi tại chỗ thành dạng đã được PRECC viết lại (thường là một tiền tố kiểu cd PATH && …). Trên bash, bạn sẽ thấy một dòng [precc] suggested rewrite: … trên stderr.
Lưu ý
- Thêm độ trễ của
precc-hookcho mỗi lần gõ phím. Hook nhắm tới <5 ms p50 nhưng p99 cao hơn khi cache nguội; xem các ghi chú về độ trễ hook trong cuốn sách này. - Không có telemetry từ đường này. Hook sẽ báo cáo dưới bất kỳ
agent_classnào mà nó phát hiện được, sẽ không phải làclaude-code— phần token bạn tiết kiệm được trên Cursor sẽ không xuất hiện trên trang thống kê công khai. - Lý do viết lại sẽ nhấp nháy qua
zle -Mtrong một lần gõ phím. Lặng lẽ, không chặn thao tác. - Để bao phủ cả agent, một shim
PATH(các wrapper tại~/.precc/bin/cargo,~/.precc/bin/git, …) là bước kế tiếp đã được dự kiến.
Tham chiếu lệnh
Tham chiếu đầy đủ cho tất cả các lệnh PRECC.
precc init
Khởi tạo PRECC và đăng ký hook với 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
Khai thác nhật ký phiên để tìm các mẫu lỗi-sửa.
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
Quản lý các kỹ năng tự động hóa.
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
Tạo báo cáo phân tích.
precc report [--email]
Options:
--email Send the report via email (requires mail setup)
precc savings
Hiển thị tiết kiệm token.
precc savings [--all]
Options:
--all Show detailed per-command breakdown (Pro)
precc compress
Nén các tệp ngữ cảnh để giảm sử dụng token.
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
Quản lý giấy phép PRECC của bạn.
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
Chức năng email.
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
Cập nhật PRECC lên phiên bản mới nhất.
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
Quản lý đo lường từ xa ẩn danh.
precc telemetry consent
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
Tuân thủ geofence IP (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
Ghi GIF động từ các tập lệnh bash (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
Phân tích các lần chạy GitHub Actions thất bại (Pro).
precc gha URL
Arguments:
URL GitHub Actions run URL
Example:
precc gha https://github.com/org/repo/actions/runs/12345678
precc cache-hint
Hiển thị thông tin gợi ý bộ nhớ đệm cho dự án hiện tại.
precc cache-hint
precc trial
Bắt đầu dùng thử Pro.
precc trial EMAIL
Arguments:
EMAIL Email address for the trial
precc nushell
Khởi chạy phiên Nushell với tích hợp PRECC.
precc nushell
precc doctor
Self-diagnose a broken or silent install.
precc doctor
Self-diagnose the install: settings.json hook registration, hook binary
path + permissions, and when the hook last fired. Run this first when
`precc savings` reports 0 tokens saved on a fresh install.
Options:
(none)
precc debug
Launch a GDB debugging session for a binary.
precc debug [BINARY] [ARGS...]
GDB-based debugging helper (Pillar 2).
Arguments:
BINARY Binary to debug
ARGS... Arguments to pass to the binary
precc explain
See what PRECC recently rewrote, and why.
precc explain [--since 1h] [--limit 20]
Show recent PRECC rewrites with their diff and the reasons each fired —
the audit trail for what PRECC changed.
Options:
--since SINCE Time window, e.g. "30m", "1h", "24h" (default: 1h)
--limit LIMIT Cap at N most-recent rewrites (default: 20)
precc undo
Undo a specific rewrite by its id.
precc undo ID
Revert a rewrite by id: re-disables the skill(s) that produced it.
Arguments:
ID Rewrite id from `precc explain` (16-hex-char hash)
precc recall
Search your cross-session knowledge mindmap.
precc recall QUERY [--kind KIND] [--limit 20]
Search the cross-session knowledge mindmap for past decisions, plans,
commits, blockers, and commands. Case-insensitive substring, newest first.
Arguments:
QUERY Query string
Options:
--kind KIND Restrict to: decision, plan, task, feature, blocker,
commit, command
--limit LIMIT Cap on hits returned (default: 20)
precc audit
Measure the token cost of your context surfaces.
precc audit <claude-md | claudeignore | positioning>
Measure the token cost of context surfaces. No opinions — just numbers.
Subcommands:
claude-md Bytes, estimated tokens, and per-section sizes of
CLAUDE.md (project + ~/.claude).
claudeignore Per-path bytes/tokens a .claudeignore could exclude from
Grep/Glob/Read (node_modules/, dist/, target/, …).
--write appends missing entries.
positioning Which positioning angles are backed by measured numbers.
precc analyze
Find command classes PRECC does not yet cover.
precc analyze frequencies
Count Bash command-class frequencies from session logs and report the
classes PRECC does not yet cover (rule-gap discovery).
Câu hỏi thường gặp
PRECC có an toàn không?
Có. PRECC sử dụng cơ chế hook PreToolUse chính thức của Claude Code – cùng điểm mở rộng mà Anthropic thiết kế cho mục đích này. Hook:
- Chạy hoàn toàn ngoại tuyến (không có lệnh gọi mạng trong đường dẫn nóng)
- Hoàn thành trong dưới 5 mili giây
- Là fail-open: nếu có lỗi, lệnh gốc chạy không thay đổi
- Chỉ sửa đổi lệnh, không bao giờ tự thực thi
- Lưu trữ dữ liệu cục bộ trong cơ sở dữ liệu SQLite
PRECC có hoạt động với các công cụ lập trình AI khác không?
PRECC được thiết kế riêng cho Claude Code. Nó phụ thuộc vào giao thức hook PreToolUse mà Claude Code cung cấp. Nó không hoạt động với Cursor, Copilot, Windsurf hoặc các công cụ lập trình AI khác.
Đo lường từ xa gửi dữ liệu gì?
Đo lường từ xa chỉ hoạt động khi bạn đồng ý. Khi được bật, nó gửi:
- Phiên bản PRECC, hệ điều hành và kiến trúc
- Số liệu tổng hợp (lệnh bị chặn, kỹ năng được kích hoạt)
- Độ trễ hook trung bình
Nó không gửi văn bản lệnh, đường dẫn tệp, tên dự án hoặc bất kỳ thông tin nhận dạng cá nhân nào. Bạn có thể xem trước dữ liệu chính xác với precc telemetry preview trước khi đồng ý. Xem Đo lường từ xa để biết chi tiết.
Làm thế nào để gỡ cài đặt PRECC?
PRECC is fully reversible — remove it in three steps:
-
Xóa đăng ký hook:
# Delete the hook entry from Claude Code's settings # (precc init added it; removing it disables PRECC) -
Xóa tệp nhị phân:
rm ~/.local/bin/precc ~/.local/bin/precc-hook ~/.local/bin/precc-learner -
Xóa dữ liệu (tùy chọn):
rm -rf ~/.local/share/precc/ rm -rf ~/.config/precc/
Giấy phép của tôi đã hết hạn. Điều gì xảy ra?
PRECC trở về tầng Community. Tất cả chức năng cốt lõi tiếp tục hoạt động:
- Các kỹ năng tích hợp vẫn hoạt động
- Pipeline hook chạy bình thường
precc savingshiển thị chế độ xem tóm tắtprecc ingestvà khai thác phiên hoạt động
Các tính năng Pro không khả dụng cho đến khi bạn gia hạn:
precc savings --all(phân tích chi tiết)precc compressprecc gifprecc ghaprecc geofence- Báo cáo qua email
Hook dường như không chạy. Làm thế nào để gỡ lỗi?
Run precc doctor first — it automates every check below. To diagnose by hand:
-
Kiểm tra xem hook đã được đăng ký chưa:
precc init -
Kiểm tra hook thủ công:
echo '{"tool_input":{"command":"cargo build"}}' | precc-hook -
Kiểm tra xem tệp nhị phân có trong PATH không:
which precc-hook -
Kiểm tra cấu hình hook của Claude Code trong
~/.claude/settings.json.
PRECC có làm chậm Claude Code không?
Không. Hook hoàn thành trong dưới 5 mili giây (p99). Điều này không thể cảm nhận được so với thời gian Claude dành cho suy luận và tạo phản hồi.
Tôi có thể sử dụng PRECC trong CI/CD không?
PRECC được thiết kế cho các phiên Claude Code tương tác. Trong CI/CD, không có phiên bản Claude Code nào để hook vào. Tuy nhiên, precc gha có thể phân tích các lần chạy GitHub Actions thất bại từ bất kỳ môi trường nào.
Các kỹ năng khai thác khác gì so với kỹ năng tích hợp?
Các kỹ năng tích hợp được cung cấp cùng PRECC và bao gồm các mẫu sai thư mục phổ biến. Các kỹ năng khai thác được học từ nhật ký phiên cụ thể của bạn – chúng nắm bắt các mẫu riêng biệt cho quy trình làm việc của bạn. Cả hai đều được lưu trữ trong SQLite và được đánh giá giống nhau bởi pipeline hook.
Tôi có thể chia sẻ kỹ năng với nhóm không?
Có. Xuất bất kỳ kỹ năng nào sang TOML với precc skills export NAME và chia sẻ tệp. Các thành viên nhóm có thể đặt nó trong thư mục skills/ hoặc nhập vào cơ sở dữ liệu heuristics.
Why do I see zero tokens saved?
If precc savings reports 0 tokens despite an active Claude Code session burning input/output tokens, the hook is not firing. Three causes account for almost every reported instance:
-
You are on v0.3.42 or v0.3.43. These releases shipped a data-path regression where the hook wrote metrics to a directory that the CLI then read from a different directory — both ran, but the savings number stayed at 0. Fixed in v0.3.44 (data paths routed through
db::data_dir()). Upgrade with:precc update -
Your
settings.jsonis missing the hook entry. Runprecc doctor(available in v0.3.53+). It checks each precondition of the hot path — settings file, hook entry, binary on$PATH, heuristics DB, recent invocations — and reports the first one that fails:precc doctorIf doctor is not available because you are on an older release, run
precc initto (re)register the hook. -
Your session has not yet hit a skill trigger. PRECC only intercepts Bash commands matching one of the active skills. If your session has been pure file editing or pure web fetching against domains not covered by
webfetch-opencli, you have not yet given the hook anything to compress or rewrite. This is normal. Runprecc skills listto see what triggers exist.
If after upgrading and running precc doctor you still see zero savings, file an issue at https://github.com/peri-a-i/precc-cc/issues with the output of precc doctor.
My MCP server (e.g. lean-ctx) is pegging CPU. How do I kill it safely without taking Claude Code down with it?
PRECC does not ship or supervise MCP servers — but this is a recurring trap because some MCP binaries (notably lean-ctx) are also invoked as per-Bash-tool-call wrappers by the Claude Code harness, not just as long-running servers. A naive pkill <name> then matches many short-lived wrappers in addition to the server.
Identify the runaway PID, do not kill by name:
pgrep -f "^lean-ctx$" \
| xargs -I{} ps -o pid,%cpu,etime,args -p {} \
| sort -k2 -nr | head -3
The top row is the long-running server (large etime, high %cpu). Send SIGTERM to only that PID:
kill -TERM <pid>
Avoid these forms, all of which can also kill Claude Code or break in-flight tool calls:
pkill lean-ctx— matches transientlean-ctx -c <cmd>wrappers spawned per Bash tool call.pkill -9 -f lean-ctx— same broad match, plus ungraceful exit leaves the MCP stdio half-open.pkill -g <pgid>/kill -- -<pgid>— kills the whole process group, which includesclaudeitself when the MCP server shares a session with it.
If after a clean SIGTERM the server does not exit within a few seconds, escalate with kill -KILL <pid> on the same single PID (still not by name). Claude Code will lose those MCP tools until you restart it; it should not exit on its own.
This advice is independent of PRECC — but PRECC users frequently run lean-ctx, so it is worth documenting here.
What is OpenCLI and do I need it?
OpenCLI is a third-party Node.js tool that turns ~148 websites into structured-output CLI commands (opencli hackernews top, opencli reddit search <q>, opencli arxiv search <q>, …). PRECC ships two built-in skills that work with it:
webfetch-opencli-hint— fires oncurl/wget/http/fetchagainst any of 11 OpenCLI-supported domains andsuggest_fix-es the equivalentopencli <site> …command. Suggestion only; never modifies the command.webfetch-opencli-hackernews— auto-rewritescurl|wget news.ycombinator.comtoopencli hackernews topwith an inlinecommand -v openclifallback to the original command if OpenCLI isn’t installed.
You don’t need OpenCLI for PRECC to work. The hint skill costs nothing; the auto-rewrite skill is safe to ship default-on because of the fallback.
If you want OpenCLI’s WebFetch token savings, install it with:
precc init --opencli
That runs npm install -g @jackwener/opencli (Node.js 20+ required). For cookie-reuse on logged-in pages, also install OpenCLI’s Chrome extension separately — see the project README. The extension requests broad permissions (debugger, <all_urls>, cookies); review them before installing.
precc doctor reports OpenCLI’s presence on $PATH as an informational line:
i opencli: installed (webfetch-opencli skills will auto-rewrite)
or
i opencli: not installed (run `precc init --opencli` if you want WebFetch token savings)
Never marks doctor as failing — the integration is fully opt-in.