Code review
Code review skill for analyzing code quality, detecting bugs, and ensuring best practices. Provides comprehensive code review with actionable feedback. Use proactively when user requests code review, quality check, or bug detection. Triggers: code review, review code, check code, analyze code, bug detection, code 리뷰, code 검수, code 검토, 코드 검수, 코드 리뷰, 코드 검토, 버그 검사, コードレビュー, バグ検出, 代码审查, 代码检查, revisión de código, revisar código, detección de errores, revue de code, réviser le code, détection de bugs, Code-Review, Code überprüfen, Fehlererkennung, revisione del codice, rivedere codice, rilevamento bug Do NOT use for: design document creation, deployment tasks, or gap analysis (use phase-8-review).From its SKILL.md
npx -y skills add solitasroh/rkit --skill code-reviewAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
15.9 KB, as published. Nobody here has run it
Code Review Skill
Skill for code quality analysis and review.
잠금 어휘 SoT: policies/locked-vocab.json — 부록 §A는
node scripts/gen-locked-vocab.mjs로 자동 생성됩니다.
0. 문서 구조 (본 SKILL의 세 층)
- 도메인 본문 (기존 §Arguments ~ §PDCA Integration): 기존 쓰임. 잠금 어휘 사용 허용 (grandfathered).
- 방법론 본문 — 도메인 중립 (§자동 생략, §리뷰 중복 제거, §사용자 질문 양식): Cycle 1.5 추가. 잠금 어휘 0건 자동 검증.
- 도메인 예시 부록 (§A): SoT 자동 생성.
Arguments
| Argument | Description | Example |
|---|---|---|
[file] | Review specific file | /code-review src/lib/auth.ts |
[directory] | Review entire directory | /code-review src/features/ |
[pr] | PR review (PR number) | /code-review pr 123 |
--auto-fix | Auto-fix Minor/Major issues (L2+ only) | /code-review src/ --auto-fix |
Review Categories
1. Code Quality
- Duplicate code detection
- Function/file complexity analysis
- Naming convention check
- Type safety verification
2. Bug Detection
- Potential bug pattern detection
- Null/undefined handling check
- Error handling inspection
- Boundary condition verification
3. Security
- XSS/CSRF vulnerability check
- SQL Injection pattern detection
- Sensitive information exposure check
- Authentication/authorization logic review
4. Performance
- N+1 query pattern detection
- Unnecessary re-render check
- Memory leak pattern detection
- Optimization opportunity identification
Review Output Format
## Code Review Report
### Summary
- Files reviewed: N
- Issues found: N (Critical: N, Major: N, Minor: N)
- Score: N/100
### Critical Issues
1. [FILE:LINE] Issue description
Suggestion: ...
### Major Issues
...
### Minor Issues
...
### Recommendations
- ...
C/C++ Pre-Analysis (자동)
target 내에 C/C++ 파일이 포함되면 code-analyzer 호출 전에 다음을 순차 수행한다. 비-C/C++ target 이면 전체 스킵 (회귀 없음).
1. 감지
Glob **/*.{c,cpp,cc,cxx,h,hpp} 로 target 하위 검사. 결과 빈 리스트면 이하 전부 스킵.
2. 러너 실행
python ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-static-analysis/rapp_review.py --target <target>
- 정상: stdout 마지막 줄이
cpp-static-analysis: <run_dir> (N findings)형식 — 이<run_dir>을 반드시 캡처 (Step 3 입력) - ModuleNotFoundError (pip 의존성 미설치):
python ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-static-analysis/install.py1회 시도 후 러너 재실행. 여전히 실패하면 fail-open - 기타 exit != 0: stderr 로그를 사용자에게 전달, fail-open. code-analyzer 는 SQ 기반으로 계속 실행
3. 산출물 디렉토리 결정 (stdout 동적 파싱)
우선: Step 2 stdout 마지막 줄에서 <run_dir> 파싱. 사용자가 project-config.json 의 paths.review 를 커스터마이징할 수 있으므로 경로 하드코딩 금지.
예시:
- stdout:
cpp-static-analysis: .rkit\state\cpp-static-analysis\20260422-092153 (12 findings) - 파싱
run_dir = .rkit/state/cpp-static-analysis/20260422-092153(cwd 기준 상대, 또는 절대 경로 가능)
fallback (stdout 파싱 실패 또는 러너 미실행 시):
.rkit/state/cpp-static-analysis/latest/존재하면 사용- 없으면
.rkit/state/cpp-static-analysis/*/중 디렉토리 mtime 가장 큰 것 선택 (Windows symlink fallback) - 어떤 timestamp 폴더도 없으면 fail-open
정규식 힌트: stdout 마지막 줄에 ^cpp-static-analysis:\s*(\S.*?)\s*\(\d+ findings\)$ 매칭하여 그룹 1 추출.
4. 산출물 로드
- findings.xml: Read 또는 Grep. target 규모 크면
grep 'severity="blocker\|major"' findings.xml로 발췌 - structural-brief.md: Read 전문 (대형 프로젝트에서 토큰 이슈 나면 헤더 섹션만 추출)
5. code-analyzer Task 프롬프트 구성
기본 agent 프롬프트 뒤에 다음 컨텍스트 블록을 첨부해 Task 호출:
=== cpp-static-analysis findings ===
<findings.xml 발췌 또는 전문>
=== cpp-static-analysis structural-brief ===
<structural-brief.md 내용>
=== severity 매핑 가이드 ===
- blocker → CRITICAL 후보
- major + 클래스 그래프 이상치(zone_of_pain, cycle) → HIGH
- major 단독 → MEDIUM
- minor → LOW
(코드 대조 후 최종 severity 결정. 위는 신호일 뿐.)
=== end ===
6. rule 네임스페이스
- rkit SQ-001~008:
.rkit/state/code-quality-metrics.json로 기존대로 로드 - rapp rule (
class_DIT_high,AP-*,zone_of_pain,IDIOM-*등): 위 첨부 블록으로만 전달 - 두 카탈로그는 독립적으로 판정. 리포트에서 통합 severity 테이블로 출력
7. fail-open 원칙
위 절차 중 어느 단계든 실패 시 code-analyzer 호출은 그대로 진행 한다. 러너/Read/첨부 모두 보조 — 필수 아님. 기존 /code-review 플로우 회귀 금지.
Agent Integration
This Skill calls the code-analyzer Agent for in-depth code analysis.
| Agent | Role |
|---|---|
| code-analyzer | Code quality, security, performance analysis |
Usage Examples
# Review specific file
/code-review src/lib/auth.ts
# Review entire directory
/code-review src/features/user/
# PR review
/code-review pr 42
# Review current changes
/code-review staged
Confidence-Based Filtering
code-analyzer Agent uses confidence-based filtering:
| Confidence | Display | Description |
|---|---|---|
| High (90%+) | Always shown | Definite issues |
| Medium (70-89%) | Selectively shown | Possible issues |
| Low (<70%) | Hidden | Uncertain suggestions |
Auto-Fix Mode (--auto-fix)
When --auto-fix flag is provided:
- Requirement: Automation level L2+ (Semi-Auto or higher)
- Scope: Only Minor and Major issues are auto-fixed
- Critical issues: Always require manual review (never auto-fixed)
- Process:
- Run normal code review first
- Present findings summary
- Auto-apply fixes for Minor/Major issues
- Re-run review to verify fixes
- Report remaining issues (Critical only)
- Guard mode: Auto-fix is disabled when guard mode is active
PDCA Integration
- Phase: Check (Quality verification)
- Trigger: Auto-suggested after implementation
- Output: docs/03-analysis/code-review-{date}.md
자주 안 잡히는 검사 자동 생략 (Adaptive Gating)
동작 원리
/code-review시작 시.rkit/state/code-review-stats.json을 읽습니다 (parse 실패 시 빈 객체로 폴백 + 감사 로그 기록).- 각 검사(specialist)에 대해
gateStatus로 분기:gateStatus == "never_gate": 무조건 dispatch (5개 고정).gateStatus == "active": 정상 dispatch.gateStatus == "gate_candidate": 자동 생략 + 출력 "[검사명] 자동 생략됨 — 최근 N회 0 findings".
gate_candidate상태에서도 N=20 커밋마다 강제 1회 dispatch (probe).lastProbe필드로 추적.- 파일 패턴 변화 감지 시 카운터 리셋 (예: 신규 SKILL.md 등장).
--force-{이름}옵션 시 강제 dispatch.
통계 파일 스키마
위치: .rkit/state/code-review-stats.json. 갱신은 임시파일 + rename 패턴 (POSIX atomic write).
{
"version": "1.0",
"lastUpdated": "ISO8601",
"specialists": {
"<name>": {
"dispatchCount": 0,
"totalFindings": 0,
"lastDispatch": "ISO8601",
"gateStatus": "active|gate_candidate|never_gate",
"lastProbe": "ISO8601 또는 null"
}
}
}
gateStatus 결정 규칙
dispatchCount< 10 →active(안전 기본값, 통계 부족).dispatchCount≥ 10 ANDtotalFindings== 0 AND name ∉ NEVER_GATE →gate_candidate.- name ∈ NEVER_GATE →
never_gate.
NEVER_GATE 고정 5개
| 이름 | 이유 |
|---|---|
security | 안전망 (보안 위협은 단발이라도 차단) |
data_migration | 안전망 (데이터 손실 방지) |
skill_md_consistency | 본 sync 핵심 자산 (잠금 어휘 보존 검증) |
vocab_sync | SoT-부록 일관성 검증 |
eval_syntax | eval.yaml 구문 유효성 (CI 진입 전) |
자동 생략 사유 기록
자동 생략이 발생할 때마다 .rkit/state/skip-log.json에 append:
{
"timestamp": "ISO8601",
"specialist": "performance",
"reason": "gate_candidate (10회 0건)",
"reviewId": "rv-005",
"diffSize": 142
}
통계 갱신 (원자적 쓰기)
const tmpPath = path + '.tmp.' + Date.now();
fs.writeFileSync(tmpPath, JSON.stringify(stats, null, 2));
fs.renameSync(tmpPath, path); // POSIX atomic
리뷰 간 중복 제거 (Cross-Review Dedup)
동작 원리
.rkit/state/review-history.jsonl에서 최근 100 entries 윈도우만 읽습니다 (O(N) 디스크 I/O 방지).- 각 현재 리뷰 항목에 대해 다음 알고리즘:
function shouldSuppress(currentFinding, currentCommit):
recentHistory = readJsonlTail("review-history.jsonl", 100)
for each prevReview in recentHistory reversed:
for each prevFinding in prevReview.findings:
if prevFinding.fingerprint == currentFinding.fingerprint:
if prevFinding.action != "skipped":
return false // "fixed" / "auto_fixed"는 항상 재검사
try:
changedFiles = git_diff_name_only(prevReview.commit, currentCommit)
catch GitNotAvailable:
return false // 폴백: 보수적으로 재출력
if currentFinding.file in changedFiles:
return false // 파일 변경 → 재출력
return true // 모든 조건 통과 → 숨김
return false
- 출력 끝에 "이전 리뷰에서 사용자가 무시한 N건 숨김 처리됨" 요약.
식별값 (fingerprint)
5개 입력의 sha256:
fingerprint = sha256(
file_path + ":" + // POSIX 정규화 (slash 통일, lower)
line_number + ":" + // 정수
rule_id + ":" + // 검사 규칙 ID
severity + ":" + // critical|major|minor|info (lower_snake)
message_first_80_codepoints // 메시지 첫 80개 유니코드 코드포인트
)
이력 파일 스키마
위치: .rkit/state/review-history.jsonl (한 줄 한 리뷰, append-only, 줄당 ≤ 4096 byte).
{"timestamp":"ISO8601","reviewId":"rv-NNN","commit":"<sha>","schemaVersion":"1.0","findings":[{"fingerprint":"<sha256>","file":"...","line":N,"ruleId":"...","severity":"...","message":"...","action":"skipped|fixed|auto_fixed"}]}
큰 리뷰는 findings를 분할해 여러 줄로 작성 (각 줄 < 4096 byte).
원자적 append
const line = JSON.stringify(reviewEntry) + '\n';
if (Buffer.byteLength(line, 'utf8') > 4096) {
splitAndAppend(line); // findings 분할
} else {
fs.appendFileSync('.rkit/state/review-history.jsonl', line); // POSIX atomic < 4096
}
회전 정책
본 sync 사이클 미적용. 100 entries 윈도우 한정으로 검색 비용 한정. 이력 파일이 무한 누적되어도 검색 비용은 일정합니다. 회전 도입은 별 사이클로 이월합니다.
사용자 질문 양식
AskUserQuestion 호출 시 5요소 강제: 질문(≤90자) / ELI10(30~120자, 도메인 전문가 면제 가능) / 추천안+이유(중립 자세 허용) / 선택지마다 ✅ ≥ 2개·❌ ≥ 1개 (각 40자 이상) / 한 번뿐인 결정에는 "⚠️ 이 결정은 되돌릴 수 없습니다 — 신중히 선택하십시오" 표시.
ELI10은 전체 결정에 1회만 작성합니다.
도메인별 코드 리뷰 사례는 부록 §A를 참조하세요.
<!-- END: cycle15-body-neutral --><!-- BEGIN: locked-vocab-appendix (auto-generated by scripts/gen-locked-vocab.mjs) -->
부록 A: 도메인 예시
이 부록은
scripts/gen-locked-vocab.mjs가policies/locked-vocab.jsonSoT에서 자동 생성합니다. 직접 편집하지 마세요 —bun run gen:vocab또는node scripts/gen-locked-vocab.mjs로 재생성됩니다.
A.1 MCU 예시
잠금 어휘 (mcu)
| 어휘 | 의미 |
|---|---|
HardFault | Cortex-M 코어 예외 |
CFSR | 0xE000ED28, Configurable Fault Status Register |
HFSR | 0xE000ED2C, HardFault Status Register |
MMFAR | 0xE000ED34, MemManage Fault Address Register |
BFAR | 0xE000ED38, BusFault Address Register |
FreeRTOS | 임베디드 RTOS — xTaskCreate/Queue/Mutex/Semaphore |
MISRA C | 안전 임베디드 코딩 표준 (MISRA C:2012) |
시나리오
MCU 코드 리뷰 — FreeRTOS 태스크 스택 추정
발견: xTaskCreate에 STACK_SIZE 1024 byte 지정인데 uxTaskGetStackHighWaterMark 측정 시 942 byte 사용 — 여유 8% 미만. MISRA C 17.5 (Stack 사용 한도) 권고 위반 가능.
A.2 MPU 예시
잠금 어휘 (mpu)
| 어휘 | 의미 |
|---|---|
Device Tree | 리눅스 하드웨어 기술 트리 |
dtsi | Device Tree Source Include 파일 |
dtoverlay | Device Tree Overlay (런타임 수정) |
bblayers.conf | Yocto 레이어 설정 파일 |
Yocto | 임베디드 리눅스 빌드 시스템 |
bitbake | Yocto 빌드 도구 |
U-Boot | Bootloader |
시나리오
MPU 코드 리뷰 — Device Tree 파편화
발견: 동일 노드가 base dtsi와 dtoverlay에 중복 정의. bitbake 빌드 시 후자가 이김. 의도된 동작인지 dtsi 주석 추가 필요.
A.3 WPF 예시
잠금 어휘 (wpf)
| 어휘 | 의미 |
|---|---|
XAML | WPF/UWP UI 마크업 언어 |
MVVM | Model-View-ViewModel 패턴 |
ObservableObject | CommunityToolkit.Mvvm 베이스 클래스 |
RelayCommand | CommunityToolkit.Mvvm Command 속성 |
.csproj | C# 프로젝트 파일 |
app.config | .NET 응용 프로그램 설정 파일 |
시나리오
WPF 코드 리뷰 — ViewModel이 System.Windows.Controls 참조
발견: MainViewModel.cs가 System.Windows.Controls.TextBox 직접 참조. MVVM 위반 — View 계층으로 분리 필요. ObservableObject 속성으로 변환 권고.
<!-- END: locked-vocab-appendix -->