跳到正文
cccskills
免费在 GitHub 公开

context-attribution

Estimate per-turn token attribution across 6 categories in Claude Code sessions to show where context budget is spent

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(10)

  • SKILL.md3.6 KB
  • commands/context-attribution.md119 B
  • hooks/post-execute.cjs191 B
  • hooks/pre-execute.cjs297 B
  • references/research-requirements.md529 B
  • rules/context-attribution.md325 B
  • schemas/input.schema.json441 B
  • schemas/output.schema.json303 B
  • scripts/main.cjs656 B
  • templates/implementation-template.md320 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Context Attribution

Estimate per-turn token attribution across 6 categories in Claude Code sessions. Based on claude-devtools visible context tracker.

When to Invoke

Skill({ skill: 'context-attribution' });

Use when: context pressure is high, optimizing CLAUDE.md sizes, understanding which tool calls consume the most tokens, debugging context overflow.

The 6 Categories

CategoryDetection PatternTypical %
CLAUDE.md filesSystem messages with claudeMd or CLAUDE.md content20-40%
@-mentioned filesRead tool results triggered by user file references10-20%
Tool outputsAll tool_result content blocks15-30%
AI thinking/textAssistant message content (text + thinking blocks)10-25%
Team coordinationMessages containing <teammate-message> XML0-15%
User messagesUser role messages (prompts, follow-ups)5-15%

Workflow

Step 1: Load Session JSONL

# Find most recent session
SESSION=$(ls -t ~/.claude/projects/$(pwd | sed 's|/|-|g; s|^-||')/*.jsonl | head -1)

Step 2: Extract Per-Turn Token Data

For each message, classify into one of the 6 categories and estimate tokens:

# Count user messages (Category 6)
grep '"role":"user"' "$SESSION" | grep -v '"tool_result"' | wc -l

# Count tool results (Categories 2-3)
grep '"type":"tool_result"' "$SESSION" | wc -l

# Count assistant output (Category 4)
grep '"role":"assistant"' "$SESSION" | wc -l

# Check for team messages (Category 5)
grep 'teammate-message' "$SESSION" | wc -l

Step 3: Estimate Tokens Per Category

Use the usage field from each assistant turn for accurate counts. Fall back to chars/4 when unavailable.

Step 4: Output Attribution Table

Turn | CLAUDE.md | Files | Tools | AI Out | Team | User | Total
-----|-----------|-------|-------|--------|------|------|------
  1  |   12,400  |     0 |     0 |    800 |    0 |  200 | 13,400
  2  |        0  | 3,200 | 1,500 |  2,100 |    0 |  150 |  6,950
...  |      ...  |   ... |   ... |    ... |  ... |  ... |   ...

Step 5: Identify Top Consumers

Report which category consumes the most tokens and suggest optimizations (e.g., reduce CLAUDE.md size, compress tool outputs).

Memory Protocol (MANDATORY)

Before starting: ```bash cat .claude/context/memory/learnings.md cat .claude/context/memory/decisions.md ```

After completing:

  • New pattern -> `.claude/context/memory/learnings.md`
  • Issue found -> `.claude/context/memory/issues.md`
  • Decision made -> `.claude/context/memory/decisions.md`

ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Ensure accessibility in UI components including semantic HTML, ARIA attributes, keyboard navigation, and WCAG 2.2 AA compliance.

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

Use when you want to improve response quality through meta-cognitive reasoning. Applies 15+ reasoning methods to reconsider and refine initial outputs.

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

N-round opposing-stance debates for trade-off analysis. Assigns pro/con roles to agents, runs structured debate rounds with quality scoring, and produces a moderator synthesis with confidence-rated recommendation. Generalizable to architecture, technology, security, and design decisions.

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

Force adversarial code review stance that eliminates confirmation bias — reviewer must find issues or re-analyze

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

Creates specialized AI agents on-demand when no existing agent matches a request. Use when the Router cannot find a suitable agent for a task. Enables self-evolution by generating persistent agents.

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

LLM-as-judge evaluation framework with 5-dimension rubric (accuracy, groundedness, coherence, completeness, helpfulness) for scoring AI-generated content quality with weighted composite scores and evidence citations

中文简介正在准备中。当前显示原文说明。

oimiragieo/agent-studio422026年7月14日 更新

查看 oimiragieo 的全部技能

报告此技能的问题