**Purpose:** Display token usage for current workflow
/plugin marketplace add nguyenthienthanh/ccpm-team-agents/plugin install nguyenthienthanh-aura-frog-aura-frog-2@nguyenthienthanh/ccpm-team-agentsworkflow/Purpose: Display token usage for current workflow
Aliases: tokens, token usage, show tokens
Trigger: User types /workflow:tokens
Show detailed token consumption breakdown for the active workflow.
# Show token usage
workflow:tokens
# Or natural language
"Show token usage"
"How many tokens used?"
"Token consumption?"
const state = loadWorkflowState();
if (!state || !state.workflow_id) {
console.log('β No active workflow');
return;
}
const totalTokens = state.total_tokens_used || 0;
const remaining = state.total_tokens_remaining || 1000000;
const contextLimit = 1000000; // 1M tokens for Claude 3.5 Sonnet
const usagePercent = Math.round((totalTokens / contextLimit) * 100);
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π TOKEN USAGE REPORT
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
**Workflow:** [workflow-name]
**ID:** [workflow-id]
## Overall Usage
ββββββββββββββββββββββββββββββββββββββββ 25%
**Used:** 250,000 tokens (~250K)
**Remaining:** 750,000 tokens (~750K)
**Limit:** 1,000,000 tokens (1M)
## Phase Breakdown
| Phase | Name | Status | Tokens | % |
|-------|------|--------|--------|---|
| 1 | Requirements Analysis | β
| 25,000 | 2.5% |
| 2 | Technical Planning | β
| 45,000 | 4.5% |
| 3 | Design Review | β
| 30,000 | 3.0% |
| 4 | Test Planning | β
| 35,000 | 3.5% |
| 5a | TDD RED | β
| 40,000 | 4.0% |
| 5b | TDD GREEN | β
| 55,000 | 5.5% |
| 5c | TDD REFACTOR | β³ | 20,000 | 2.0% |
| 6 | Code Review | βΈοΈ | - | - |
| 7 | QA Validation | βΈοΈ | - | - |
| 8 | Documentation | βΈοΈ | - | - |
| 9 | Notification | βΈοΈ | - | - |
## Token Efficiency
**Average per phase:** ~35,000 tokens
**Estimated completion:** ~350,000 tokens total
**Efficiency score:** Good β
## Recommendations
β
**Sufficient context remaining** - Continue workflow
β οΈ **Monitor usage** - 25% consumed
π‘ **Optimize prompts** - Keep responses focused
if (usagePercent > 80) {
console.log('\nβ οΈ **WARNING: High token usage!**');
console.log(' - Consider completing workflow soon');
console.log(' - Or start new conversation context');
console.log(' - Save important context before limit');
} else if (usagePercent > 60) {
console.log('\nπ‘ **Notice: Moderate usage**');
console.log(' - More than halfway through context');
console.log(' - Plan to wrap up soon');
}
## Available Actions
- **Continue workflow** - Plenty of context remaining
- **workflow:status** - Check current phase
- **workflow:approve** - Approve current phase
- **help** - Show all commands
function formatTokens(tokens: number): string {
if (tokens >= 1000000) {
return `${(tokens / 1000000).toFixed(1)}M`;
} else if (tokens >= 1000) {
return `${Math.round(tokens / 1000)}K`;
}
return tokens.toString();
}
function createProgressBar(percent: number, length: number = 50): string {
const filled = Math.round((percent / 100) * length);
const bar = 'β'.repeat(filled) + 'β'.repeat(length - filled);
return bar;
}
π Token Usage: 50,000 / 1,000,000 (5%)
ββββββββββββββββββββββββββββββββββββββββ 5%
β
Excellent - Continue workflow
π Token Usage: 500,000 / 1,000,000 (50%)
ββββββββββββββββββββββββββββββββββββββββ 50%
β οΈ Moderate - Monitor remaining phases
π Token Usage: 850,000 / 1,000,000 (85%)
βββββββββββββββββββββββββββββββββββββββββββ 85%
π¨ High usage - Complete workflow soon
# Run token tracking script
bash scripts/workflow/track-tokens.sh show
# Log token usage
bash scripts/workflow/track-tokens.sh log
# Estimate tokens from text
bash scripts/workflow/track-tokens.sh estimate "Your text here"
{
"workflow_id": "add-authentication-20251124-120000",
"total_tokens_used": 250000,
"total_tokens_remaining": 750000,
"phases": {
"1": {
"tokens": {
"start": 10000,
"end": 35000,
"phase_tokens": 25000,
"cumulative_tokens": 25000
}
}
}
}
β
Token report displayed clearly
β
Phase breakdown shown
β
Warnings shown if high usage
β
Recommendations provided
β
User can make informed decisions
Command: workflow:tokens
Version: 1.0.0
Script: scripts/workflow/track-tokens.sh