codeburn
codeburn copied to clipboard
Add MCP and skill ROI optimize insights
Summary
- Adds two new
optimizefindings for capability-level MCP/skill analysis:- low edit ROI for invoked MCP servers and skills in implementation-like turns
- retry impact for capabilities whose edit turns retry materially more than same-category baseline turns
- Keeps the findings diagnostic: CodeBurn asks users to inspect sessions and narrow/remove capabilities only after confirming the sessions justify it.
- Caps shared-turn token/cost/retry impact once when multiple candidate capabilities appear in the same turn, so co-occurring MCP + skill usage cannot inflate ranking.
Why
optimize already reports unused MCP inventory and ghost skills, but it could not answer two higher-level questions:
- "This MCP server/skill is being used, but is it helping implementation work?"
- "When this capability is involved, does the agent need more retry loops than comparable work?"
Those are different from ghost/unused checks: a capability can be invoked frequently and still be low-signal for edit-producing work, or correlate with repeated fix/test loops. The new findings surface that as a review signal without pretending correlation is causation.
What changed
- Adds turn-keyed capability aggregation over parsed session summaries:
- MCP capabilities are grouped by server from canonical
mcp__<server>__<tool>names. - Skill capabilities come from parsed
call.skillsonly; generic turn labels such assubCategoryare not treated as skills. - Capabilities are counted once per turn even if the same MCP server/tool appears multiple times.
- MCP capabilities are grouped by server from canonical
- Adds a low-edit-ROI detector for implementation-like categories (
coding,debugging,feature,refactoring,testing).- Example output shape:
MCP docs: 1/4 implementation turns produced edits (25% edit rate), $2.00 touchedskill api-review: 0/3 implementation turns produced edits (0% edit rate), $1.50 touched
- Example output shape:
- Adds a retry-impact detector using same-category edit baselines.
- Example output shape:
skill planner: 2.0 retries/edit turn vs 0.0 baseline in the same task categories (3 edit turns, baseline 3)
- Example output shape:
- Reuses a single capability aggregation pass inside
scanAndDetect, alongside existing MCP coverage aggregation. - Adds regression tests for:
- ROI sample thresholds
- MCP/skill findings together
- per-turn MCP deduplication
- shared-turn savings caps for co-occurring MCP + skill candidates
- no
subCategoryfalse skill labels - same-category retry baselines
- retry sample thresholds
Validation
I validated the behavior by running the real src/optimize.ts detector exports against controlled ProjectSummary fixtures via npx tsx --eval. This is not just green tests: the harness constructs the exact edge cases this PR is meant to handle and prints the detector output.
{
"roi_shared_turn_cap": {
"title": "2 MCP/skill capabilities with low edit ROI",
"tokensSaved": 1650,
"expectedTokensSaved": 1650,
"containsMcpCombo": true,
"containsSkillCombo": true,
"proof": "3 shared non-edit turns * 2,200 effective tokens * 25%; not doubled to 3,300 when MCP and skill co-occur"
},
"retry_same_category_baseline_and_shared_turn_cap": {
"title": "2 MCP/skill capabilities correlated with high retries",
"tokensSaved": 3300,
"expectedTokensSaved": 3300,
"containsSameCategoryBaseline": true,
"ignoresHighRetryDebuggingBaseline": true,
"proof": "3 shared coding edit turns * 2,200 effective tokens * 50%; debugging retry turns do not contaminate coding baseline"
},
"subCategory_false_skill_guard": {
"finding": null,
"proof": "turn.subCategory=frontend with no call.skills and no MCP tools emits no capability finding"
}
}
What this proves:
- ROI emits both the MCP and skill candidates, but shared non-edit turns are capped once:
1,650tokens instead of the buggy3,300double count. - Retry impact emits both the MCP and skill candidates, but shared edit turns are capped once:
3,300tokens instead of the buggy6,600double count. - Retry baseline is same-category: high-retry
debuggingedit turns are present in the fixture, but they do not contaminate thecodingbaseline. subCategoryalone does not create a fakeskill frontendfinding.
Supporting checks:
./node_modules/.bin/tsc --noEmit --pretty falsenpx vitest run tests/optimize.test.ts— 87 tests passednpm run buildnpm test -- --run— 62 files / 882 tests passedgit diff --check origin/main...HEAD- GitHub checks on this PR:
assess,check,semgrepall passed - Claude Opus 4.7, effort max review:
- first pass found shared-turn double-counting and
subCategoryskill-label risks - after fixing both, final review returned
PASS
- first pass found shared-turn double-counting and
- Gemini 3.1 Pro Preview review returned
PASSon the amended diff
Notes
- This intentionally does not auto-edit MCP or skill config. The findings are audit prompts because high retries or low edit rate can also reflect hard tasks, read-only investigation, or intentionally exploratory work.
- Low MCP tool coverage still owns the "large server inventory is mostly unused" case; the ROI detector suppresses MCP servers already flagged there to avoid duplicate findings.