AgentSkillsCN

Token Budget Check

针对任务流程、线框图、无障碍设计及用户交互,打造优质用户体验模式

SKILL.md
--- frontmatter
skill_name: token-budget-check
skill_category: documentation
description: Analyze markdown files for token budget compliance
allowed_tools: [Read, Bash, Glob]
token_estimate: 850
version: 1.0
last_updated: 2025-12-21
owner: Claude Copilot
status: active
tags: [tokens, documentation, budget, validation, shared-docs]
related_skills: [frontmatter-validation, link-validation]
trigger_files: ["*.md", "**\/docs/**\/*.md", "**\/documentation/**\/*.md"]
trigger_keywords: [token, budget, documentation, word-count, tokens, over-budget]

Token Budget Check

Analyze markdown files to ensure they comply with token budget guidelines.

Purpose

Shared-docs files have token budgets to optimize AI ingestion. This skill checks files against those budgets and suggests optimizations when over budget.

Token Budgets by Document Type

Document TypeMax TokensMax Words
Skill (SKILL.md)2,0001,400
Product overview800560
Product architecture1,200840
Product API summary1,000700
Product integration800560
Operational guide4,0002,800
Agent profile2,0001,400
Index/navigation400280

Procedure

1. Identify Target Files

If a specific file is provided, check that file. Otherwise, scan the directory:

bash
find . -name "*.md" -type f | head -20

2. Calculate Token Estimate

For each file, estimate tokens (words × 1.4):

bash
file="path/to/file.md"
words=$(wc -w < "$file" | tr -d ' ')
tokens=$((words * 14 / 10))
echo "$file: ~$tokens tokens ($words words)"

3. Determine Document Type

Infer type from:

  • Filename: SKILL.md → skill, 00-overview.md → overview
  • Path: 02-products/ → product doc, 03-ai-enabling/02-profiles/ → agent profile
  • Frontmatter: doc_type field if present

4. Compare Against Budget

StatusConditionAction
OKUnder budgetReport as compliant
WARNING80-100% of budgetSuggest review
OVERExceeds budgetAnalyze and suggest cuts

5. If Over Budget, Analyze Content

Identify optimization opportunities:

  • Prose that could be tables (30-50% savings)
  • Redundant explanations
  • Examples that could be shortened
  • Content that belongs in linked docs

Output Format

markdown
## Token Budget Report

### Summary
- Files checked: N
- Compliant: N
- Warnings: N
- Over budget: N

### Details

| File | Type | Tokens | Budget | Status |
|------|------|--------|--------|--------|
| path/to/file.md | skill | 1,850 | 2,000 | OK |
| path/to/doc.md | overview | 950 | 800 | OVER (+150) |

### Recommendations

#### path/to/doc.md (950 tokens, budget 800)
- Lines 45-60: Convert feature list to table (-80 tokens)
- Lines 72-85: Remove redundant introduction (-50 tokens)

Efficiency Patterns Reference

PatternToken Savings
Tables over prose30-50%
Bullet points over paragraphs20-30%
Omit articles in table cells5-10%
Use abbreviations (env, config, auth)5-10%
Remove redundant headers5-10%