Code Review
ตั้งค่า PR reviews อัตโนมัติที่ catch logic errors, security vulnerabilities และ regressions โดยใช้ multi-agent analysis ของ codebase ทั้งหมด
Code Review อยู่ใน research preview สำหรับ subscription Team และ Enterprise ไม่รองรับสำหรับองค์กรที่มี Zero Data Retention เปิดใช้งาน
Code Review วิเคราะห์ GitHub pull requests ของคุณและ post findings เป็น inline comments บนบรรทัด code ที่พบปัญหา Fleet ของ specialized agents ตรวจสอบการเปลี่ยนแปลง code ในบริบทของ codebase ทั้งหมด มองหา logic errors, security vulnerabilities, broken edge cases และ subtle regressions
วิธีที่ reviews ทำงาน
เมื่อ admin เปิดใช้งาน Code Review reviews จะ trigger เมื่อ PR เปิด, ทุก push หรือเมื่อ request ด้วยตนเอง ขึ้นอยู่กับ configured behavior ของ repository
เมื่อ review รัน agents หลายตัววิเคราะห์ diff และ code โดยรอบใน parallel บน Anthropic infrastructure แต่ละ agent มองหาปัญหาคนละประเภท จากนั้น verification step ตรวจสอบ candidates กับ code behavior จริงเพื่อ filter false positives ผล deduplicated, ถูก rank ตาม severity และ post เป็น inline comments พร้อม summary ใน review body
Reviews ใช้เวลาเฉลี่ย 20 นาที
Severity levels
| Marker | Severity | ความหมาย |
|---|---|---|
| 🔴 | Important | บั๊กที่ควรแก้ก่อน merge |
| 🟡 | Nit | ปัญหาเล็กน้อย ควรแก้แต่ไม่ blocking |
| 🟣 | Pre-existing | บั๊กที่มีอยู่ใน codebase แต่ไม่ได้ introduce โดย PR นี้ |
Rate และ reply กับ findings
แต่ละ review comment มี 👍 และ 👎 ติดมาด้วย คลิก 👍 หาก finding มีประโยชน์ หรือ 👎 หากไม่ถูกต้องหรือดัง
Check run output
แต่ละ review แสดงใน Claude Code Review check run ขยาย Details เพื่อดู summary ของ finding ทั้งหมดเรียงตาม severity
ตั้งค่า Code Review
ขั้นตอนที่ 1: ไปที่ claude.ai/admin-settings/claude-code และหา Code Review section
ขั้นตอนที่ 2: คลิก Setup เพื่อเริ่ม GitHub App installation flow
ขั้นตอนที่ 3: ติดตั้ง Claude GitHub App ในองค์กร GitHub ของคุณ App ขอ permissions เหล่านี้:
- Contents: read และ write
- Issues: read และ write
- Pull requests: read และ write
ขั้นตอนที่ 4: เลือก repositories ที่จะเปิดใช้งาน Code Review
ขั้นตอนที่ 5: ตั้ง review triggers ต่อ repo:
- Once after PR creation: review รันครั้งเดียวเมื่อ PR เปิด
- After every push: review รันทุก push
- Manual: reviews เริ่มเฉพาะเมื่อมีคน comment
@claude reviewบน PR
Trigger reviews ด้วยตนเอง
| Command | สิ่งที่ทำ |
|---|---|
@claude review | เริ่ม review และ subscribe PR ให้ push-triggered reviews |
@claude review once | เริ่ม review เดี่ยวโดยไม่ subscribe PR |
Post เป็น top-level PR comment ไม่ใช่ inline comment บน diff line
ปรับแต่ง reviews
CLAUDE.md
Code Review อ่าน CLAUDE.md files ของ repository และ treat การ introduce violations ใหม่เป็น nit-level findings
REVIEW.md
REVIEW.md ที่ root ของ repository ของคุณ override วิธีที่ Code Review ทำงาน เนื้อหาถูก inject เป็น system prompt ของทุก agent ในลำดับความสำคัญสูงสุด
สิ่งที่คุณปรับแต่งได้:
- Severity: กำหนด 🔴 Important ใหม่สำหรับ repository ของคุณ
- Nit volume: จำกัดจำนวน 🟡 Nit comments ต่อ review
- Skip rules: แสดงรายการ paths, branch patterns และ finding categories ที่ข้ามได้
- Repo-specific checks: เพิ่มกฎที่ต้องการ flag ทุก PR
- Verification bar: ต้องการหลักฐานก่อน post finding
ตัวอย่าง REVIEW.md:
# Review instructions
## What Important means here
Reserve Important for findings that would break behavior, leak data,
or block a rollback: incorrect logic, unscoped database queries, PII
in logs or error messages, and migrations that aren't backward
compatible. Style, naming, and refactoring suggestions are Nit at
most.
## Cap the nits
Report at most five Nits per review. If you found more, say "plus N
similar items" in the summary instead of posting them inline.
## Do not report
- Anything CI already enforces: lint, formatting, type errors
- Generated files under `src/gen/` and any `*.lock` file
## Always check
- New API routes have an integration test
- Log lines don't include email addresses, user IDs, or request bodies
ดู usage
ไปที่ claude.ai/analytics/code-review เพื่อดู Code Review activity ทั้งองค์กร
| Section | สิ่งที่แสดง |
|---|---|
| PRs reviewed | จำนวน pull requests ที่ reviewed ต่อวัน |
| Cost weekly | ค่าใช้จ่ายรายสัปดาห์สำหรับ Code Review |
| Feedback | จำนวน review comments ที่ developer จัดการแล้ว |
| Repository breakdown | จำนวน PRs reviewed และ comments resolved ต่อ repo |
Pricing
Code Review คิดราคาตาม token usage แต่ละ review มีค่าเฉลี่ย $15-25 Code Review usage คิดราคาแยกผ่าน usage credits
การแก้ไขปัญหา
Retrigger review ที่ล้มเหลวหรือ timeout
Comment @claude review once บน PR เพื่อเริ่ม review ใหม่
ปุ่ม Re-run ใน GitHub's Checks tab ไม่ retrigger Code Review ใช้ comment command หรือ push ใหม่แทน
Review ไม่รันและ PR แสดงข้อความ spend-cap
เมื่อถึง spend cap รายเดือน Code Review post comment เดี่ยวใน PR Reviews จะ resume อัตโนมัติเมื่อเริ่มรอบ billing ใหม่
Review diff ใน local
command /code-review review diff ใน terminal โดยไม่ต้องติดตั้ง GitHub App รัน /code-review ultra --fix เพื่อ run deep ultrareview ใน cloud
แหล่งข้อมูลที่เกี่ยวข้อง
- Commands: รัน
/code-reviewใน local Claude Code session - GitHub Actions: รัน Claude ใน GitHub Actions workflows ของคุณ
- GitLab CI/CD: self-hosted Claude integration สำหรับ GitLab pipelines
- Memory: วิธีที่
CLAUDE.mdfiles ทำงานใน Claude Code