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

บทนำ

PRECC คืออะไร?

PRECC (การแก้ไขข้อผิดพลาดเชิงคาดการณ์สำหรับ Claude Code) คือเครื่องมือ Rust ที่ดักจับคำสั่ง bash ของ Claude Code ผ่านกลไก PreToolUse hook อย่างเป็นทางการ มันแก้ไขข้อผิดพลาดก่อนที่จะเกิดขึ้น ประหยัดโทเค็นและกำจัดวงจรการลองใหม่

ฟรีสำหรับผู้ใช้ชุมชน

ปัญหา

Claude Code สิ้นเปลืองโทเค็นจำนวนมากกับข้อผิดพลาดที่ป้องกันได้:

  • ข้อผิดพลาดไดเรกทอรีผิด – การรัน cargo build ในไดเรกทอรีระดับบนที่ไม่มี Cargo.toml แล้วลองใหม่หลังจากอ่านข้อผิดพลาด
  • วงจรการลองใหม่ – คำสั่งที่ล้มเหลวสร้างเอาต์พุตยาวเหยียด Claude อ่าน วิเคราะห์ และลองใหม่ แต่ละรอบเผาผลาญโทเค็นหลายร้อยตัว
  • เอาต์พุตยาวเหยียด – คำสั่งเช่น find หรือ ls -R ผลิตหลายพันบรรทัดที่ Claude ต้องประมวลผล

สี่เสาหลัก

แก้ไขบริบท (cd-prepend)

ตรวจจับเมื่อคำสั่งเช่น cargo build หรือ npm test ทำงานในไดเรกทอรีผิดและเพิ่ม cd /path/ที่ถูก && ก่อนการทำงาน

การดีบัก GDB

ตรวจจับโอกาสในการแนบ GDB เพื่อการดีบัก segfault และการแครชอย่างลึกซึ้งยิ่งขึ้น โดยให้ข้อมูลดีบักที่มีโครงสร้างแทน core dump ดิบ

การขุดเซสชัน

ขุดบันทึกเซสชันของ Claude Code เพื่อค้นหาคู่ความล้มเหลว-การแก้ไข เมื่อข้อผิดพลาดเดิมเกิดขึ้นซ้ำ PRECC ทราบการแก้ไขแล้วและใช้โดยอัตโนมัติ

ทักษะการทำงานอัตโนมัติ

ห้องสมุดของทักษะในตัวและที่ขุดมาซึ่งจับคู่กับรูปแบบคำสั่งและเขียนใหม่ ทักษะถูกกำหนดเป็นไฟล์ TOML หรือแถว SQLite ทำให้ง่ายต่อการตรวจสอบ แก้ไข และแบ่งปัน

วิธีการทำงาน (เวอร์ชัน 30 วินาที)

  1. Claude Code กำลังจะรันคำสั่ง bash
  2. PreToolUse hook ส่งคำสั่งไปยัง precc-hook เป็น JSON ผ่าน stdin
  3. precc-hook รันคำสั่งผ่านไปป์ไลน์ (ทักษะ, การแก้ไขไดเรกทอรี, การบีบอัด) ในเวลาน้อยกว่า 3 มิลลิวินาที
  4. คำสั่งที่แก้ไขแล้วถูกส่งคืนเป็น JSON ผ่าน stdout
  5. Claude Code รันคำสั่งที่แก้ไขแล้วแทน

ข้อผิดพลาดเล็กน้อยจะถูกยุบรวม; เหตุผลของการเขียนใหม่ติดมากับการตอบสนองของ hook ดังนั้นการแก้ไขแต่ละครั้งจึงตรวจสอบได้ ไม่ใช่เงียบ

ขอบเขตความปลอดภัย

PRECC จะเขียนใหม่เฉพาะเมื่อความเท่าเทียมทางความหมายได้รับการรักษาอย่างพิสูจน์ได้หรือผู้ใช้สามารถตรวจสอบได้ คำสั่งที่ทำลาย (rm, git push --force, git reset --hard) จะไม่ถูกเขียนใหม่เด็ดขาด แม้ว่าทักษะจะตรงกัน การเปลี่ยนแปลงทุกครั้งต้องมีขอบเขต — คำสั่งที่เขียนใหม่ต้องมีโทเค็นหลักของคำสั่งเดิม การเขียนใหม่ที่ไม่มีขอบเขตจะถูกย้อนกลับโดยอัตโนมัติ การเขียนใหม่ทุกครั้งจะถูกบันทึกและแสดงให้คุณตรวจสอบ ปิดใช้งาน หรือยกเลิกได้

การบีบอัดแบบปรับตัว

หากคำสั่งล้มเหลวหลังจากการบีบอัด PRECC จะข้ามการบีบอัดในการลองใหม่โดยอัตโนมัติ เพื่อให้ Claude ได้เอาต์พุตเต็มสำหรับการดีบัก

สถิติการใช้งานสด

เวอร์ชันปัจจุบัน :

ตัวชี้วัดค่า
โทเค็นที่ประหยัดได้
อัตราการประหยัด%
เวลาแฝงของ hook ms (p50)
ผู้ใช้
crates.io downloads

crates.io downloads count CI, docs.rs and mirror traffic — they are not a measure of unique users.

การประหยัดตามรุ่น

ตัวเลขเหล่านี้อัปเดตโดยอัตโนมัติจากการวัดระยะไกลแบบไม่ระบุตัวตน

ลิงก์

การติดตั้ง

ติดตั้งด่วน (Linux / macOS)

curl -fsSL https://peria.ai/install.sh | bash

คำสั่งนี้จะดาวน์โหลดไบนารีเวอร์ชันล่าสุดสำหรับแพลตฟอร์มของคุณ ตรวจสอบ SHA256 checksum และวางไว้ใน ~/.local/bin/

หลังจากติดตั้งแล้ว ให้เริ่มต้น PRECC:

precc init

precc init ลงทะเบียน hook PreToolUse กับ Claude Code สร้างไดเรกทอรีข้อมูล และเริ่มต้นฐานข้อมูลทักษะ

ตัวเลือกการติดตั้ง

การตรวจสอบ SHA256

ตามค่าเริ่มต้น ตัวติดตั้งจะตรวจสอบ checksum ของไบนารีกับ SHA256 ที่เผยแพร่ หากต้องการข้ามการตรวจสอบ (ไม่แนะนำ):

curl -fsSL https://peria.ai/install.sh | bash -s -- --no-verify

คำนำหน้าการติดตั้งแบบกำหนดเอง

ติดตั้งในตำแหน่งที่กำหนดเอง:

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.

เครื่องมือเสริม (–extras)

PRECC มาพร้อมกับเครื่องมือเสริมที่เลือกได้ ติดตั้งด้วย --extras:

curl -fsSL https://peria.ai/install.sh | bash -s -- --extras

คำสั่งนี้จะติดตั้ง:

เครื่องมือวัตถุประสงค์
RTKชุดเครื่องมือเขียนคำสั่งใหม่
lean-ctxการบีบอัดบริบทสำหรับ CLAUDE.md และไฟล์ prompt
nushellเชลล์แบบมีโครงสร้างสำหรับ pipeline ขั้นสูง
cocoindex-codeการจัดทำดัชนีโค้ดเพื่อการแก้ไขบริบทที่เร็วขึ้น

Windows (PowerShell)

irm https://peria.ai/install.ps1 | iex

จากนั้นเริ่มต้น:

precc init

การติดตั้งด้วยตนเอง

  1. ดาวน์โหลดไบนารีสำหรับแพลตฟอร์มของคุณจาก GitHub Releases
  2. ตรวจสอบ SHA256 checksum กับไฟล์ .sha256 ในรุ่นที่เผยแพร่
  3. วางไบนารีในไดเรกทอรีบน PATH ของคุณ (เช่น ~/.local/bin/)
  4. รัน precc init

การอัปเดต

precc update

บังคับอัปเดตเป็นเวอร์ชันเฉพาะ:

precc update --force --version 0.3.0

เปิดใช้งานการอัปเดตอัตโนมัติ:

precc update --auto

การติดตั้งภายใต้ OpenClaw / ClawHub

PRECC มาพร้อมไฟล์ manifest ของปลั๊กอินที่ plugins/openclaw/openclaw.plugin.json (id precc-token-saver) เมื่อมีการเผยแพร่รุ่นสาธารณะ เวิร์กโฟลว์ GitHub Actions clawhub-publish.yml จะส่งชุด skill ไปยังรีจิสทรีของ ClawHub เพื่อให้ผู้ใช้ปลายทางสามารถติดตั้ง PRECC ผ่าน CLI ของ ClawHub แทนการใช้ตัวติดตั้ง 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.

การแสดงผลการประหยัดภายใต้ OpenClaw

ทุกหน้ารายงานของ PRECC ที่ทำงานภายใต้ Claude Code ก็ทำงานภายใต้ OpenClaw เช่นกัน — precc savings, precc savings --all, แถบสถานะที่แปลเป็นภาษาท้องถิ่น (ตั้งค่า PRECC_LANG=zh แล้วแถบจะแสดงในภาษาของคุณ) และบันทึกตรวจสอบการเขียนใหม่ภายในเครื่อง ล้วนอ่านจากฐานข้อมูล SQLCipher เดียวกันบนเครื่องของคุณ ข้อกำหนดแยกต่างหากที่ docs/symposium-plan/openclaw-savings-reporting.md อธิบายฟิลด์ preccSavings แบบมีโครงสร้างในการตอบกลับของ hook ทุกครั้ง พร้อมการแจ้งเตือนสิ้นสุดเซสชันบรรทัดเดียวที่เกณฑ์เริ่มต้น $0.05 ในอนาคต ส่วนนี้ยังไม่ได้เผยแพร่

