一键导入
token-efficiency-audit
Three-layer token defense stack — audit current settings, apply safe/CI levers, and monitor status
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Three-layer token defense stack — audit current settings, apply safe/CI levers, and monitor status
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Full R017 verification (5+3 rounds) before commit
Load a skill profile to switch active plugin set. Use when user wants to focus on a specific workflow (web-app/data-eng/harness-dev/minimal) and reduce skill enumeration block size per
6-stage structured development cycle with stage-based tool restrictions
Deploy applications to Vercel with auto-detection and preview URLs
Auto-detect project context and optimize harness — deactivate unused agents/skills, suggest missing experts, generate project profile
Monitor Claude Code releases and auto-generate GitHub issues for each new version
| name | token-efficiency-audit |
| description | Three-layer token defense stack — audit current settings, apply safe/CI levers, and monitor status |
| scope | package |
| user-invocable | true |
| argument-hint | [audit|apply-interactive|apply-ci|status] |
| version | 1.0.0 |
Layer 3 of the three-layer token defense stack. Audits current Claude Code settings against the token efficiency lever reference table, applies safe interactive levers, and reports combined layer status.
Reference guide: guides/claude-code/14-token-efficiency.md
┌─────────────────────────────────────────────────────────────────┐
│ Layer 1: cc-token-saver (CACHE DEFENSE) │
│ Before session — protect prompt cache TTL from idle expiry │
├─────────────────────────────────────────────────────────────────┤
│ Layer 2: R013 Ecomode (RUNTIME COMPRESSION) │
│ During session — compact output, aggregate results, prune input│
├─────────────────────────────────────────────────────────────────┤
│ Layer 3: token-efficiency-audit (PRE-SESSION PREVENTION) │
│ Config time — disable injections before they happen │
└─────────────────────────────────────────────────────────────────┘
Each layer is independently deployable and non-overlapping. Layer 3 (this skill) operates at config time — it prevents overhead from ever entering the context window.
.claude/settings.json (project-level, git-tracked).claude/settings.local.json (local, not git-tracked)includeGitInstructionsautoConnectIdeattribution.commitattribution.prenv.BASH_MAX_OUTPUT_LENGTHenv.CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENSenv.MAX_MCP_OUTPUT_TOKENS[Token Efficiency Audit]
Reference: guides/claude-code/14-token-efficiency.md (CC v2.1.114+)
| Lever | Current | Recommended | Gap | Location |
|-------------------------------------|-------------|-------------|--------|-----------------------|
| includeGitInstructions | true | false | ⚠ SET | settings.json |
| autoConnectIde | true | false | ⚠ SET | settings.json |
| attribution.commit | auto text | "" | ⚠ SET | settings.json |
| attribution.pr | auto text | "" | ⚠ SET | settings.json |
| BASH_MAX_OUTPUT_LENGTH | unlimited | 15000 | ⚠ SET | settings.local.json |
| CLAUDE_CODE_FILE_READ_MAX_OUTPUT... | unlimited | 8000 | ⚠ SET | settings.local.json |
| MAX_MCP_OUTPUT_TOKENS | unlimited | 8000 | ⚠ SET | settings.local.json |
Run /token-efficiency-audit apply-interactive to apply all safe levers.
Gap column values:
OK — already at recommended value⚠ SET — currently at default, recommended change availableCUSTOM — non-default value that differs from recommendation (display actual value)Applies Interactive Session Levers only (safe for development use).
.claude/settings.json and .claude/settings.local.json (create if not exists)settings.json:
{
"includeGitInstructions": false,
"autoConnectIde": false,
"attribution": {
"commit": "",
"pr": ""
}
}
settings.local.json (env block):
{
"env": {
"BASH_MAX_OUTPUT_LENGTH": "15000",
"CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS": "8000",
"MAX_MCP_OUTPUT_TOKENS": "8000"
}
}
[Done] Interactive levers applied
settings.json:
includeGitInstructions: true → false
autoConnectIde: true → false
attribution.commit: (auto) → ""
attribution.pr: (auto) → ""
settings.local.json:
BASH_MAX_OUTPUT_LENGTH: (none) → 15000
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS: (none) → 8000
MAX_MCP_OUTPUT_TOKENS: (none) → 8000
Note: settings.json is git-tracked. Commit if appropriate.
Takes effect on next claude session restart.
Applies CI/Worker-Only Levers. These disable core oh-my-customcode functionality.
R001 Risk: HIGH — Display this warning prominently BEFORE applying:
⚠ WARNING — CI/WORKER LEVERS
These settings disable core oh-my-customcode functionality:
• CLAUDE_CODE_DISABLE_CLAUDE_MDS=1 → ALL rules and routing offline (R010 disabled)
• CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS=1 → All 49 agents unavailable
• ENABLE_CLAUDEAI_MCP_SERVERS=false → MCP-dependent skills unavailable
• CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 → No persistent memory across sessions
Only use for CI/worker pipelines. Never apply to interactive development sessions.
Type "yes" to confirm, or anything else to cancel:
settings.local.json:
{
"env": {
"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1",
"CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS": "1",
"ENABLE_CLAUDEAI_MCP_SERVERS": "false",
"CLAUDE_CODE_DISABLE_AUTO_MEMORY": "1"
}
}
[Done] CI/Worker levers applied to settings.local.json
This file is NOT git-tracked.
To undo: remove the four env keys or run /token-efficiency-audit status
[Cancelled] No changes made.Reports current state of all three layers.
.claude/ plugin config or known plugin markers).claude/settings.json for ecomode configaudit modeCLAUDE_CODE_ENABLE_TELEMETRY in settings[Token Efficiency Status]
Layer 1: cc-token-saver ✓ Installed / ✗ Not installed
Layer 2: R013 Ecomode ✓ Active (threshold: 4) / ✗ Not configured
Layer 3: Settings levers 4/7 at recommended
Layer 3 details:
includeGitInstructions: false ✓
autoConnectIde: true ⚠
attribution.commit: "" ✓
attribution.pr: "" ✓
BASH_MAX_OUTPUT_LENGTH: 15000 ✓
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS: unlimited ⚠
MAX_MCP_OUTPUT_TOKENS: unlimited ⚠
Run /token-efficiency-audit apply-interactive to fix ⚠ levers.
OTel: not enabled — run /monitoring-setup enable to measure effectiveness.
When Codex CLI is in use (detected by presence of ~/.codex/config.toml):
Recommended settings in config.toml:
[features]
apps = false
[apps._default]
enabled = false
web_search = "disabled"
tool_output_token_limit = 10000
Non-interactive Codex CLI flag reference: guides/claude-code/13-cli-flags.md
Setting output limits too low forces repeated re-call loops — the model issues tail -n 50 output.txt or re-reads files in chunks, costing more tokens than the original uncapped output.
Enforce these minimum floors (never go below):
| Variable | Safe minimum | Recommended |
|---|---|---|
BASH_MAX_OUTPUT_LENGTH | 10000 | 15000 |
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS | 4000 | 8000 |
MAX_MCP_OUTPUT_TOKENS | 4000 | 8000 |
Codex tool_output_token_limit | 5000 | 10000 |
If a user requests values below these floors, warn them of the re-call trap risk before applying.
Settings defaults change with minor CC version releases. After each upgrade, re-run /token-efficiency-audit audit to verify active defaults. Reference baseline: CC v2.1.114+ / Codex v0.121.0+.
guides/claude-code/14-token-efficiency.md — Full three-layer stack guide and lever table.claude/rules/SHOULD-ecomode.md (R013) — Layer 2 specification.claude/skills/monitoring-setup/SKILL.md — Measure effectiveness via OTel metricsguides/cc-token-saver/README.md — Layer 1 detailed guideguides/claude-code/13-cli-flags.md — Non-interactive/CI CLI flags