nav-stats

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Navigator Session Statistics Skill

Navigator 会话统计Skill

Show real-time efficiency reporting with baseline comparisons, making Navigator's value quantifiable and shareable.
展示带有基准对比的实时效率报告,让Navigator的价值可量化、可分享。

When to Invoke

调用时机

Invoke this skill when the user:
  • Says "show my stats", "show session stats", "show metrics"
  • Asks "how efficient am I?", "how much did I save?"
  • Says "show my Navigator report", "efficiency report"
  • Wants to see token savings or session performance
  • Says "show impact", "prove Navigator works"
DO NOT invoke if:
  • User just started session (< 5 messages)
  • Navigator not initialized in project
  • User asking about specific metrics only (answer directly)
当用户出现以下情况时调用此Skill:
  • 说出“显示我的统计数据”“显示会话统计”“显示指标”
  • 询问“我的效率如何?”“我节省了多少?”
  • 说出“显示我的Navigator报告”“效率报告”
  • 想要查看Token节省量或会话性能
  • 说出“显示作用”“证明Navigator有效”
请勿调用的情况:
  • 用户刚开启会话(消息数<5条)
  • 项目中未初始化Navigator
  • 用户仅询问特定指标(直接回答即可)

Execution Steps

执行步骤

Step 1: Check Navigator Initialized

步骤1:检查Navigator是否初始化

Verify Navigator is set up:
bash
if [ ! -f ".agent/DEVELOPMENT-README.md" ]; then
  echo "❌ Navigator not initialized in this project"
  echo "Run 'Initialize Navigator' first"
  exit 1
fi
验证Navigator已配置完成:
bash
if [ ! -f ".agent/DEVELOPMENT-README.md" ]; then
  echo "❌ Navigator not initialized in this project"
  echo "Run 'Initialize Navigator' first"
  exit 1
fi

Step 2: Run Enhanced Session Stats

步骤2:运行增强版会话统计脚本

Execute the enhanced session statistics script:
bash
undefined
执行增强版会话统计脚本:
bash
undefined

Check if enhanced script exists

Check if enhanced script exists

if [ ! -f "scripts/session-stats.sh" ]; then echo "❌ Session stats script not found" echo "This feature requires Navigator v3.5.0+" exit 1 fi
if [ ! -f "scripts/session-stats.sh" ]; then echo "❌ Session stats script not found" echo "This feature requires Navigator v3.5.0+" exit 1 fi

Run stats script

Run stats script

bash scripts/session-stats.sh

This script outputs shell-parseable variables:
- `BASELINE_TOKENS` - Total size of all .agent/ docs
- `LOADED_TOKENS` - Actually loaded in session (estimated)
- `TOKENS_SAVED` - Difference
- `SAVINGS_PERCENT` - Percentage saved
- `EFFICIENCY_SCORE` - 0-100 score
- `CACHE_EFFICIENCY` - From OpenTelemetry
- `CONTEXT_USAGE_PERCENT` - Estimated context fill
- `TIME_SAVED_MINUTES` - Estimated time saved
bash scripts/session-stats.sh

该脚本输出可被Shell解析的变量:
- `BASELINE_TOKENS` - 所有.agent/文档的总大小
- `LOADED_TOKENS` - 会话中实际加载的Token量(估算值)
- `TOKENS_SAVED` - 两者差值
- `SAVINGS_PERCENT` - 节省百分比
- `EFFICIENCY_SCORE` - 0-100分的效率得分
- `CACHE_EFFICIENCY` - 来自OpenTelemetry的缓存效率
- `CONTEXT_USAGE_PERCENT` - 估算的上下文填充率
- `TIME_SAVED_MINUTES` - 估算的节省时长

Step 3: Calculate Efficiency Score

步骤3:计算效率得分

Use predefined function to calculate score:
bash
undefined
使用预定义函数计算得分:
bash
undefined

Extract metrics from session-stats.sh

Extract metrics from session-stats.sh

source <(bash scripts/session-stats.sh)
source <(bash scripts/session-stats.sh)

Calculate efficiency score using predefined function

Calculate efficiency score using predefined function

EFFICIENCY_SCORE=$(python3 skills/nav-stats/functions/efficiency_scorer.py
--tokens-saved-percent ${SAVINGS_PERCENT}
--cache-efficiency ${CACHE_EFFICIENCY}
--context-usage ${CONTEXT_USAGE_PERCENT})
undefined
EFFICIENCY_SCORE=$(python3 skills/nav-stats/functions/efficiency_scorer.py
--tokens-saved-percent ${SAVINGS_PERCENT}
--cache-efficiency ${CACHE_EFFICIENCY}
--context-usage ${CONTEXT_USAGE_PERCENT})
undefined

Step 4: Format and Display Report

步骤4:格式化并展示报告

Use predefined function to format visual report:
bash
undefined
使用预定义函数将指标格式化为可视化报告:
bash
undefined

Generate formatted report

Generate formatted report