การตรวจสอบการติดตั้ง

$ precc --version
precc 0.3.0

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

หากไม่พบ precc ให้ตรวจสอบว่า ~/.local/bin อยู่ใน PATH ของคุณ

เริ่มต้นอย่างรวดเร็ว

เริ่มใช้งาน PRECC ใน 5 นาที

ขั้นตอนที่ 1: ติดตั้ง

curl -fsSL https://peria.ai/install.sh | bash

ขั้นตอนที่ 2: เริ่มต้นระบบ

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

ขั้นตอนที่ 3: ตรวจสอบว่า hook ทำงานอยู่

$ 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

ขั้นตอนที่ 4: ใช้ Claude Code ตามปกติ

เปิด Claude Code แล้วทำงานตามปกติ PRECC ทำงานอยู่เบื้องหลังอย่างเงียบๆ เมื่อ Claude ออกคำสั่งที่จะล้มเหลว PRECC จะแก้ไขก่อนการดำเนินการ

ตัวอย่าง: Cargo Build ในไดเรกทอรีที่ผิด

สมมติว่าโปรเจกต์ของคุณอยู่ที่ ~/projects/myapp/ และ Claude ออกคำสั่ง:

cargo build

จาก ~/projects/ (สูงกว่าหนึ่งระดับ ไม่มี Cargo.toml ที่นั่น)

ไม่มี PRECC: Claude ได้รับข้อผิดพลาด could not find Cargo.toml in /home/user/projects or any parent directory อ่าน วิเคราะห์ แล้วลองใหม่ด้วย cd myapp && cargo build ค่าใช้จ่าย: ~2,000 โทเค็นสูญเปล่า

ใช้ PRECC: hook ตรวจพบว่าไม่มี Cargo.toml หาเจอใน myapp/ และเขียนคำสั่งใหม่เป็น:

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

Claude ไม่เห็นข้อผิดพลาดเลย ไม่มีโทเค็นสูญเปล่า

ขั้นตอนที่ 5: ตรวจสอบการประหยัดของคุณ

หลังจากเซสชัน ดูว่า PRECC ประหยัดโทเค็นได้เท่าไหร่:

$ 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)

ขั้นตอนถัดไป

  • ทักษะ – ดูทักษะทั้งหมดที่มีและวิธีสร้างทักษะของคุณเอง
  • Hook Pipeline – เข้าใจว่าเกิดอะไรขึ้นเบื้องหลัง
  • การประหยัด – การวิเคราะห์การประหยัดโทเค็นอย่างละเอียด

ใบอนุญาต

PRECC เสนอสองระดับ: Community (ฟรี) และ Pro

ระดับ Community (ฟรี)

ระดับ Community ประกอบด้วย:

  • ทักษะในตัวทั้งหมด (แก้ไขไดเรกทอรีผิด, แปล jj ฯลฯ)
  • ท่อ hook ที่รองรับ Pillar 1 และ Pillar 4 อย่างเต็มที่
  • สรุปพื้นฐานของ precc savings
  • การขุดเซสชันด้วย precc ingest
  • ใช้งานในเครื่องไม่จำกัด

ระดับ Pro

Pro ปลดล็อกฟีเจอร์เพิ่มเติม:

  • รายละเอียดการประหยัดprecc savings --all พร้อมการวิเคราะห์ต่อคำสั่ง
  • บันทึก GIFprecc gif สำหรับสร้าง GIF แอนิเมชันของเทอร์มินัล
  • การปฏิบัติตาม IP geofence – สำหรับสภาพแวดล้อมที่ถูกควบคุม
  • รายงานอีเมลprecc mail report เพื่อส่งการวิเคราะห์
  • การวิเคราะห์ GitHub Actionsprecc gha สำหรับการแก้จุดบกพร่องของเวิร์กโฟลว์ที่ล้มเหลว
  • การบีบอัดบริบทprecc compress สำหรับการเพิ่มประสิทธิภาพ CLAUDE.md
  • การสนับสนุนแบบเร่งด่วน

การเปิดใช้งานใบอนุญาต

$ 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

ตรวจสอบสถานะใบอนุญาต

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

การเปิดใช้งาน GitHub Sponsors

หากคุณสนับสนุน PRECC ผ่าน GitHub Sponsors ใบอนุญาตจะถูกเปิดใช้งานโดยอัตโนมัติผ่านอีเมล GitHub ของคุณ ไม่ต้องใช้คีย์ – แค่ให้แน่ใจว่าอีเมลผู้สนับสนุนตรงกัน:

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

ลายนิ้วมืออุปกรณ์

ใบอนุญาตแต่ละใบผูกกับลายนิ้วมืออุปกรณ์ ดูของคุณด้วย:

$ precc license fingerprint
Fingerprint: a1b2c3d4e5f6...

หากต้องการโอนใบอนุญาตไปยังเครื่องใหม่ ให้ยกเลิกการเปิดใช้งานก่อน:

precc license deactivate

จากนั้นเปิดใช้งานบนเครื่องใหม่

ใบอนุญาตหมดอายุ?

เมื่อใบอนุญาต Pro หมดอายุ PRECC จะกลับไปที่ระดับ Community ทักษะในตัวและฟังก์ชันหลักทั้งหมดยังคงทำงานต่อไป เฉพาะฟีเจอร์เฉพาะ Pro เท่านั้นที่จะใช้ไม่ได้ ดู FAQ สำหรับรายละเอียดเพิ่มเติม

ไปป์ไลน์ Hook

ไบนารี precc-hook เป็นแกนหลักของ PRECC อยู่ระหว่าง Claude Code กับ shell ประมวลผลทุกคำสั่ง bash ภายใน 5 มิลลิวินาที

วิธีที่ Claude Code เรียกใช้ Hook

Claude Code รองรับ hook PreToolUse – โปรแกรมภายนอกที่สามารถตรวจสอบและแก้ไขอินพุตของเครื่องมือก่อนการทำงาน เมื่อ Claude กำลังจะรันคำสั่ง bash จะส่ง JSON ไปยัง precc-hook ผ่าน stdin และอ่านผลลัพธ์จาก stdout

ขั้นตอน 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

ตัวอย่าง: อินพุตและเอาต์พุต JSON

อินพุต (จาก Claude Code)

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

PRECC ตรวจพบว่าไดเรกทอรีปัจจุบันไม่มี Cargo.toml แต่ ./myapp/Cargo.toml มีอยู่

เอาต์พุต (ไปยัง Claude Code)

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

หากไม่จำเป็นต้องแก้ไข updatedInput.command จะว่างเปล่าและ Claude Code จะใช้คำสั่งเดิม

รายละเอียดขั้นตอน

ขั้นตอนที่ 1: แยกวิเคราะห์ JSON

อ่านอ็อบเจกต์ JSON ทั้งหมดจาก stdin ดึงค่า tool_input.command หากการแยกวิเคราะห์ล้มเหลว hook จะออกทันทีและ Claude Code จะใช้คำสั่งเดิม (การออกแบบ fail-open)

ขั้นตอนที่ 2: การจับคู่ Skill

สอบถามฐานข้อมูล heuristic ของ SQLite เพื่อหา skill ที่มีรูปแบบทริกเกอร์ตรงกับคำสั่ง ตรวจสอบ skill ตามลำดับความสำคัญ ทั้ง skill TOML ในตัวและ skill ที่ขุดได้จะถูกประเมิน

ขั้นตอนที่ 3: การแก้ไขไดเรกทอรี

สำหรับคำสั่ง build (cargo, go, make, npm, python ฯลฯ) ตรวจสอบว่าไฟล์โปรเจกต์ที่คาดหวังมีอยู่ในไดเรกทอรีปัจจุบันหรือไม่ หากไม่มี จะสแกนไดเรกทอรีใกล้เคียงเพื่อหาผลลัพธ์ที่ตรงที่สุดและเติม cd <dir> && ข้างหน้า

การสแกนไดเรกทอรีใช้ดัชนีระบบไฟล์ที่แคชไว้โดยมี TTL 5 วินาทีเพื่อรักษาความเร็ว

ขั้นตอนที่ 4: ตรวจสอบ GDB

หากคำสั่งมีแนวโน้มที่จะทำให้เกิด crash (เช่น รัน debug binary) PRECC สามารถแนะนำหรือแทรก GDB wrapper เพื่อจับเอาต์พุต debug แบบมีโครงสร้างแทน crash log ดิบ

ขั้นตอนที่ 5: การเขียนใหม่ RTK

ใช้กฎ RTK (Rewrite Toolkit) ที่ย่อคำสั่งที่ยาว ระงับเอาต์พุตที่มีเสียงรบกวน หรือปรับโครงสร้างคำสั่งเพื่อประสิทธิภาพของ token

ขั้นตอนที่ 6: ส่งออก JSON

ซีเรียลไลซ์คำสั่งที่แก้ไขกลับเป็น JSON และเขียนลง stdout หากไม่มีการเปลี่ยนแปลง เอาต์พุตจะส่งสัญญาณให้ Claude Code ใช้คำสั่งเดิม

ประสิทธิภาพ

