feat: AI spend solution with custom metrics, scorecard, and team plugin - #231
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add YAML frontmatter, diagram code block, and After Installing section so solutions install Data Model and Next steps menu options work correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add ai-spend-scorecard with bronze/silver/gold budget compliance tiers (bronze = tracking, silver = within 125% of budget, gold = under budget) - Add ai-budget-weekly and ai-spend-weekly custom data to team catalog entities (platform=$480, frontend=$360, data=$280, engineering=$1100 budgets) - Add team rollup entries (8 weeks) to ai-spend.json sample data - Update sync script to walk team-member hierarchy (DFS) and write both ai-spend custom metric and ai-spend-weekly custom data on team entities - Update README with scorecard docs, budget CLI command, and updated diagram Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace custom("ai-spend-weekly") metadata approach with:
customMetrics(key="ai-spend", lookback=duration("P8D")).map((m) => m.value).average()
The time-series custom metric is the source of truth for both trending
and budget compliance — no separate custom data key needed for spend.
Also removes push_custom_data from sync script and ai-spend-weekly from
team YAML catalog files.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace direct employee filter with DFS adjacency-map walk so the plugin correctly resolves sub-teams (e.g. team-engineering → team-platform → employee-alice-chen) instead of only showing direct employee members. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Cortex relationships API returns a non-standard type value for custom entity types so checking dst.type === 'employee' is unreliable. Instead, nodes with outgoing team-member relationships are sub-teams; nodes without are leaf employees. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ctx.tag is the plugin's own tag; ctx.entity.tag is the entity being viewed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The custom metrics GET endpoint returns { data: [...] }, not { values: [...] }.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Total card: green when under budget, red when over, purple when no budget set - Bar chart: stacked green/red split at budget threshold per member - Dashed vertical budget line with label drawn via custom Chart.js plugin - Falls back to original purple chart when no ai-budget-weekly is set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Switch afterDraw to afterDatasetsDraw so line renders on top of bars - Set suggestedMax to max(budget, maxSpend)*1.1 so budget line is always within the visible x-axis range (was off-screen when all spend < budget) - Remove bounds guard that was hiding the line - Green bars match total card color (#16a34a); red bars match (#dc2626) - Tooltip: hover green shows "Budget: $X/wk", hover red shows "Over by: +$X" - interaction mode: nearest+intersect so each segment tooltips independently - filter: raw > 0 hides phantom tooltip on zero-value overflow segments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…handles budget status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ai-spendsolution: track per-employee Claude AI spend in Cortex using custom metrics with full team hierarchy rollup visibilityemployeeentity type andteam-memberrelationship type with sample org of 5 employees across 4 teamssync-claude-spend.pyscript + GitHub Actions workflow to pull weekly spend from the Anthropic Analytics API and push to Cortex custom metrics with team rollups via DFS hierarchy walkai-spend-scorecard— bronze/silver/gold budget compliance scorecard using CQL against theai-spendcustom metricteam-ai-spendplugin — per-team spend visualization with budget-aware header card (green/red) and per-member bar chartbackup importto supportcustom-metrics/directoriesVersion
1.29.0 (minor bump —
feat:commits)Test plan
cortex solutions install -s ai-spendinstalls all resources cleanlycortex solutions info -s ai-spendshows ASCII flow diagramsync-claude-spend.pymaps emails to entity tags and pushes team rollups🤖 Generated with Claude Code