python3 skills/nav-stats/functions/report_formatter.py
--baseline ${BASELINE_TOKENS}
--loaded ${LOADED_TOKENS}
--saved ${TOKENS_SAVED}
--savings-percent ${SAVINGS_PERCENT}
--cache-efficiency ${CACHE_EFFICIENCY}
--context-usage ${CONTEXT_USAGE_PERCENT}
--efficiency-score ${EFFICIENCY_SCORE}
--time-saved ${TIME_SAVED_MINUTES}

**Output Format**:
╔══════════════════════════════════════════════════════╗ ║ NAVIGATOR EFFICIENCY REPORT ║ ╚══════════════════════════════════════════════════════╝
📊 TOKEN USAGE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Documentation loaded: 12,000 tokens Baseline (all docs): 150,000 tokens Tokens saved: 138,000 tokens (92% ↓)
💾 CACHE PERFORMANCE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Cache efficiency: 100.0% (perfect)
📈 SESSION METRICS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Context usage: 35% (excellent) Efficiency score: 94/100 (excellent)
⏱️ TIME SAVED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Estimated time saved: ~42 minutes
💡 WHAT THIS MEANS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Navigator loaded 92% fewer tokens than loading all docs. Your context window is 65% available for actual work.
🎯 RECOMMENDATIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ Excellent efficiency - keep using lazy-loading strategy ✅ Context usage healthy - plenty of room for work
Share your efficiency: Take a screenshot! #ContextEfficiency
undefined
python3 skills/nav-stats/functions/report_formatter.py
--baseline ${BASELINE_TOKENS}
--loaded ${LOADED_TOKENS}
--saved ${TOKENS_SAVED}
--savings-percent ${SAVINGS_PERCENT}
--cache-efficiency ${CACHE_EFFICIENCY}
--context-usage ${CONTEXT_USAGE_PERCENT}
--efficiency-score ${EFFICIENCY_SCORE}
--time-saved ${TIME_SAVED_MINUTES}

**输出格式**:
╔══════════════════════════════════════════════════════╗ ║ NAVIGATOR EFFICIENCY REPORT ║ ╚══════════════════════════════════════════════════════╝
📊 TOKEN USAGE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Documentation loaded: 12,000 tokens Baseline (all docs): 150,000 tokens Tokens saved: 138,000 tokens (92% ↓)
💾 CACHE PERFORMANCE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Cache efficiency: 100.0% (perfect)
📈 SESSION METRICS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Context usage: 35% (excellent) Efficiency score: 94/100 (excellent)
⏱️ TIME SAVED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Estimated time saved: ~42 minutes
💡 WHAT THIS MEANS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Navigator loaded 92% fewer tokens than loading all docs. Your context window is 65% available for actual work.
🎯 RECOMMENDATIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ Excellent efficiency - keep using lazy-loading strategy ✅ Context usage healthy - plenty of room for work
Share your efficiency: Take a screenshot! #ContextEfficiency
undefined

Step 5: Add Context-Specific Recommendations

步骤5:添加上下文相关的建议

Based on efficiency score, provide actionable advice:
If efficiency_score < 70:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Token savings below target (70%+)
→ Check: Are you loading more docs than needed?
→ Tip: Use navigator to find docs, don't load all upfront

Read more: .agent/philosophy/CONTEXT-EFFICIENCY.md
If context_usage > 80%:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Context usage high (80%+)
→ Consider: Create context marker and compact
→ Tip: Compact after completing sub-tasks

Read more: .agent/philosophy/ANTI-PATTERNS.md
If cache_efficiency < 80%:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Cache efficiency low (<80%)
→ Check: CLAUDE.md properly configured?
→ Tip: Ensure prompt caching enabled

Read more: .agent/philosophy/PATTERNS.md (Caching pattern)
根据效率得分,提供可执行的建议:
如果efficiency_score < 70:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Token savings below target (70%+)
→ Check: Are you loading more docs than needed?
→ Tip: Use navigator to find docs, don't load all upfront

Read more: .agent/philosophy/CONTEXT-EFFICIENCY.md
如果context_usage > 80%:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Context usage high (80%+)
→ Consider: Create context marker and compact
→ Tip: Compact after completing sub-tasks

Read more: .agent/philosophy/ANTI-PATTERNS.md
如果cache_efficiency < 80%:
⚠️  RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  Cache efficiency low (<80%)
→ Check: CLAUDE.md properly configured?
→ Tip: Ensure prompt caching enabled

Read more: .agent/philosophy/PATTERNS.md (Caching pattern)

Predefined Functions

预定义函数

efficiency_scorer.py

efficiency_scorer.py

Calculate Navigator efficiency score (0-100) based on:
  • Token savings (40 points)
  • Cache efficiency (30 points)
  • Context usage (30 points)
Usage:
bash
python3 skills/nav-stats/functions/efficiency_scorer.py \
  --tokens-saved-percent 92 \
  --cache-efficiency 100 \
  --context-usage 35
Output:
94
(integer score)
基于以下指标计算Navigator效率得分(0-100分):
  • Token节省量(40分)
  • 缓存效率(30分)
  • 上下文使用率(30分)
使用方式:
bash
python3 skills/nav-stats/functions/efficiency_scorer.py \
  --tokens-saved-percent 92 \
  --cache-efficiency 100 \
  --context-usage 35