ไปป์ไลน์ทั้งหมดเสร็จสิ้นภายใน 5 มิลลิวินาที (p99) การเพิ่มประสิทธิภาพหลัก:

  • SQLite ในโหมด WAL สำหรับการอ่านพร้อมกันแบบไม่ล็อก
  • รูปแบบ regex ที่คอมไพล์ล่วงหน้าสำหรับการจับคู่ skill
  • การสแกนระบบไฟล์ที่แคชไว้ (TTL 5 วินาที)
  • ไม่มีการเรียกเครือข่ายใน hot path
  • Fail-open: ข้อผิดพลาดใดๆ จะกลับไปใช้คำสั่งเดิม

ทดสอบ Hook ด้วยตนเอง

คุณสามารถเรียกใช้ hook โดยตรง:

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

ทักษะ

ทักษะคือกฎการจับคู่รูปแบบที่ PRECC ใช้เพื่อตรวจจับและแก้ไขคำสั่ง สามารถเป็นแบบในตัว (จัดส่งเป็นไฟล์ TOML) หรือขุดจากบันทึกเซสชัน

ทักษะในตัว

ทักษะทริกเกอร์เมื่อการดำเนินการ
cargo-wrong-dircargo build/test/clippy นอกโปรเจกต์ Rustเพิ่ม cd ไปยังไดเรกทอรี Cargo.toml ที่ใกล้ที่สุด
git-wrong-dirgit * นอกรีโพ gitเพิ่ม cd ไปยังไดเรกทอรี .git ที่ใกล้ที่สุด
go-wrong-dirgo build/test นอกโมดูล Goเพิ่ม cd ไปยังไดเรกทอรี go.mod ที่ใกล้ที่สุด
make-wrong-dirmake โดยไม่มี Makefile ในไดเรกทอรีปัจจุบันเพิ่ม cd ไปยังไดเรกทอรี Makefile ที่ใกล้ที่สุด
npm-wrong-dirnpm/npx/pnpm/yarn นอกโปรเจกต์ Nodeเพิ่ม cd ไปยังไดเรกทอรี package.json ที่ใกล้ที่สุด
python-wrong-dirpython/pytest/pip นอกโปรเจกต์ Pythonเพิ่ม cd ไปยังโปรเจกต์ Python ที่ใกล้ที่สุด
jj-translategit * ในรีโพ jj ที่อยู่ร่วมกันเขียนใหม่เป็นคำสั่ง jj ที่เทียบเท่า
asciinema-gifasciinema recเขียนใหม่เป็น precc gif

แสดงรายการทักษะ

$ 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

แสดงรายละเอียดทักษะ

$ 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

ส่งออกทักษะเป็น 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

แก้ไขทักษะ

$ precc skills edit cargo-wrong-dir

คำสั่งนี้เปิดคำจำกัดความทักษะใน $EDITOR ของคุณ หลังจากบันทึก ทักษะจะถูกโหลดใหม่โดยอัตโนมัติ

คำสั่ง Advise

precc skills advise วิเคราะห์เซสชันล่าสุดของคุณและแนะนำทักษะใหม่ตามรูปแบบที่ซ้ำกัน:

$ 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]?

การจัดกลุ่มทักษะ

$ precc skills cluster

จัดกลุ่มทักษะที่ขุดได้ที่คล้ายกันเพื่อช่วยระบุรูปแบบที่ซ้ำซ้อนหรือทับซ้อนกัน

ทักษะที่ขุดได้เทียบกับทักษะในตัว

