Content
# cc-audit
A Claude Code skill that audits your Claude Code setup — model config, MCP servers, rules bloat, cache efficiency, and context usage — in one command.
## What it checks
| Category | Details |
|----------|---------|
| **Static config** | Default model, hooks coverage, MCP count |
| **Rules bloat** | Line counts, project-specific rules leaking into global |
| **Session analysis** | Cache hit/miss, idle time, context %, model switches, image-induced cache breaks, /compact usage |
| **Official best practices** | Live search against Claude Code docs — compares your setup against current recommendations |
## Install
Paste this into any Claude Code session:
```
請安裝這個 skill:https://github.com/danyuchn/cc-audit
步驟:
1. git clone https://github.com/danyuchn/cc-audit /tmp/cc-audit-install
2. mkdir -p ~/.claude/skills/cc-audit
3. cp /tmp/cc-audit-install/SKILL.md ~/.claude/skills/cc-audit/
4. rm -rf /tmp/cc-audit-install
```
Or manually:
```bash
mkdir -p ~/.claude/skills/cc-audit
curl -fsSL https://raw.githubusercontent.com/danyuchn/cc-audit/main/SKILL.md \
-o ~/.claude/skills/cc-audit/SKILL.md
```
## Usage
After installing, trigger with any of:
```
/cc-audit
健診
幫我審查 Claude Code
quota 檢查
```
## Sample output
```
### 1. 設定快照
預設模型: sonnet ✅
Hooks: PreToolUse / PostToolUse / PostCompact / TaskCreated ✅
MCP 數量: 6
### 2. Session 健診
專案 模型 閒置(分) CacheMiss 圖破快取 Context% 換模型 /compact 輪數
knowledge-base claude-sonnet-4-6 ✅ 3.8 ✅0 ✅0 ✅ 33.0% ✅ - 42
claude-course claude-sonnet-4-6 🟡 13.6 🟡2 ✅0 🟡 92.6% ✅ 🟡 84
### 3. 官方最佳實踐 vs 目前設定
📌 ...(即時查詢官方文件)
### 5. 可執行建議
🔴 wordpress.md 在 global rules → 移到專案的 .claude/rules/
🟡 claude-course context 超 80% 但未 /compact → 養成 60% 就壓縮的習慣
```
## How it works
- **Static checks**: reads `~/.claude/settings.json` and `~/.claude.json`
- **Session analysis**: parses the 5 most recent JSONL files in `~/.claude/projects/`
- **Cache detection**: `cache_creation_input_tokens` spike + `cache_read_input_tokens` drop = confirmed cache miss
- **Context %**: `(input + cache_create + cache_read) / 200,000`
- **Official docs**: live WebSearch against `code.claude.com` and `docs.anthropic.com`
## Requirements
- Claude Code with a valid subscription
- Python 3 (pre-installed on macOS/Linux)
- `gh` CLI (only needed if you want to contribute)