输出:
94
(整数得分)

report_formatter.py

report_formatter.py

Format efficiency metrics into visual, shareable report.
Usage:
bash
python3 skills/nav-stats/functions/report_formatter.py \
  --baseline 150000 \
  --loaded 12000 \
  --saved 138000 \
  --savings-percent 92 \
  --cache-efficiency 100 \
  --context-usage 35 \
  --efficiency-score 94 \
  --time-saved 42
Output: Formatted ASCII report (see Step 4)
将效率指标格式化为可视化、可分享的报告。
使用方式:
bash
python3 skills/nav-stats/functions/report_formatter.py \
  --baseline 150000 \
  --loaded 12000 \
  --saved 138000 \
  --savings-percent 92 \
  --cache-efficiency 100 \
  --context-usage 35 \
  --efficiency-score 94 \
  --time-saved 42
输出: 格式化的ASCII报告(见步骤4)

Philosophy Integration

理念整合

Context Engineering Principle: Measurement validates optimization
From
.agent/philosophy/PATTERNS.md
:
"Measure to validate. Navigator tracks real metrics, not estimates."
This skill proves:
  • Token savings are real (baseline comparison)
  • Cache efficiency works (OpenTelemetry data)
  • Context usage is healthy (window not overloaded)
  • Time saved is quantifiable (6s per 1k tokens)
上下文工程原则:用数据验证优化效果
来自
.agent/philosophy/PATTERNS.md
"Measure to validate. Navigator tracks real metrics, not estimates."
此Skill可证明:
  • Token节省量真实可信(基于基准对比)
  • 缓存效率切实有效(来自OpenTelemetry数据)
  • 上下文使用率处于健康状态(上下文窗口未过载)
  • 节省时长可量化(每1k Token约节省6秒)

User Experience

用户体验

User says: "Show my stats"
Skill displays:
  1. Visual efficiency report
  2. Clear metrics (tokens, cache, context)
  3. Interpretation ("What this means")
  4. Actionable recommendations
User can:
  • Screenshot and share (#ContextEfficiency)
  • Understand Navigator's impact
  • Optimize workflow based on recommendations
  • Validate context engineering principles
用户说:“Show my stats”
Skill展示:
  1. 可视化效率报告
  2. 清晰的指标数据(Token、缓存、上下文)
  3. 指标解读(“这意味着什么”)
  4. 可执行的优化建议
用户可以:
  • 截图分享(#ContextEfficiency)
  • 了解Navigator的实际作用
  • 根据建议优化工作流程
  • 验证上下文工程原则

Example Output Scenarios

示例输出场景

Scenario 1: Excellent Efficiency (Score 94)

场景1:高效(得分94)

User following lazy-loading pattern, cache working perfectly:
  • 92% token savings ✅
  • 100% cache efficiency ✅
  • 35% context usage ✅
  • Score: 94/100
Recommendation: Keep it up! Share your efficiency.
用户遵循懒加载模式,缓存运行完美:
  • 92% Token节省量 ✅
  • 100%缓存效率 ✅
  • 35%上下文使用率 ✅
  • 得分:94/100
建议:保持当前状态!分享你的效率成果。

Scenario 2: Fair Efficiency (Score 72)

场景2:中等效率(得分72)

User loading too many docs upfront:
  • 65% token savings ⚠️
  • 95% cache efficiency ✅
  • 55% context usage ✅
  • Score: 72/100
Recommendation: Review lazy-loading strategy. Load docs on-demand.
用户预先加载了过多文档:
  • 65% Token节省量 ⚠️
  • 95%缓存效率 ✅
  • 55%上下文使用率 ✅
  • 得分:72/100
建议:回顾懒加载策略,按需加载文档。

Scenario 3: Poor Efficiency (Score 48)

场景3:低效(得分48)

User not using Navigator patterns:
  • 45% token savings ❌
  • 70% cache efficiency ⚠️
  • 85% context usage ❌
  • Score: 48/100
Recommendation: Read philosophy docs. Consider /nav:compact. Review CLAUDE.md.
用户未使用Navigator的最佳实践:
  • 45% Token节省量 ❌
  • 70%缓存效率 ⚠️
  • 85%上下文使用率 ❌
  • 得分:48/100
建议:阅读理念文档,考虑使用/nav:compact命令,检查CLAUDE.md配置。

Success Metrics

成功指标

After using this skill, users should:
  • Understand their efficiency score
  • See quantified token savings
  • Know what to improve (if anything)
  • Feel motivated to share results
Long-term impact:
  • Users screenshot reports and share
  • "Navigator saved me 138k tokens" becomes common
  • Efficiency becomes visible, not abstract
  • Continuous improvement through measurement

This skill makes Navigator's value tangible and shareable.
使用此Skill后,用户应:
  • 了解自己的效率得分
  • 看到量化的Token节省量
  • 知道需要改进的地方(如有)
  • 有动力分享成果
长期影响:
  • 用户截图并分享报告
  • “Navigator为我节省了138k Token”成为常见表述
  • 效率变得可视化,而非抽象概念
  • 通过持续测量实现持续改进

此Skill让Navigator的价值变得切实可感且易于分享。