context-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Usage Audit

使用审计

Bloated context costs more and produces worse output. This skill finds the waste and tells you what to cut.
冗余的上下文会增加成本并降低输出质量。本skill可找出冗余部分并告诉你需要精简的内容。

Step 1: Get /context Data

步骤1:获取/context数据

Check the conversation history for /context output. If the user already ran /context in this session, use that data. If not, ask:
"Run /context in this session terminal and let me know when you're done. I can't run slash commands myself, but once I can see the breakdown I'll audit everything it flags."
STOP HERE. Do NOT proceed to Step 2 until the user has ran /context. The context breakdown determines what to audit and in what order. Without it, the audit is guessing. Output the message above and wait for the user's next message.
查看对话历史中的/context输出。如果用户已在本次会话中执行过/context,则使用该数据。若未执行,请询问:
"请在本次会话终端中执行/context命令,完成后告知我。我无法自行执行斜杠命令,但一旦能看到上下文细分情况,我就会审计所有标记的问题。"
在此处停止。在用户执行/context之前,请勿进入步骤2。上下文细分结果决定了审计的内容和顺序。没有该数据,审计就只能靠猜测。输出上述消息并等待用户的下一条回复。

Step 2: Audit What's Bloated

步骤2:审计冗余内容

Based on the /context output, audit each category from largest to smallest. Run checks in parallel where possible.
根据/context的输出,按从大到小的顺序审计每个类别。尽可能并行执行检查。

MCP Servers

MCP服务器

Each server loads full tool definitions into context every turn (~15,000-20,000 tokens each).
  • Count configured servers from settings.json
  • Flag any with CLI alternatives (Playwright, Google Workspace, GitHub all have CLIs that cost zero tokens when idle)
  • Report total MCP overhead from /context output
每个服务器每次交互都会将完整的工具定义加载到上下文中(每个约15,000-20,000 tokens)。
  • 从settings.json统计已配置的服务器数量
  • 标记任何有CLI替代方案的服务器(Playwright、Google Workspace、GitHub都有闲置时token消耗为零的CLI工具)
  • 从/context输出中报告MCP的总开销

CLAUDE.md

CLAUDE.md

Read all CLAUDE.md files (project root, .claude/, ~/.claude/). Count lines. Then read every rule and test against five filters:
FilterFlag when...
DefaultClaude already does this without being told ("write clean code", "handle errors")
ContradictionConflicts with another rule in same or different file
RedundancyRepeats something already covered elsewhere
BandaidAdded to fix one bad output, not improve outputs generally
VagueInterpreted differently every time ("be natural", "use good tone")
If total CLAUDE.md lines > 200, check for progressive disclosure opportunities: rules that only apply to specific tasks (API conventions, deployment steps, testing guidelines) should move to reference files with one-line pointers. Only recommend splitting when the file is actually bloated -- a lean CLAUDE.md with universal context is fine as a single file.
读取所有CLAUDE.md文件(项目根目录、.claude/、~/.claude/)。统计行数。然后逐条读取规则并通过以下五个筛选条件进行测试:
筛选条件标记情况
默认能力Claude无需额外告知就已具备该能力(如“编写整洁代码”、“处理错误”)
矛盾冲突与同一文件或其他文件中的另一条规则冲突
重复冗余重复了已在其他地方涵盖的内容
临时补丁仅为修复某次糟糕输出而添加,并非普遍提升输出质量
表述模糊每次解读都不一致(如“自然表述”、“使用良好语气”)
如果CLAUDE.md总行数>200,检查是否有渐进式披露的机会:仅适用于特定任务的规则(API规范、部署步骤、测试指南)应移至参考文件,仅保留一行指向该文件的提示。仅当文件确实冗余时才建议拆分——内容精简、包含通用上下文的CLAUDE.md作为单个文件是没问题的。

Skills

Skills

Scan .claude/skills/*/SKILL.md. For each skill:
  • Count lines (flag > 200, critical > 500)
  • Run the same five filters on instructions
  • Check for restated goals, hedging ("you may want to"), synonymous instructions ("be concise" + "keep it short" + "don't be verbose")
扫描.claude/skills/*/SKILL.md文件。针对每个skill:
  • 统计行数(>200行标记,>500行严重标记)
  • 对说明内容应用相同的五个筛选条件
  • 检查是否存在重复目标、模糊表述(如“你可能想要”)、同义指令(如“简洁表述”+“保持简短”+“不要冗长”)

Settings

设置

Check settings.json for:
SettingFlag ifRecommended
autocompact_percentage_overrideMissing or > 8075
BASH_MAX_OUTPUT_LENGTH (env)At default (30-50K)150000
检查settings.json中的以下设置:
设置项标记条件推荐值
autocompact_percentage_override缺失或>8075
BASH_MAX_OUTPUT_LENGTH(环境变量)为默认值(30-50K)150000

Hooks

钩子(Hooks)

Check settings.json for
hooks
configuration. For each hook:
  • Flag hooks that run slow commands (network calls, heavy builds)
  • Flag hooks with no timeout configured
  • Check if any hook runs on high-frequency events (e.g., every tool call) where latency compounds
检查settings.json中的
hooks
配置。针对每个钩子:
  • 标记执行慢命令的钩子(网络调用、重型构建)
  • 标记未配置超时的钩子
  • 检查是否有钩子在高频事件(如每次工具调用)中运行,此类情况会导致延迟累积

Memory Files

记忆文件

