Optimize workflow prompts: reduce token usage by 70% in shared files #7081
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Token usage spiked 4x to 1.71M across 10 workflow runs. Root cause: verbose prompts with redundant examples, lengthy bash scripts, and repetitive instructions.
Changes
Shared files (high-impact, imported by 30-45 workflows each):
trending-charts-simple.md: 313 → 78 lines (75% ↓)reporting.md: 80 → 14 lines (82% ↓)High-volume workflows (daily/per-event):
audit-workflows.md: 374 → 163 lines (56% ↓)daily-code-metrics.md: 563 → 93 lines (83% ↓)dev-hawk.md: 143 → 98 lines (31% ↓)All 121 workflow lock files recompiled: -5,316 lines net across affected sections.
Token impact
Shared file multiplier effect:
trending-charts-simple.md: 235 lines × 32 imports = 7,520 lines eliminatedreporting.md: 66 lines × 45 imports = 2,970 lines eliminatedEstimated savings: ~42K tokens/run from shared files alone, ~450K tokens across 10 runs.
Before/After example (
trending-charts-simple.md):Projected results
From 1.71M baseline → ~1.26M tokens (26% reduction). Target: <850K (50%). Additional optimizations available if monitoring shows gap remains: output summarization, MCP server instruction files (slack.md: 219 lines, drain3.md: 196 lines), remaining high-line-count workflows.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.