ทักษะในตัวมาพร้อมกับ PRECC และถูกกำหนดใน skills/builtin/*.toml ครอบคลุมข้อผิดพลาดไดเรกทอรีผิดที่พบบ่อยที่สุด

ทักษะที่ขุดได้ถูกสร้างโดย precc ingest หรือ daemon precc-learner จากบันทึกเซสชันของคุณ ถูกเก็บใน ~/.local/share/precc/heuristics.db และเฉพาะเจาะจงกับเวิร์กโฟลว์ของคุณ ดู การขุด สำหรับรายละเอียด

การประหยัด

PRECC ติดตามการประหยัดโทเค็นโดยประมาณจากทุกการสกัดกั้น ใช้ precc savings เพื่อดูว่า PRECC ป้องกันการสูญเสียได้เท่าไร

สรุปย่อ

$ 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)

รายละเอียด (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>%

วิธีประมาณการประหยัด

การแก้ไขแต่ละประเภทมีค่าโทเค็นโดยประมาณตามสิ่งที่จะเกิดขึ้นหากไม่มี PRECC:

ประเภทการแก้ไขการประหยัดโดยประมาณเหตุผล
cd prepend~500 tokensผลลัพธ์ข้อผิดพลาด + การให้เหตุผลของ Claude + ลองใหม่
การเปิดใช้ทักษะ~400 tokensผลลัพธ์ข้อผิดพลาด + การให้เหตุผลของ Claude + ลองใหม่
RTK rewrite~250 tokensผลลัพธ์ยาวที่ Claude ต้องอ่าน
Lean-ctx wrap~600 tokensเนื้อหาไฟล์ขนาดใหญ่ถูกบีบอัด
การป้องกันที่ขุดค้น~500 tokensหลีกเลี่ยงรูปแบบความล้มเหลวที่รู้จัก

นี่เป็นการประมาณการแบบอนุรักษ์นิยม การประหยัดจริงมักสูงกว่าเพราะการให้เหตุผลของ Claude เกี่ยวกับข้อผิดพลาดอาจยาว

การประหยัดสะสม

การประหยัดจะคงอยู่ข้ามเซสชันในฐานข้อมูล PRECC เมื่อเวลาผ่านไปคุณสามารถติดตามผลกระทบทั้งหมด:

$ 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

แถบสถานะ

หลังการติดตั้ง PRECC จะเพิ่มรายการ statusLine ลงใน ~/.claude/settings.json เพื่อให้แถบสถานะของ Claude Code แสดงเมตริกเซสชันแบบสด:

$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)

ตั้งค่า PRECC_LANG เพื่อแสดงป้ายกำกับเป็นภาษาของคุณ — ดูบทการแปล

แต่ละส่วน:

ส่วนแหล่งที่มาความหมายรีเซ็ตเมื่อเริ่มเซสชันใหม่หรือไม่?
$0.42 spentcost.total_cost_usdค่าใช้จ่ายเซสชันสะสมที่ Claude Code รายงานใช่
1.2M in/outtotal_input_tokens + total_output_tokensโทเคนอินพุต (ไม่แคช) + เอาต์พุตตลอดเซสชันใช่
📊 last cmd: −1.2Kการวัดของ PRECC สำหรับคำสั่ง Bash ล่าสุดการประหยัดจริงที่วัดได้จากการรันคำสั่งเดิมใหม่ไม่ (คงอยู่ข้ามเซสชัน)
PRECC: 7 fixesmetrics.logจำนวนการแก้ไขในเซสชันนี้ — นับจำนวนเท่านั้น ไม่มีการประมาณโทเคนปลอมใช่
5.8ms avgความหน่วงของ PRECC hook p50เวลาที่ PRECC ใช้ในการประมวลผลการเรียกเครื่องมือแต่ละครั้งใช่
bash 18% of totalpost_observations.logสัดส่วนโทเคนเซสชันที่มาจากเอาต์พุต Bash — อธิบายว่าทำไมการประหยัดของ PRECC จึงเป็นเพียงส่วนหนึ่งของต้นทุนทั้งหมดโดยธรรมชาติ (PRECC ปรับปรุงเฉพาะเอาต์พุต Bash)ใช่
this session: 320 saved over 7 cmds (~$0.05).lifetime_summary.json − baselineเดลตาจริงต่อเซสชัน ซ่อนเมื่อเดลตาเป็นศูนย์ (เริ่มเซสชัน)ใช่ (ฐานข้อมูลถูกบันทึกใหม่)
lifetime: 8.9K saved over 217 cmds (~$2.85).lifetime_summary.jsonโทเคนสะสมที่ประหยัดได้และคำสั่งที่วัดซ้ำตั้งแต่ติดตั้ง PRECC ครั้งแรก พร้อมมูลค่าโดยประมาณเป็น USD ตามอัตราต่อโทเคนปัจจุบันไม่

ส่วน lifetime: ถูกวางไว้ท้ายสุด เพื่อให้เป็นส่วนแรกที่ถูกตัดเมื่อ UI ของ Claude Code ตัดแถบที่ขอบขวา

ทำไมค่าใช้จ่ายกับจำนวนโทเคนถึงหารกันไม่ได้

1.2M in/out ที่แสดง ไม่ใช่ ตัวส่วนที่ทำให้ได้ $0.42 spent cost.total_cost_usd ของ Claude Code คำนวณจากการแยกย่อยโทเคนเต็มรูปแบบของ API — อินพุตพื้นฐาน เอาต์พุต บวกการอ่านแคชและการสร้างแคช จำนวนโทเคนแคชสะสมตลอดเซสชันไม่ได้เปิดเผยในสคีมา statusline ดังนั้น PRECC จึงแสดงได้เฉพาะส่วนที่มองเห็นได้ (ไม่ใช่แคช)

ในเซสชันยาวที่มีการอ่านไฟล์ซ้ำมาก การอ่านแคชอาจสูงถึง 10 เท่าของจำนวนโทเคนที่มองเห็นได้ นั่นคือเหตุผลที่การจับคู่ทั้งสองเป็นอัตราส่วนจะทำให้เข้าใจผิด — PRECC จึงแสดงเป็นส่วนอิสระแทน

ทำไม PRECC ถึงไม่คำนวณค่าใช้จ่าย

ตัวเลขค่าใช้จ่ายเป็นค่าที่เชื่อถือได้ PRECC อ่าน cost.total_cost_usd ตามตัวอักษรจาก JSON ที่ Claude Code ส่งผ่าน stdin ไปยังคำสั่งสถานะ นั่นคือตัวเลขเดียวกันกับที่ Claude Code หักจากงบสมัครสมาชิก/การใช้งานของคุณ คุณสามารถตรวจสอบเมื่อใดก็ได้ด้วยคำสั่งสแลชในตัว /cost — ทั้งสองค่าควรตรงกัน

อะไรที่ขับเคลื่อนค่าใช้จ่าย

สำหรับ Claude Opus 4.6:

Token typeStandard (≤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

ปัจจัยที่ขับเคลื่อนค่าใช้จ่ายมากที่สุดในเซสชันยาวมักคือโทเคนเอาต์พุต (ประเภทที่แพงที่สุดต่อโทเคน โดยเฉพาะที่ระดับบริบท 1M) การอ่านแคชซ้ำๆ (แต่ละครั้งราคาถูกแต่สะสมเร็วในหลายเทิร์น) และการสร้างแคช (เขียนหนึ่งครั้งต่อการอ่านไฟล์ที่ ~1.25× อัตราอินพุตพื้นฐาน) PRECC ลดต้นทุนโทเคนที่มองเห็นได้โดยการบีบอัดเอาต์พุต Bash (ส่วน 📊 last cmd: แสดงการประหยัดต่อคำสั่ง) แต่ไม่สามารถลดการอ่านแคชของไฟล์ที่ Claude โหลดไว้แล้วได้

การนับเซสชันที่เสถียร

ส่วน “PRECC: N fixes” จะนับเหตุการณ์ตั้งแต่จุดเริ่มเซสชันที่ คงอยู่ ซึ่งเขียนลงใน ~/.local/share/precc/sessions/<session_id>.start ในการรีเฟรช statusline ครั้งแรกของแต่ละเซสชัน ทำให้การนับเป็นแบบโมโนโทน — ไม่สามารถลดลงกลางเซสชันได้แม้ว่า cost.total_duration_ms จะหายไปในการรีเฟรชหนึ่งๆ

สแน็ปช็อตตลอดอายุที่รีเฟรชอัตโนมัติ

ส่วน lifetime: อ่าน ~/.local/share/precc/.lifetime_summary.json ซึ่งจะถูกเขียนใหม่ทุกครั้งที่มีการวัด PostToolUse และทุกครั้งที่เรียก precc savings ส่วน this session: อ่านไฟล์ lifetime เดียวกันแต่ลบเส้นฐานต่อเซสชันที่เก็บไว้ในการรีเฟรชครั้งแรกของแต่ละเซสชัน ไม่ต้องรีเฟรชด้วยตนเอง — ไฟล์อัปเดตตัวเอง

การปิดแถบสถานะ

หากคุณต้องการเก็บแถบสถานะที่มีอยู่ ให้ตั้งคำสั่ง statusLine ของคุณเองใน ~/.claude/settings.json ตัวติดตั้ง PRECC จะตรวจพบค่าที่กำหนดเองและไม่แตะต้องมันในการอัปเดตครั้งต่อๆ ไป

หากต้องการระงับเฉพาะบรรทัด 📊 PRECC ต่อการโต้ตอบ (ใน additionalContext) ให้ตั้งค่า PRECC_QUIET=1 ในสภาพแวดล้อม shell ของคุณ

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-ctx wrapping) — 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.

การบีบอัด

precc compress ย่อ CLAUDE.md และไฟล์บริบทอื่นๆ เพื่อลดการใช้โทเค็นเมื่อ Claude Code โหลดไฟล์เหล่านั้น นี่เป็นฟีเจอร์ Pro

การใช้งานพื้นฐาน

$ 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.

ทดลองรัน

ดูตัวอย่างสิ่งที่จะเปลี่ยนแปลงโดยไม่แก้ไขไฟล์:

$ 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%)

การย้อนกลับ

ไฟล์ต้นฉบับจะถูกสำรองโดยอัตโนมัติ เพื่อกู้คืน:

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

อะไรถูกบีบอัด

ตัวบีบอัดใช้การแปลงหลายอย่าง:

  • ลบช่องว่างและบรรทัดว่างที่ซ้ำซ้อน
  • ย่อข้อความที่ยืดยาวโดยรักษาความหมาย
  • ย่อตารางและรายการ
  • ลบความคิดเห็นและการจัดรูปแบบตกแต่ง
  • รักษาบล็อกโค้ด เส้นทาง และตัวระบุทางเทคนิคทั้งหมด

ผลลัพธ์ที่บีบอัดยังคงอ่านได้โดยมนุษย์ – ไม่ได้ถูกย่อหรือทำให้สับสน

กำหนดเป้าหมายไฟล์เฉพาะ

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

รายงาน

precc report สร้างแดชบอร์ดวิเคราะห์ที่สรุปกิจกรรม PRECC และการประหยัดโทเค็น

การสร้างรายงาน

$ 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
  ...

ส่งรายงานทางอีเมล

ส่งรายงานไปยังที่อยู่อีเมล (ต้องตั้งค่าอีเมล ดู Email):

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

ที่อยู่ผู้รับอ่านจาก ~/.config/precc/mail.toml คุณยังสามารถใช้ precc mail report EMAIL เพื่อส่งไปยังที่อยู่เฉพาะ

ข้อมูลรายงาน

รายงานสร้างจากฐานข้อมูล PRECC ในเครื่องที่ ~/.local/share/precc/history.db ไม่มีข้อมูลออกจากเครื่องของคุณเว้นแต่คุณจะส่งรายงานทางอีเมลอย่างชัดเจน

การขุด

PRECC ขุดค้นล็อกเซสชัน Claude Code เพื่อเรียนรู้รูปแบบข้อผิดพลาด-แก้ไข เมื่อพบข้อผิดพลาดเดิมอีกครั้ง จะแก้ไขโดยอัตโนมัติ

การนำเข้าล็อกเซสชัน

นำเข้าไฟล์เดียว

$ 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

นำเข้าล็อกทั้งหมด

$ 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

บังคับนำเข้าใหม่

เพื่อประมวลผลไฟล์ที่นำเข้าแล้วอีกครั้ง:

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

การขุดทำงานอย่างไร

  1. PRECC อ่านไฟล์ล็อก JSONL ของเซสชัน
  2. ระบุคู่คำสั่งที่คำสั่งแรกล้มเหลวและคำสั่งที่สองเป็นการลองใหม่ที่แก้ไขแล้ว
  3. แยกรูปแบบ (อะไรผิดพลาด) และการแก้ไข (Claude ทำอะไรต่างไป)
  4. รูปแบบถูกเก็บใน ~/.local/share/precc/history.db
  5. เมื่อรูปแบบถึงเกณฑ์ความเชื่อมั่น จะกลายเป็นทักษะที่ขุดได้ใน heuristics.db

ตัวอย่างรูปแบบ

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 ทำงานเบื้องหลังและเฝ้าดูล็อกเซสชันใหม่โดยอัตโนมัติ:

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

Daemon ใช้การแจ้งเตือนระบบไฟล์ (inotify บน Linux, FSEvents บน macOS) จึงตอบสนองทันทีเมื่อเซสชันสิ้นสุด

จากรูปแบบสู่ทักษะ

รูปแบบที่ขุดได้จะเลื่อนขั้นเป็นทักษะเมื่อตรงตามเกณฑ์เหล่านี้:

  • พบอย่างน้อย 3 ครั้งข้ามเซสชัน
  • รูปแบบการแก้ไขสม่ำเสมอ (การแก้ไขประเภทเดียวกันทุกครั้ง)
  • ไม่พบผลบวกปลอม

คุณสามารถตรวจสอบผู้สมัครทักษะได้ด้วย:

$ precc skills advise

ดู Skills สำหรับรายละเอียดการจัดการทักษะ

การจัดเก็บข้อมูล

  • คู่ข้อผิดพลาด-แก้ไข: ~/.local/share/precc/history.db
  • ทักษะที่เลื่อนขั้น: ~/.local/share/precc/heuristics.db

ทั้งสองเป็นฐานข้อมูล SQLite ในโหมด WAL เพื่อการเข้าถึงพร้อมกันอย่างปลอดภัย

อีเมล

PRECC สามารถส่งรายงานและไฟล์ทางอีเมลได้ ต้องตั้งค่า SMTP ครั้งเดียว

การตั้งค่า

$ 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.

ไฟล์การกำหนดค่า

การกำหนดค่าถูกเก็บไว้ที่ ~/.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

คุณสามารถแก้ไขไฟล์นี้ได้โดยตรง:

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

สำหรับ Gmail ให้ใช้ รหัสผ่านแอป แทนรหัสผ่านบัญชี

การส่งรายงาน

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

การส่งไฟล์

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

การรองรับรีเลย์ SSH

หากเครื่องของคุณไม่สามารถเข้าถึงเซิร์ฟเวอร์ SMTP ได้โดยตรง (เช่น อยู่หลังไฟร์วอลล์ขององค์กร) PRECC รองรับการรีเลย์ผ่านอุโมงค์ SSH:

[smtp]
host = "localhost"
port = 2525

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

PRECC จะสร้างอุโมงค์ SSH โดยอัตโนมัติก่อนส่ง

การบันทึก GIF

precc gif สร้างการบันทึก GIF แบบเคลื่อนไหวของเซสชันเทอร์มินัลจากสคริปต์ bash นี่เป็นฟีเจอร์ Pro

การใช้งานพื้นฐาน

$ 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)

อาร์กิวเมนต์แรกเป็นสคริปต์ bash ที่มีคำสั่งที่จะรัน อาร์กิวเมนต์ที่สองคือความยาวการบันทึกสูงสุด

รูปแบบสคริปต์

สคริปต์เป็นไฟล์ bash มาตรฐาน:

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

การจำลองอินพุต

สำหรับคำสั่งแบบโต้ตอบ ให้ระบุค่าอินพุตเป็นอาร์กิวเมนต์เพิ่มเติม:

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

อาร์กิวเมนต์เพิ่มเติมแต่ละตัวจะถูกป้อนเป็นบรรทัด stdin เมื่อสคริปต์ร้องขออินพุต

ตัวเลือกเอาต์พุต

ไฟล์เอาต์พุตจะตั้งชื่อตามสคริปต์เป็นค่าเริ่มต้น (script.gif) GIF ใช้ธีมเทอร์มินัลสีเข้มขนาดมาตรฐาน 80x24

ทำไมต้อง GIF แทน asciinema?

ทักษะในตัว asciinema-gif จะเขียนใหม่ asciinema rec เป็น precc gif โดยอัตโนมัติ ไฟล์ GIF พกพาได้ง่ายกว่า – แสดงแบบอินไลน์ใน GitHub README, Slack และอีเมลโดยไม่ต้องใช้โปรแกรมเล่น

การวิเคราะห์ GitHub Actions

precc gha วิเคราะห์การรัน GitHub Actions ที่ล้มเหลวและแนะนำวิธีแก้ไข นี่เป็นฟีเจอร์ Pro

การใช้งาน

ส่ง URL ของการรัน GitHub Actions ที่ล้มเหลว:

$ 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

ทำอะไร

  1. แยกวิเคราะห์ URL การรัน GitHub Actions เพื่อดึงเจ้าของ, repo และ ID การรัน
  2. ดึงบันทึกการรันผ่าน GitHub API (ใช้ GITHUB_TOKEN หากตั้งค่าไว้ มิฉะนั้นเข้าถึงแบบสาธารณะ)
  3. ระบุขั้นตอนที่ล้มเหลวและดึงบรรทัดข้อผิดพลาดที่เกี่ยวข้อง
  4. วิเคราะห์ข้อผิดพลาดและแนะนำวิธีแก้ไขตามรูปแบบความล้มเหลว CI ทั่วไป

รูปแบบความล้มเหลวที่รองรับ

  • คอนเทนเนอร์บริการที่ขาดหายไป (ฐานข้อมูล, Redis ฯลฯ)
  • ระบบปฏิบัติการหรือสถาปัตยกรรม runner ไม่ถูกต้อง
  • ตัวแปรสภาพแวดล้อมหรือ secrets ที่ขาดหายไป
  • การติดตั้ง dependency ล้มเหลว
  • การทดสอบหมดเวลา
  • ข้อผิดพลาดด้านสิทธิ์
  • แคชพลาดทำให้ build ช้า

รั้วภูมิศาสตร์

PRECC รวมการตรวจสอบการปฏิบัติตาม IP geofence สำหรับสภาพแวดล้อมที่มีการควบคุม นี่เป็นฟีเจอร์ Pro

ภาพรวม

บางองค์กรกำหนดให้เครื่องมือพัฒนาทำงานเฉพาะในภูมิภาคที่ได้รับอนุมัติเท่านั้น ฟีเจอร์ geofence ของ PRECC จะตรวจสอบว่าที่อยู่ IP ของเครื่องปัจจุบันอยู่ในรายการภูมิภาคที่อนุญาต

การตรวจสอบการปฏิบัติตาม

$ 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

หากเครื่องอยู่นอกภูมิภาคที่อนุญาต:

$ 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.

การรีเฟรชข้อมูล geofence

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

ดูข้อมูล geofence

$ 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

การล้างแคช

$ precc geofence clear
[precc] Geofence cache cleared.

การกำหนดค่า

นโยบาย geofence ถูกกำหนดใน ~/.config/precc/geofence.toml:

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

ตั้งค่า block_on_violation = true เพื่อป้องกันไม่ให้ PRECC ทำงานเมื่ออยู่นอกภูมิภาคที่อนุญาต

การวัดระยะไกล

PRECC รองรับการวัดระยะไกลแบบไม่ระบุตัวตนเพื่อช่วยปรับปรุงเครื่องมือ ไม่มีการเก็บข้อมูลเว้นแต่คุณจะยินยอมอย่างชัดเจน

เลือกเข้าร่วม

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

เลือกไม่เข้าร่วม

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

ตรวจสอบสถานะ

$ precc telemetry status
Telemetry: disabled
Last sent: never

ดูตัวอย่างข้อมูลที่จะถูกส่ง

ก่อนเลือกเข้าร่วม คุณสามารถดูได้ว่าข้อมูลใดจะถูกเก็บ:

$ 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
}

ข้อมูลที่เก็บรวบรวม

  • เวอร์ชัน PRECC ระบบปฏิบัติการ และสถาปัตยกรรม
  • จำนวนรวม: คำสั่งที่สกัด ทักษะที่เปิดใช้งาน เสาหลักที่ใช้
  • ความหน่วงเฉลี่ยของ hook
  • จำนวนเซสชัน

ข้อมูลที่ไม่ได้เก็บรวบรวม

  • ไม่มีข้อความคำสั่งหรืออาร์กิวเมนต์
  • ไม่มีเส้นทางไฟล์หรือชื่อไดเรกทอรี
  • ไม่มีชื่อโปรเจกต์หรือ URL ของที่เก็บ
  • ไม่มีข้อมูลส่วนบุคคลที่ระบุตัวตนได้ (PII)
  • ไม่มีที่อยู่ IP (เซิร์ฟเวอร์ไม่บันทึก)

การแทนที่ด้วยตัวแปรสภาพแวดล้อม

เพื่อปิดการวัดระยะไกลโดยไม่ต้องรันคำสั่ง (มีประโยชน์ใน CI หรือสภาพแวดล้อมที่ใช้ร่วมกัน):

export PRECC_NO_TELEMETRY=1

สิ่งนี้มีความสำคัญเหนือการตั้งค่าความยินยอม

ปลายทางข้อมูล

ข้อมูลการวัดระยะไกลจะถูกส่งไปยัง https://telemetry.peria.ai/v1/precc ผ่าน HTTPS ข้อมูลนี้ใช้เพื่อทำความเข้าใจรูปแบบการใช้งานและจัดลำดับความสำคัญของการพัฒนาเท่านั้น

การพยากรณ์ต้นทุนโทเค็น

PRECC มาพร้อมโอราเคิลพยากรณ์ต้นทุนโทเค็น เพื่อให้แผนหลายขั้นตอนสามารถวางงบประมาณเป็นโทเค็นแทนเวลานาฬิกา บันทึกการพยากรณ์ก่อนแต่ละขั้นตอน บันทึกค่าจริงหลังงานเสร็จ และชุดข้อมูลจะฝึกตัวพยากรณ์ในตัวที่ดีขึ้นตามเวลา

บันทึกการพยากรณ์

ส่งคำอธิบายหนึ่งบรรทัดของขั้นตอนที่วางแผนไว้ PRECC จะจัดหมวดหมู่ (feat / fix / test / refactor / measurement / doc / chore / unknown) ประมาณจำนวนโทเค็น และพิมพ์ id ที่คุณจะใช้ปิดวงจร

$ 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>

บันทึกค่าจริง

หลังจากขั้นตอนเสร็จสิ้น ให้ดูจำนวนโทเค็นจริงจากส่วนท้ายของเซสชันหรือเทเลเมตรี แล้วส่งกลับผ่าน id

$ precc predict --record 42 6300
Recorded actual=6300 tokens for prediction id=42.

ฝึก trained-v1

เมื่อมีการพยากรณ์ที่ปิดแล้วอย่างน้อยสิบรายการ ให้พอดี trained-v1 ridge regression บน log10(actual) เทียบกับ log10(ความยาวคำอธิบาย) บวกตัวแปรหุ่น one-hot ของหมวดหมู่ การพอดีเป็นรูปแบบปิด (Cholesky บนสมการปกติด้วย ridge λ=1) และทำงานในหน่วยมิลลิวินาที

$ 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

หลังการฝึก ทุกการเรียก precc predict ใหม่จะใช้ trained-v1 อัตโนมัติจนกว่าคุณจะลบหรือแทนที่ไฟล์โมเดล การพยากรณ์เก่าจะคง model_version เดิมไว้ เพื่อให้คุณเปรียบเทียบตัวพยากรณ์ตามช่วงเวลาได้

ตรวจสอบความแม่นยำของตัวพยากรณ์

precc predict --eval รายงานข้อผิดพลาดร้อยละสัมบูรณ์เฉลี่ย (MAPE) โดยรวมและรายหมวดหมู่ คำนวณเฉพาะการพยากรณ์ที่ปิดแล้ว (แถวที่มีทั้งค่าพยากรณ์และค่าจริง)

$ 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%
  ...

แสดงการพยากรณ์ล่าสุด

precc predict --list แสดงแถวล่าสุดตามลำดับเวลาย้อนกลับ แถวที่เปิดอยู่ (ไม่มีค่าจริง) พร้อมที่จะปิด

$ 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...

ทำไมต้องเป็นโทเค็น ไม่ใช่เวลานาฬิกา

การประมาณเวลาไม่สามารถวัดได้ภายหลัง และไม่สามารถรวมกันข้ามเครื่องหรือเซสชันได้ จำนวนโทเค็นเป็นค่าคงที่ เปรียบเทียบได้ และทำให้ชุดข้อมูลที่มีฉลากเติบโต ซึ่งช่วยปรับปรุงตัวพยากรณ์ในทุกวงจรที่ปิด เป้าหมายของโอราเคิลคือการเปลี่ยนการประมาณจากเกมเดาเป็นการวัด

ข้อมูลอยู่ที่ไหน

ข้อมูลการพยากรณ์ทั้งหมดถูกเก็บไว้บนเครื่องของคุณในเครื่อง ไม่มีการอัปโหลด

~/.local/share/precc/
├── metrics.db                — predictions table (oracle DB)
└── predict_model.json        — trained-v1 coefficients (after `--train`)

การแปลภาษา

PRECC แสดงแถบสถานะและข้อความตอบกลับสั้นใน 28 ภาษา การแปลถูกคอมไพล์ลงในไบนารี การเลือกภาษาจึงไม่เพิ่มภาระ I/O ในขั้นตอน hook

การตั้งค่าภาษา

ตั้งค่าตัวแปรสภาพแวดล้อม PRECC_LANG เป็นรหัสภาษาที่รองรับ ค่านี้จะมีลำดับความสำคัญสูงกว่าทุกแหล่งอื่น

$ PRECC_LANG=zh precc savings
$ export PRECC_LANG=ja

การคงค่าผ่าน consent.toml

เพิ่ม [ui] preferred_language = "ja" (หรือรหัสใดก็ตามที่รองรับ) ในไฟล์ ~/.config/precc/consent.toml เพื่อคงค่าไว้ข้าม shell โดยไม่ต้อง export ตัวแปรสภาพแวดล้อม

# ~/.config/precc/consent.toml
[ui]
preferred_language = "ja"

ลำดับการตัดสินค่า

PRECC จะตรวจ PRECC_LANG ก่อน จากนั้นจึงดู [ui] preferred_language ใน consent.toml และสุดท้ายค่อยถอยกลับไปที่ภาษาอังกฤษ ค่าที่ไม่ว่างค่าแรกจะถูกใช้และเก็บแคชไว้ตลอดอายุของกระบวนการ

1. PRECC_LANG          (environment variable)
2. consent.toml        ([ui] preferred_language)
3. "en"                (default)

ขอบเขตที่รองรับ

ตารางการแปลมีคอลัมน์ภาษา 28 คอลัมน์ เซลล์ที่ทีมไม่สามารถตรวจสอบด้วยตนเองจะถูกเว้นว่างและถอยกลับไปใช้ภาษาอังกฤษเมื่อมีการค้นหา แทนที่จะแสดงข้อความที่ถูกกุขึ้น หากคุณช่วยปรับปรุงคำแปลได้ โปรดส่งกลับมายังต้นน้ำ

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

ทำไมจึงยังเร็วอยู่

การแปลถูกเก็บเป็นอาเรย์ const แบบ compile-time ภายในไบนารี precc-core ไม่ได้อยู่ใน SQLite hook ทำเพียงการค้นหาในหน่วยความจำเพียงครั้งเดียว ดังนั้นต้นทุนการแปลจึงเล็กจนวัดไม่ได้เมื่อเทียบกับงบ < 5 ms p99 ของ hook

Mindmap

This page is auto-generated from mindmap.db — a SQLite snapshot of all recorded PRECC development sessions and git commits. Every row traces back to its source (commit:<sha>, session:<id>, or doc:<path>).

Overview

  • Sessions analyzed: 22
  • Messages: 14023
  • Tool invocations: 5072
  • Commits: 205
  • Time range: 2026-03-20T07:04:14.787Z → 2026-04-19T11:50:10.153Z
  • Effort (tokens):
    • input: 27928
    • output: 2750669
    • cache writes: 43349705
    • cache reads: 1936351239

Features

ScopeTitleStatusCommitsTokensFirstLastSource
benchfeat(bench): SWE-bench Verified/Lite driver scaffoldingstabilizing443442992026-04-172026-04-17commit:5bdd027d
benchmark_gate.shfeat: benchmark_gate.sh + pin tb dataset to 0.1.1shipped143442992026-04-172026-04-17commit:99fa9a74
realfeat: real lean-ctx (not stub), wider campaign, doc updatesshipped2298211522026-04-072026-04-17commit:6095720a
precc_mode=benchmarkfeat: PRECC_MODE=benchmark toggle + pairwise benchmark harnessshipped143442992026-04-172026-04-17commit:50c5a30f
addfeat: add precc update self-update commandshipped14425571072026-03-092026-04-17commit:e5542fba
negotiablefeat: negotiable rewrites, skill decay, explain/undo — response to criticshipped143442992026-04-172026-04-17commit:6fda67e4
statuslinefeat: statusline shows actual session token consumption + coststabilizing3254249152026-04-082026-04-13commit:4f65556d
publicfeat: public repo commits attributed to Ce-cyber-artshipped1253821192026-04-102026-04-10commit:0e4840e4
shortfeat: short install URL https://peria.ai/install.shshipped1253821192026-04-092026-04-09commit:615d3d06
rewritefeat: rewrite Pillar 2b (ccc) and Pillar 3 (compress) in Rust for single-binary deploymentshipped2381180742026-03-202026-04-08commit:78621579
shortenfeat: shorten statusline segments to fit narrower terminalsshipped1253821192026-04-082026-04-08commit:ef2c88b4
dropfeat: drop fake token estimate, append cost estimate to lifetime segmentstabilizing2253821192026-04-082026-04-08commit:2702f3f9
updatefeat: update pricing to $5/6mo + $10/yr, add webhook serverstabilizing9381180742026-02-252026-04-08commit:2d366031
clearerfeat: clearer statusline labels — meas:, drop confusing %, add bash shareshipped1253821192026-04-082026-04-08commit:4cd837b7
stablefeat: stable machine_hash for telemetry dedupstabilizing2253821192026-04-082026-04-08commit:3073f428
lifetimefeat: lifetime savings segment in statuslineshipped1253821192026-04-082026-04-08commit:9af422e8
preccfeat: precc analyze frequencies — data-driven rule gap discoveryshipped3253821192026-04-072026-04-08commit:d6f24c50
per-interactionfeat: per-interaction PRECC savings line in PostToolUseshipped1253821192026-04-082026-04-08commit:e3bc282e
webhookfeat: webhook auto-regenerates stats.json on telemetry POSTstabilizing2291341862026-03-312026-04-08commit:912b75f3
per-emailfeat: per-email aggregation for telemetryshipped1253821192026-04-082026-04-08commit:14c95e7d
v0.3.3feat: v0.3.3 — companion tools default-on, install-script clarityshipped1253821192026-04-072026-04-07commit:48fca046
measurementfeat: measurement campaign script — real per-mode measurementsshipped1253821192026-04-072026-04-07commit:36760587
quote-awarefeat: quote-aware chain split + sysadmin tool whitelist (54.2% → 55.5%)shipped1253821192026-04-072026-04-07commit:f6580598
;feat: ; chain support + ssh inner-command parsing for measurementshipped1253821192026-04-072026-04-07commit:10093218
expandfeat: expand is_safe_to_rerun coverage + measurement timeout/cacheshipped1253821192026-04-072026-04-07commit:c5a7ea79
multi-modefeat: multi-mode adaptive compression with failure learningshipped1253821192026-04-072026-04-07commit:81475afc
measuredfeat: measured savings in telemetry, detailed live stats, update nudgeshipped1253821192026-04-062026-04-06commit:06907091
scientificfeat: scientific token savings measurement, telemetry dedup, 28-language docsshipped1253821192026-04-062026-04-06commit:78a20ef2
v0.3.2feat: v0.3.2 — hook safety, adaptive compression, on-demand metrics importshipped1253821192026-04-052026-04-05commit:a0c0c882
self-hostedfeat: self-hosted telemetry endpoint at peria.ai, install UX improvementsshipped125657032026-04-042026-04-04commit:8212a18e
auto-updatefeat: auto-update consent prompt on init and manual updateshipped119243022026-04-022026-04-02commit:818be6dd
useperf: use pre-built binaries for lean-ctx and nushell installationstabilizing4101702522026-03-092026-03-31commit:8c612e55
authorizefeat: authorize peria.ai server for license key generationshipped211863642026-03-312026-03-31commit:53dfe832
licensefeat: license keys, SMTP mail-agent, updated business plan and demosstabilizing2101702522026-03-092026-03-31commit:b07c9dfb
lean-ctxfeat: lean-ctx integration for deep output compressionshipped111863642026-03-312026-03-31commit:07361e62
integratefeat: integrate three-pillar savings from precc-cc (cocoindex-code, token-saver, ClawHub)shipped2101702522026-03-202026-03-31commit:af4205f1
windowsfeat: Windows build via CI, deploy triggers workflowstabilizing225336922026-03-292026-03-29commit:7404761b
monthlyfeat: monthly usage report via email for Pro usersshipped125336922026-03-282026-03-28commit:77ad78bc
nushellfeat: nushell what-if analysis, skill clustering, comment blocker, bash unwrap (v0.2.6)shipped123379412026-03-272026-03-27commit:803df684
geofencefeat: geofence compliance guard, 3rd-party skill Claude interaction tracking (v0.2.5)shipped123379412026-03-262026-03-26commit:0c9fc765
stripefeat: Stripe payment integration, context pressure, GHA analysisshipped224570882026-03-212026-03-22commit:8eb16f78
contextfeat: context pressure warning, GHA analysis, statusline context %shipped121661412026-03-202026-03-20commit:894621ba
statusline,feat: statusline, squash deploy, ClaWHub metadata, SHA256 checksumsshipped121661412026-03-202026-03-20commit:7ab15883
gumroadfeat: Gumroad license verification via API (v0.2.2)shipped102026-03-132026-03-13commit:75c5e480
per-userfeat: per-user email-based license keys with Gumroad webhook (v0.2.2)shipped102026-03-132026-03-13commit:6d056958
posttoolusefeat: PostToolUse observability + comprehensive test coverage (v0.2.1)shipped102026-03-122026-03-12commit:6e33b7e4
multi-toolfeat: multi-tool hook dispatch, subagent propagation & Read/Grep filters (v0.2.0)shipped102026-03-122026-03-12commit:1bf5a108
skillfeat: skill advisor, sharing credits, telemetry & Rust actionbook (v0.1.9)shipped102026-03-122026-03-12commit:d41d310e
firefeat: fire anonymous update-check ping on precc update (opt-out via PRECC_NO_TELEMETRY=1)shipped102026-03-102026-03-10commit:7acce69d
enforcefeat: enforce license tier gates (Free/Pro) on ingest, mined skills, gif, mail, savingsshipped102026-03-102026-03-10commit:a7bd23e3
translatefeat: translate git commands to jj (Jujutsu) in colocated reposshipped102026-03-092026-03-09commit:d8a29e48
rtkfeat(rtk): sync rewrite rules with upstream RTK v0.27.2shipped102026-03-092026-03-09commit:ad7dca0e
applyfeat: apply skill portfolio per command for maximum token savingsshipped102026-03-092026-03-09commit:b2490073
pitchfeat(pitch): add bilingual EN/ZH PowerPoint pitch deckshipped202026-02-272026-02-28commit:8876c4b7
hookperf(hook): skip heuristics.db open via plain-text prefix cacheshipped102026-02-272026-02-27commit:89537483
initfeat(init): embed builtin skills in binary via include_str!shipped102026-02-262026-02-26commit:3a837b13
clifeat(cli): add precc skills export commandshipped202026-02-262026-02-26commit:59beea8d
gdbfeat(gdb): re-enable Pillar 2 GDB hook suggestionshipped102026-02-262026-02-26commit:a8428025
skillsfeat(skills): add git wrong-dir skill and context mappingstabilizing202026-02-252026-02-25commit:352474e1
metricsfeat(metrics): record hook latency, rtk_rewrite, cd_prepend via append-logshipped102026-02-252026-02-25commit:9bf31d12
demofeat(demo): add investor demo suiteshipped102026-02-252026-02-25commit:c818a0ac
securityfeat(security): SQLCipher encryption, binary hardening, multi-platform CIshipped102026-02-252026-02-25commit:efd3dfc8
ingestfeat(ingest): add –force flag to re-mine already-recorded sessionsshipped102026-02-222026-02-22commit:85cc8f6f

Dependencies (precc-core modules)

  • advisordb, promote, skills
  • dietlean_ctx
  • metricsdb
  • miningskills
  • mode_selectordb, mode
  • multi_probediet, lean_ctx, mode, nushell, post_observe, rtk
  • nushelllean_ctx, mining, rtk
  • promotedb, skills
  • rtklean_ctx
  • sharingdb, license, skills
  • skill_advisormining, nushell
  • skillsdb
  • telemetrydb, license, mining

Plans & Tasks

Plans (prompts requesting design/architecture)

  • [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)

Tasks (TaskCreate / TodoWrite entries)

  • completed: 89
  • in_progress: 3
  • deleted: 2

Most recent 30 tasks:

  • [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 report that 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 &lt;build\|test\|check\|clippy&gt; without -p, reads cached cargo 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-baseline subcommand. 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)

Blockers (user-reported failure/stuck signals)

  • 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)

Decisions & Rationale

  • 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-events to 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 ScriptDecision: Replace the rtk-rewrite.sh shell script hook with a compiled Rust binary (precc-hook). Alternatives considered: source: doc:ALTERNATIVES.md
  • 2. SQLite vs Key-Value StoreDecision: Use SQLite for both history.db and heuristics.db. Alternatives considered: source: doc:ALTERNATIVES.md
  • 3. Workspace of 4 Crates vs MonolithDecision: 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 CLIDecision: 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 MiningDecision: Support both modes — precc-learner daemon for continuous mining, precc ingest for on-demand. Alternatives considered: source: doc:ALTERNATIVES.md
  • 6. Confidence ThresholdsDecision: 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 StrategyDecision: Port RTK’s rewriting logic into precc-core as the final pipeline stage, rather than running both hooks in sequence. Alternatives considered: source: doc:ALTERNATIVES.md
  • 8. Skill Storage FormatDecision: TOML files for built-in skills, SQLite rows for mined/user skills. Alternatives considered: source: doc:ALTERNATIVES.md
  • 9. Session Log FormatDecision: 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

KPIs over time

MetricUnitFirstLatestΔSamplesLast source
atx0.11.25+1.152commit:4f65556d
buildms3480+4772commit:f84bab49
hookms53-22commit:f81e4543
precctokens42387-3362commit:e3bc282e
savedms4.86.3+1.52commit:ec17f16c

Effort by session (top 10 by tokens)

SessionFirst → LastMsgsinputoutputCache writeCache read
ebd819382026-04-04 → 2026-04-1345174547686622246909501020430414
781fe4842026-04-16 → 2026-04-17143413416035963739362259708120
101753392026-03-28 → 2026-03-30131811761024692430047110606429
5761d7ca2026-03-26 → 2026-03-28118043631370562196522116605673
550c7bab2026-03-20 → 2026-03-2210641466104943205973292991217
905ff1692026-04-18 → 2026-04-196501698496929157266863432376
d65ad15f2026-03-31 → 2026-04-0475255878099184564558334554
3b5e29472026-03-22 → 2026-03-2311628961280681526203102403205
0925455d2026-04-19 → 2026-04-19440830262128122605432943523
435418852026-03-31 → 2026-03-31566735382683109632841667559

การใช้ PRECC ร่วมกับ Cursor

PRECC ถูกสร้างขึ้นเป็น PreToolUse hook สำหรับ Claude Code แต่ไลบรารีสกิลที่อยู่เบื้องหลัง เช่น cargo-wrong-dir, git-wrong-dir, npm-wrong-dir, jj-translate และอื่นๆ นั้นไม่ขึ้นอยู่กับเอดิเตอร์ใดเอดิเตอร์หนึ่ง ด้วย shell snippet สั้นๆ คุณสามารถส่งทุกคำสั่งที่พิมพ์ในเทอร์มินัลในตัวของ Cursor ผ่าน precc-hook ได้ เพื่อให้การเขียนคำสั่งใหม่แบบเดียวกันที่ช่วยประหยัดโทเค็นบน Claude Code ก็ช่วยประหยัดโทเค็นบน Cursor ได้เช่นกัน

Requires precc ≥ 0.3.45. Earlier versions don’t plant the integration scripts under <data_dir>/integrations/cursor/. Run precc update to upgrade if you have an older release.

สิ่งที่ครอบคลุม

การผสานรวมนี้จะดักจับคำสั่งที่คุณ พิมพ์ เข้าไปในเทอร์มินัลของ Cursor บน zsh จะเขียนบรรทัดคำสั่งใหม่โดยอัตโนมัติก่อนกด Enter ส่วนบน bash ทำได้เพียงเตือนเท่านั้น (เพราะ trap DEBUG จะทำงานหลังจากคำสั่งถูกกำหนดเสร็จแล้ว) คำสั่งที่ เอเจนต์ ของ Cursor สั่งให้ทำงานเป็น subprocess แบบ bash -c จะไม่โหลด interactive shell init ของคุณ ดังนั้น hook จึงมองไม่เห็น การปิดช่องว่างนี้ต้องใช้ shim ของ PATH ซึ่งยังไม่มีอยู่ในไดเรกทอรีนี้ การเรียกใช้เครื่องมือที่ไม่ใช่เชลล์ของ Cursor (การแก้ไขไฟล์ การค้นหาโค้ด) ก็อยู่นอกขอบเขตเช่นกัน

การติดตั้ง

zsh (เขียนใหม่อัตโนมัติ)

source ~/.local/share/precc/integrations/cursor/precc-preexec.zsh

รัน precc init หนึ่งครั้ง — คำสั่งนี้จะติดตั้งสคริปต์ไว้ที่พาธด้านบน (ใช้ <data_dir> จากที่จัดเก็บของ precc ดังนั้น CLAUDE_CONFIG_DIR และการแยกโปรไฟล์อื่นๆ จะได้รับการเคารพ) จากนั้นเพิ่มบรรทัด source ลงใน ~/.zshrc ทั้ง precc-hook และ jq ต้องอยู่ใน PATH สคริปต์จะไม่ทำงานอย่างเรียบร้อยหากขาดอย่างใดอย่างหนึ่ง

bash (เตือนอย่างเดียว)

source ~/.local/share/precc/integrations/cursor/precc-preexec.bash

รัน precc init หนึ่งครั้ง — คำสั่งนี้จะติดตั้งสคริปต์ไว้ที่พาธด้านบน จากนั้นเพิ่มบรรทัด source ลงใน ~/.bashrc ตัวดัก DEBUG จะพิมพ์การเขียนใหม่ที่แนะนำไปยัง stderr โดยไม่ใช้งานจริง คุณสามารถคัดลอกคำแนะนำด้วยตนเองได้

การตรวจสอบ

ในเทอร์มินัลของ Cursor ให้ cd /tmp (ที่ใดก็ได้นอกโปรเจกต์ Rust) แล้วพิมพ์คำสั่ง build ของ Rust จากนั้นกด Enter บน zsh บัฟเฟอร์ควรเปลี่ยนแปลงในที่เป็นรูปแบบที่ PRECC เขียนใหม่ (โดยทั่วไปจะเป็นการเติมในลักษณะ cd PATH && …) ส่วนบน bash คุณควรเห็นบรรทัด [precc] suggested rewrite: … บน stderr

ข้อควรระวัง

  • เพิ่มเวลาแฝงของ precc-hook ต่อการกดแต่ละครั้ง hook ตั้งเป้าหมายไว้ที่ <5 ms p50 แต่ p99 จะสูงกว่าเมื่อแคชเย็น ดูบันทึก hook-latency ในหนังสือเล่มนี้
  • ไม่มี telemetry จากเส้นทางนี้ hook จะรายงานภายใต้ agent_class ใดก็ตามที่ตรวจพบ ซึ่งจะไม่ใช่ claude-code ดังนั้นการประหยัดของ Cursor จะไม่ปรากฏบนหน้าสถิติสาธารณะ
  • เหตุผลของการเขียนใหม่จะปรากฏแวบหนึ่งผ่าน zle -M เพียงหนึ่งจังหวะการกดปุ่ม เงียบ ไม่ใช่โหมดบล็อก
  • สำหรับการครอบคลุมเอเจนต์ shim ของ PATH (wrapper ที่ ~/.precc/bin/cargo, ~/.precc/bin/git, …) คือขั้นตอนถัดไปที่วางแผนไว้

อ้างอิงคำสั่ง

เอกสารอ้างอิงฉบับสมบูรณ์สำหรับคำสั่ง PRECC ทั้งหมด


precc init

เริ่มต้น PRECC และลงทะเบียน hook กับ 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

ขุดบันทึกเซสชันเพื่อหารูปแบบข้อผิดพลาด-การแก้ไข

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

จัดการทักษะอัตโนมัติ

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

สร้างรายงานวิเคราะห์

precc report [--email]

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

precc savings

แสดงการประหยัด token

precc savings [--all]

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

precc compress

บีบอัดไฟล์บริบทเพื่อลดการใช้ 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

จัดการใบอนุญาต PRECC ของคุณ

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

ฟังก์ชันอีเมล

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

อัปเดต PRECC เป็นเวอร์ชันล่าสุด

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

จัดการการวัดระยะไกลแบบไม่ระบุตัวตน

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

การปฏิบัติตาม 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

บันทึก GIF แบบเคลื่อนไหวจากสคริปต์ 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

วิเคราะห์การรัน GitHub Actions ที่ล้มเหลว (Pro)

precc gha URL

Arguments:
  URL             GitHub Actions run URL

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

precc cache-hint

แสดงข้อมูลคำแนะนำแคชสำหรับโปรเจกต์ปัจจุบัน

precc cache-hint

precc trial

เริ่มทดลองใช้ Pro

precc trial EMAIL

Arguments:
  EMAIL           Email address for the trial

precc nushell

เปิดเซสชัน Nushell พร้อมการรวม 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).

คำถามที่พบบ่อย

PRECC ปลอดภัยไหม?

ใช่ PRECC ใช้กลไก hook PreToolUse อย่างเป็นทางการของ Claude Code – จุดขยายเดียวกันที่ Anthropic ออกแบบมาเพื่อจุดประสงค์นี้โดยเฉพาะ Hook:

  • ทำงานแบบออฟไลน์ทั้งหมด (ไม่มีการเรียกเครือข่ายในเส้นทางหลัก)
  • เสร็จสิ้นในเวลาน้อยกว่า 5 มิลลิวินาที
  • เป็น fail-open: หากมีข้อผิดพลาด คำสั่งเดิมจะทำงานโดยไม่เปลี่ยนแปลง
  • แก้ไขคำสั่งเท่านั้น ไม่เคยเรียกใช้เอง
  • จัดเก็บข้อมูลในฐานข้อมูล SQLite ภายในเครื่อง

PRECC ทำงานกับเครื่องมือเขียนโค้ด AI อื่นได้ไหม?

PRECC ออกแบบมาสำหรับ Claude Code โดยเฉพาะ มันอาศัยโปรโตคอล hook PreToolUse ที่ Claude Code มีให้ ไม่ทำงานกับ Cursor, Copilot, Windsurf หรือเครื่องมือเขียนโค้ด AI อื่น

การวัดระยะไกลส่งข้อมูลอะไร?

การวัดระยะไกลเป็นแบบเลือกเข้าร่วมเท่านั้น เมื่อเปิดใช้งานจะส่ง:

  • เวอร์ชัน PRECC ระบบปฏิบัติการ และสถาปัตยกรรม
  • จำนวนรวม (คำสั่งที่สกัด ทักษะที่เปิดใช้งาน)
  • ความหน่วงเฉลี่ยของ hook

ไม่ส่งข้อความคำสั่ง เส้นทางไฟล์ ชื่อโปรเจกต์ หรือข้อมูลส่วนบุคคล คุณสามารถดูตัวอย่างข้อมูลที่แน่นอนด้วย precc telemetry preview ก่อนเลือกเข้าร่วม ดูการวัดระยะไกลสำหรับรายละเอียด

ฉันจะถอนการติดตั้ง PRECC ได้อย่างไร?

PRECC is fully reversible — remove it in three steps:

  1. ลบการลงทะเบียน hook:

    # Delete the hook entry from Claude Code's settings
    # (precc init added it; removing it disables PRECC)
    
  2. ลบไฟล์ไบนารี:

    rm ~/.local/bin/precc ~/.local/bin/precc-hook ~/.local/bin/precc-learner
    
  3. ลบข้อมูล (ไม่บังคับ):

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

ใบอนุญาตของฉันหมดอายุ เกิดอะไรขึ้น?

PRECC กลับไปยังระดับ Community ฟังก์ชันหลักทั้งหมดยังคงทำงาน:

  • ทักษะในตัวยังคงใช้งานได้
  • Pipeline hook ทำงานปกติ
  • precc savings แสดงมุมมองสรุป
  • precc ingest และการขุดเซสชันทำงาน

ฟีเจอร์ Pro จะไม่สามารถใช้งานได้จนกว่าจะต่ออายุ:

  • precc savings --all (รายละเอียดการแยกย่อย)
  • precc compress
  • precc gif
  • precc gha
  • precc geofence
  • รายงานทางอีเมล

Hook ดูเหมือนไม่ทำงาน ฉันจะแก้ไขจุดบกพร่องอย่างไร?

Run precc doctor first — it automates every check below. To diagnose by hand:

  1. ตรวจสอบว่า hook ได้ลงทะเบียนแล้ว:

    precc init
    
  2. ทดสอบ hook ด้วยตนเอง:

    echo '{"tool_input":{"command":"cargo build"}}' | precc-hook
    
  3. ตรวจสอบว่าไฟล์ไบนารีอยู่ใน PATH:

    which precc-hook
    
  4. ตรวจสอบการกำหนดค่า hook ของ Claude Code ใน ~/.claude/settings.json

PRECC ทำให้ Claude Code ช้าลงไหม?

ไม่ Hook เสร็จสิ้นในเวลาน้อยกว่า 5 มิลลิวินาที (p99) ซึ่งแทบไม่รู้สึกเมื่อเทียบกับเวลาที่ Claude ใช้ในการคิดและสร้างคำตอบ

ฉันใช้ PRECC ใน CI/CD ได้ไหม?

PRECC ออกแบบมาสำหรับเซสชัน Claude Code แบบโต้ตอบ ใน CI/CD ไม่มีอินสแตนซ์ Claude Code ให้ hook เข้า อย่างไรก็ตาม precc gha สามารถวิเคราะห์การรัน GitHub Actions ที่ล้มเหลวจากสภาพแวดล้อมใดก็ได้

ทักษะที่ขุดมาแตกต่างจากทักษะในตัวอย่างไร?

ทักษะในตัวมาพร้อมกับ PRECC และครอบคลุมรูปแบบไดเรกทอรีผิดทั่วไป ทักษะที่ขุดมาเรียนรู้จากบันทึกเซสชันเฉพาะของคุณ ทั้งสองถูกจัดเก็บใน SQLite และถูกประเมินเหมือนกันโดย pipeline hook

ฉันแชร์ทักษะกับทีมได้ไหม?

ได้ ส่งออกทักษะเป็น TOML ด้วย precc skills export NAME และแชร์ไฟล์ สมาชิกในทีมสามารถวางไว้ในไดเรกทอรี skills/ หรือนำเข้าสู่ฐานข้อมูลได้

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:

  1. 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
    
  2. Your settings.json is missing the hook entry. Run precc 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 doctor
    

    If doctor is not available because you are on an older release, run precc init to (re)register the hook.

  3. 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. Run precc skills list to 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 transient lean-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 includes claude itself 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 on curl/wget/http/fetch against any of 11 OpenCLI-supported domains and suggest_fix-es the equivalent opencli <site> … command. Suggestion only; never modifies the command.
  • webfetch-opencli-hackernews — auto-rewrites curl|wget news.ycombinator.com to opencli hackernews top with an inline command -v opencli fallback 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.

ภาษาอื่น