Glob
~/.claude/projects/*/memory/*.md
. For each memory directory:
  • Count total files and estimate total lines
  • Flag stale memories (check if referenced project paths still exist)
  • Flag memories > 50 lines (memories should be concise pointers, not docs)
  • Flag memory directories with > 20 files (index bloat)
遍历
~/.claude/projects/*/memory/*.md
文件。针对每个记忆目录:
  • 统计总文件数并估算总行数
  • 标记过期记忆(检查引用的项目路径是否仍存在)
  • 标记>50行的记忆(记忆应是简洁的指向性内容,而非文档)
  • 标记文件数>20的记忆目录(索引冗余)

.claudeignore

.claudeignore

Check if
.claudeignore
exists in the project root. If missing and the project has large generated/indexed directories, recommend creating one. Key patterns to check for:
  • Large data directories (fixtures, seeds, dumps)
  • Generated docs (typedoc, javadoc, storybook-static)
  • Monorepo packages the user isn't actively working on
检查项目根目录是否存在
.claudeignore
文件。若缺失且项目包含大型生成/索引目录,建议创建该文件。需检查的关键模式:
  • 大型数据目录(fixtures、seeds、dumps)
  • 生成的文档(typedoc、javadoc、storybook-static)
  • 用户未在积极开发的单仓库包

File Permissions

文件权限

Check settings.json for
permissions.deny
rules. If missing, check whether bloat directories exist in the project:
If this exists...Should deny...
.git.git
package.jsonnode_modules, dist, build, .next, .nuxt, .cache, coverage
Cargo.tomltarget
go.modvendor
pyproject.toml / requirements.txtpycache, .venv, *.egg-info
检查settings.json中的
permissions.deny
规则。若缺失,检查项目中是否存在冗余目录:
若存在...应拒绝访问...
.git.git
package.jsonnode_modules, dist, build, .next, .nuxt, .cache, coverage
Cargo.tomltarget
go.modvendor
pyproject.toml / requirements.txtpycache, .venv, *.egg-info

Step 3: Score and Report

步骤3:评分与报告

Score starts at 100. Deduct per issue:
IssuePoints
CLAUDE.md > 200 lines-10
CLAUDE.md > 500 lines-20
Per 5 rules flagged by filters-5
Contradictions between files-10
Missing autocompact override-10
Missing bash output override-5
Skill > 200 lines-5 each
Skill > 500 lines-10 each
Per MCP server-3 each
No deny rules + bloat dirs exist-10
Hook with no timeout on frequent event-5 each
Stale or oversized memory files-5
Memory directory > 20 files-5
Missing .claudeignore + large dirs exist-5
Floor at 0. Output this format:
undefined
初始评分为100分,根据问题扣分:
问题扣分
CLAUDE.md >200行-10
CLAUDE.md >500行-20
每5条被筛选标记的规则-5
文件间存在矛盾冲突-10
缺失自动压缩覆盖设置-10
缺失bash输出覆盖设置-5
Skill >200行每个扣-5
Skill >500行每个扣-10
每个MCP服务器每个扣-3
无拒绝规则且存在冗余目录-10
高频事件中运行的无超时钩子每个扣-5
过期或过大的记忆文件-5
记忆目录文件数>20-5
缺失.claudeignore且存在大型目录-5
最低分为0分。输出格式如下:
undefined

Usage Audit

使用审计

Score: {N}/100 [{CLEAN|NEEDS WORK|BLOATED|CRITICAL}]
评分: {N}/100 [{CLEAN|NEEDS WORK|BLOATED|CRITICAL}]

Context Breakdown (from /context)

上下文细分(来自/context)

{Paste the key numbers from /context output}
{粘贴/context输出中的关键数据}

Issues Found

发现的问题

[{CRITICAL|WARNING|INFO}] {Category}

[{CRITICAL|WARNING|INFO}] {类别}

{What's wrong} Fix: {One-line actionable fix}
{问题描述} 修复方案: {一行可执行的修复建议}

Rules to Cut

需移除的规则

{Each flagged rule: the text, which filter, one-line reason}
{每条被标记的规则:规则文本、所属筛选条件、一行原因说明}

Conflicts

冲突情况

{Contradictions between files, with paths}
{文件间的矛盾冲突,包含文件路径}

Top 3 Fixes

三大优先修复项

  1. {Highest-impact fix}
  2. {Second}
  3. {Third}

Score labels: 90-100 CLEAN, 70-89 NEEDS WORK, 50-69 BLOATED, 0-49 CRITICAL.
Severity: CRITICAL > 10pts, WARNING 5-10pts, INFO < 5pts.
  1. {影响最大的修复方案}
  2. {次优修复方案}
  3. {第三优先修复方案}

评分标签:90-100分 → CLEAN,70-89分 → NEEDS WORK,50-69分 → BLOATED,0-49分 → CRITICAL。
严重程度:CRITICAL >10分,WARNING 5-10分,INFO <5分。

Step 4: Offer to Fix

步骤4:提供修复服务

After the report:
"Want me to fix any of these? I can:
  • Show you a cleaned-up CLAUDE.md with the flagged rules removed
  • Add the missing settings.json configs
  • Add permissions.deny rules for build artifacts
  • Add timeouts to hooks missing them
  • Clean up stale memory files
  • Generate a .claudeignore for this project
  • Show which skills to compress"
Auto-apply settings.json and permissions.deny (safe, reversible). Show diffs for CLAUDE.md and skills -- let the user confirm before modifying instruction files.
报告生成后:
“需要我帮你修复这些问题吗?我可以:
  • 为你展示移除标记规则后的精简版CLAUDE.md
  • 添加缺失的settings.json配置
  • 为构建产物添加permissions.deny规则
  • 为缺失超时设置的钩子添加超时
  • 清理过期的记忆文件
  • 为当前项目生成.claudeignore文件
  • 告知你需要压缩的skills”
可自动应用settings.json和permissions.deny的修复(安全且可撤销)。对于CLAUDE.md和skills的修改,需先展示差异,获得用户确认后再修改指令文件。