---
name: anima-rate-limits
description: 'Implement rate limiting for Anima API code generation requests.

  Use when batching component generation, handling rate limit errors,

  or optimizing API throughput for large design systems.

  Trigger with: "anima rate limit", "anima throttling", "anima batch generation".'
allowed-tools: Read, Write, Edit, Bash(npm:*)
version: 2.0.0
argument-hint: "[figma-workload]"
model: inherit
effort: high
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - design
  - figma
  - anima
  - rate-limiting
compatibility: Requires Node.js 20+, approved Anima API access, current Anima SDK documentation, and authorized Figma or website source access
title: anima-rate-limits
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/anima-rate-limits
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-rate-limits/references/official-docs.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/anima-rate-limits`. 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-rate-limits`, 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-rate-limits) 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-rate-limits`. 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-rate-limits --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/anima-rate-limits --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 Rate Limits

## Overview

Handle Figma rate limits from the current SDK's structured callback and treat any
Anima generation quota as account-specific until the provider or agreement says
otherwise. Never encode an invented requests-per-minute or concurrency allowance.

## Documented Signals

| Surface | Signal | Required action |
|---------|--------|-----------------|
| `FigmaRestApi.onRateLimited` | `retryAfter`, `figmaPlanTier`, `figmaRateLimitType` | Retry only inside a bounded elapsed-time budget |
| `figmaRateLimitMaxWait` | 1–180 seconds; default 60 | Set explicitly for the request's latency budget |
| Anima generation | Returned error/progress state and account contract | Stop or queue; do not infer a numeric quota |

## Prerequisites

- Confirm the account's current generation and concurrency contract before choosing worker concurrency; absence of a published number means fail closed, not guess.
- Store `ANIMA_TOKEN`, `FIGMA_TOKEN`, and `FIGMA_FILE_KEY` in the runtime secret manager or injected environment, and verify that the token has only the scopes required for the selected file. Never put tokens in source, fixtures, logs, generated receipts, or retry payloads.
- Define an explicit allowlist of Figma files and node IDs, a bounded batch size, a maximum retry budget, and an approved output directory. Use synthetic or sandbox designs for load tests and confirm that generated output contains no customer data before persisting it.
- Install the pinned SDK and decide whether a generation is safe to repeat. Persist a redacted request fingerprint and resume only failed node IDs.

## Instructions

### Step 1: Configure Structured Figma Rate Handling

```typescript
// src/anima/client.ts
import { Anima, FigmaRestApi } from '@animaapp/anima-sdk';

const figmaRestApi = new FigmaRestApi({
  defaultOptions: {
    token: process.env.FIGMA_TOKEN!,
    onRateLimited: async ({ retryAfter, figmaPlanTier, figmaRateLimitType }) => {
      console.warn({ retryAfter, figmaPlanTier, figmaRateLimitType });
      return retryAfter > 0 && retryAfter <= 5; // Repository latency budget.
    },
  },
});

export const anima = new Anima({
  auth: { token: process.env.ANIMA_TOKEN! },
  figmaRestApi,
});
```

### Step 2: Bind Each Generation to a Maximum Wait

```typescript
const result = await anima.generateCode({
  fileKey: process.env.FIGMA_FILE_KEY!,
  nodesId: ['1:2'],
  figmaRateLimitMaxWait: 5,
  settings: { framework: 'react', language: 'typescript', styling: 'tailwind' },
});
console.log({ fileCount: Object.keys(result.files).length, sessionId: result.sessionId });
```

## Error Handling

- Let `FigmaRestApi` own Figma retry decisions. Do not add a second uncoordinated retry loop around the same request.
- Do not retry 401/403 authentication or permission failures, invalid node/file parameters, or policy rejections. Stop the batch, report the node ID and redacted status, and repair credentials or scope before resuming.
- Retry only bounded transient 5xx and network failures. Cap attempts and total elapsed time, cancel queued work after the budget is exhausted, and preserve the successful results separately from failed node IDs so a resume cannot regenerate the whole batch accidentally.
- Treat timeout, process restart, and partial writes as ambiguous outcomes: check the request fingerprint or cache before resubmitting, write output atomically, and quarantine incomplete files. Logs and receipts may contain counts, status classes, and hashes, but not tokens, design contents, user identifiers, or generated source.
- Alert when the observed rate, queue depth, quota remaining, or failure ratio crosses the configured threshold. A human must approve any change to concurrency or quota settings; rollback means restoring the last known-good limiter configuration and draining queued work.

## Examples

For a sandbox batch, keep the work bounded and make the outcome auditable without exposing design data:

```typescript
const nodeIds = ['synthetic-card', 'synthetic-button'];
const receipt = {
  batchId: 'sandbox-2026-01-15-a',
  requested: nodeIds.length,
  succeeded: 0,
  failed: 0,
  contactsExported: 0,
};

for (const nodeId of nodeIds) {
  try {
    await anima.generateCode({ fileKey: process.env.FIGMA_FILE_KEY!, nodesId: [nodeId], figmaRateLimitMaxWait: 5, settings });
    receipt.succeeded++;
  } catch (error) {
    receipt.failed++;
    // Store only a redacted status and node fingerprint; never serialize `error` or source.
  }
}
console.log(JSON.stringify({ ...receipt, tokenPresent: Boolean(process.env.ANIMA_TOKEN) }));
```

An acceptable completion receipt is `requested=2; succeeded=2; failed=0; contacts_exported=0` with the sandbox ID and limiter settings recorded separately. A production batch should use the same controls, a reviewed allowlist, and an owner-approved change record before increasing concurrency.

## 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

- Bottleneck-throttled code generation matching API limits
- Batch generator for design system-scale operations
- 429 retry handler with progressive backoff

## Resources

- [Anima API Docs](https://docs.animaapp.com/docs/anima-api)
- [Bottleneck npm](https://www.npmjs.com/package/bottleneck)
