agentsclimarketplace

Hex cost tuning

Skill jeremylongshore/claude-code-plugins-plus-skills/plugins/saas-packs/hex-pack/skills/hex-cost-tuning

'Optimize Hex costs through tier selection, sampling, and usage monitoring.From its SKILL.md

Install
npx -y skills add jeremylongshore/claude-code-plugins-plus-skills --skill hex-cost-tuning

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

4.6 KB, 911 tokens by cl100k_base, as published. Nobody here has run it

Hex Cost Tuning

Overview

Hex pricing combines per-seat licensing with compute-based charges for notebook runs and data connections. Each scheduled or ad-hoc notebook execution consumes compute credits proportional to query complexity and data volume processed. Organizations running dozens of notebooks on hourly schedules — many producing identical results from unchanged data — accumulate unnecessary compute costs. Caching run results, optimizing schedules, and consolidating redundant notebooks are the highest-leverage cost reduction strategies.

Cost Breakdown

ComponentCost DriverOptimization
Seat licensesPer-user/month (Team: $28/user)Audit active editors quarterly; move viewers to free tier
Notebook runsCompute per scheduled or manual executionCache results for unchanged data; extend run intervals
Data connectionsActive warehouse/database connectionsConsolidate overlapping connections; remove unused ones
Scheduled runsCron-triggered executions across all projectsAudit schedules — reduce frequency for stable data
API callsAdmin and Run API requestsBatch API operations; use cached results endpoint

API Call Reduction

class HexRunOptimizer {
  private resultCache = new Map<string, { data: any; timestamp: number }>();
  private dataHashes = new Map<string, string>();

  async runIfChanged(projectId: string, runFn: () => Promise<any>): Promise<any> {
    const currentHash = await this.getSourceDataHash(projectId);
    if (this.dataHashes.get(projectId) === currentHash) {
      const cached = this.resultCache.get(projectId);
      if (cached) return cached.data; // Source unchanged — serve cached result
    }
    const result = await runFn();
    this.resultCache.set(projectId, { data: result, timestamp: Date.now() });
    this.dataHashes.set(projectId, currentHash);
    return result;
  }

  private async getSourceDataHash(projectId: string): Promise<string> {
    const res = await fetch(`/api/v1/project/${projectId}/status`);
    return (await res.json()).sourceDataHash;
  }
}

Usage Monitoring

class HexCostMonitor {
  private runs = new Map<string, number[]>();
  private weeklyBudget = 500; // max runs per week

  recordRun(projectId: string): void {
    const timestamps = this.runs.get(projectId) || [];
    timestamps.push(Date.now());
    this.runs.set(projectId, timestamps);
  }

  getWeeklyReport(): { totalRuns: number; byProject: Record<string, number> } {
    const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
    const byProject: Record<string, number> = {};
    let total = 0;
    for (const [id, stamps] of this.runs) {
      const count = stamps.filter(t => t > weekAgo).length;
      byProject[id] = count;
      total += count;
    }
    return { totalRuns: total, byProject };
  }
}

Cost Optimization Checklist

  • Cache notebook results with updateCacheResult: true
  • Skip re-runs when source data is unchanged
  • Audit scheduled run frequencies — extend intervals for stable data
  • Move read-only users from Team to free viewer tier
  • Consolidate duplicate notebooks querying the same data
  • Remove unused data connections
  • Set weekly run budget alerts at 80% threshold
  • Identify overrun projects (>20 runs/week) for schedule review

Error Handling

IssueCauseFix
Compute costs spikingHourly schedules on notebooks with daily-changing dataExtend schedule to match data refresh cadence
Stale cached resultsSource data changed but cache not invalidatedUse source data hash comparison before serving cache
API rate limit (429)Too many concurrent run triggersQueue runs with concurrency limit of 3
Unused notebooks accruing runsAbandoned projects still on scheduleAudit and disable schedules for inactive projects
Connection pool exhaustedToo many simultaneous data source queriesConsolidate connections; stagger scheduled run times

Resources

Next Steps

See hex-performance-tuning.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,144. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.