---
name: anima-cost-tuning
description: 'Optimize Anima API costs through caching, incremental generation, and tier selection.

  Use when managing Anima API usage, reducing unnecessary code generations,

  or right-sizing your Anima plan for team size.

  Trigger with: "anima cost", "anima pricing", "anima budget", "anima API usage".'
allowed-tools: Read, Write, Edit, Bash(npm:*)
version: 2.0.0
argument-hint: "[usage-report-or-policy]"
model: inherit
effort: high
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - design
  - figma
  - anima
  - cost-optimization
compatibility: Requires Node.js 20+, approved Anima API access, current Anima SDK documentation, and authorized Figma or website source access
title: anima-cost-tuning
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/anima-cost-tuning
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/official-docs.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/anima-cost-tuning/references/official-docs.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/anima-cost-tuning`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/anima-cost-tuning`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/anima-cost-tuning) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/anima-cost-tuning`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/anima-cost-tuning --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/anima-cost-tuning --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Anima Cost Tuning

## Overview

Optimize design-to-code generation by measuring approved usage, avoiding
duplicate work, and retaining only reusable outputs. Treat cost projections as
planning inputs until the account owner confirms current contractual terms.

## Pricing Context

Do not infer price units from the SDK or marketing site. Obtain the current account
agreement or usage report from the authorized owner and label every projection with
its source date, currency, unit, and included allowance.

## Prerequisites

- A current agreement or account report from the authorized Anima owner; do not
  infer consumption limits from the illustrative optimization table.
- Aggregate generation telemetry that records file/node identifiers, generation
  version, cache state, and duration without exposing design tokens or content.
- An explicit cache freshness and invalidation policy agreed by design and code
  owners so cached output cannot silently lag an approved design change.

## Cost Optimization Strategies

| Strategy | Measure | Guardrail |
|----------|---------|-----------|
| Content-addressed reuse | Avoided duplicate generations | Bind source revision, node, SDK version, and settings |
| Incremental generation | Changed versus unchanged nodes | Regenerate when change state is unknown |
| Asset policy | Hosted versus external transfer | Follow security, retention, and licensing policy |
| Output reuse | Accepted reusable components | Revalidate after source or dependency changes |

## Authentication

Read usage only through the account owner's authorized report or integration.
Keep Anima and Figma credentials in the backend secret manager and aggregate
telemetry before analysis so this workflow never receives token or design data.

## Instructions

### Step 1: Usage Tracker

```typescript
// src/cost/usage-tracker.ts
interface GenerationRecord {
  timestamp: string;
  fileKey: string;
  nodeId: string;
  cached: boolean;
  durationMs: number;
}

class AnimaUsageTracker {
  private records: GenerationRecord[] = [];

  record(entry: GenerationRecord): void { this.records.push(entry); }

  getReport(): { total: number; cached: number; cacheHitRate: number | null } {
    const total = this.records.length;
    const cached = this.records.filter(r => r.cached).length;
    return {
      total,
      cached,
      cacheHitRate: total > 0 ? cached / total : null,
    };
  }
}
```

### Step 2: Smart Generation Policy

```typescript
// Only generate when:
// 1. Figma file version changed (check via Figma API)
// 2. The repository's reviewed cache-retention policy requires refresh
// 3. Settings changed (new framework/styling)
// 4. Force flag passed (manual override)

async function shouldGenerate(
  fileKey: string,
  nodeId: string,
  cache: any,
): Promise<boolean> {
  // Check cache first
  const cached = cache.get(fileKey, nodeId);
  if (cached && cached.sourceRevision === cache.currentSourceRevision(fileKey)) {
    console.log('Using source- and settings-bound cached generation');
    return false;
  }
  return true;
}
```

## Tool Discipline

Use Read and Grep to inspect the existing integration and generated diff before changing anything. Use Write or Edit only inside the approved generated-code, test, or configuration paths. Use the declared Bash commands only for the explicit install, validation, or diagnostic steps in this workflow; never print tokens, source designs, generated source, or private website captures.

## Output

- Usage tracking with cache hit rate reporting
- Smart generation policy reducing unnecessary API calls
- A measured avoided-work report; monetary impact remains unclaimed without account data

## Examples

For a weekly design-system sync, record aggregate generation counts for the
approved component registry, then compare an uncached baseline with the smart
generation policy. Regenerate only components whose Figma version or generation
settings changed, and attach the source-version and cache decision to the PR.
If the current usage report is incomplete, a cache cannot identify its source
version, or a design owner requests an immediate change, bypass the cache only
with an explicit force record and regenerate the affected component—not the
entire design file by default.

## Error Handling

| Failure | Response |
|---------|----------|
| Account limits or pricing data are unavailable | Mark projections as incomplete and obtain current data from the account owner. |
| Cache source version is unknown | Refuse reuse and regenerate the approved affected component. |
| Generation rate spikes unexpectedly | Pause noncritical jobs, inspect aggregate telemetry, and enforce the scheduling policy. |
| Output is stale after an approved design change | Invalidate the affected cache key and record the corrected generation receipt. |

## Resources

- [Anima Pricing](https://www.animaapp.com)
- [Anima API](https://docs.animaapp.com/docs/anima-api)
