Testdriver:Cache logo

Testdriver:Cache

Organization
testdriverai
testdriver:cache

Speed up tests with screenshot-based caching

Overview

Publishertestdriverai
Repositorytestdriverai
Skill nametestdriver:cache
Stars
465
Forks
39
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by testdriverai on GitHub. Read the source before you install it.

Installation

Install the Testdriver:Cache AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/testdriverai/testdriverai/tree/main/ai/skills/testdriver-cache
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/testdriverai/testdriverai.git /tmp/testdriverai
mkdir -p .claude/skills
cp -r /tmp/testdriverai/ai/skills/testdriver-cache .claude/skills/testdriverai-testdriver-cache
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Testdriver:Cache in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Testdriver:Cache on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Testdriver:Cache is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Overview

The cache system makes repeated test runs faster. It compares screenshots to cached results. When the screen did not change much, TestDriver uses the cached element positions again. It does not make an AI call.

The cache works at two levels:

  • Screen cache: a pixel diff comparison between the present screenshot and the cached screenshot
  • Element cache: OpenCV template matching to make sure that the cached element position is still correct

How It Works

  1. On find(), the SDK sends the present screenshot and the cache metadata to the API.
  2. The API compares the screenshot against the cached results for the same cacheKey.
  3. If the screen pixel diff is in the screen threshold AND the element template match is more than the element threshold, TestDriver returns the cached position.
  4. If not, TestDriver makes a new AI call and caches the result.

Configuration

Constructor Options

javascript
const testdriver = new TestDriver({
  cache: {
    enabled: true,
    thresholds: {
      find: {
        screen: 0.05,     // 5% pixel diff allowed (default)
        element: 0.8,     // 80% OpenCV correlation required (default)
      },
      assert: 0.05,       // 5% pixel diff for assertions (default)
    },
  },
  cacheKey: 'my-custom-key',   // overrides auto-generated key
});
<ParamField path="thresholds" type="CacheThresholds">
  Threshold configuration for different command types.

  <Expandable title="properties">
    <ParamField path="find" type="FindCacheThresholds">
      Thresholds for `find()` and `findAll()`.

      <Expandable title="properties">
        <ParamField path="screen" type="number" default={0.05}>
          Maximum pixel diff percentage allowed between the current screenshot and the cached screenshot. Lower values require a closer match. Range: `0` to `1`.
        </ParamField>
        
        <ParamField path="element" type="number" default={0.8}>
          Minimum OpenCV template matching correlation required for the cached element crop. Higher values require a closer match. Range: `0` to `1`. Only used for `find()`, not `findAll()`.
        </ParamField>
      </Expandable>
    </ParamField>
    
    <ParamField path="assert" type="number" default={0.05}>
      Maximum pixel diff allowed for assertion cache hits.
    </ParamField>
  </Expandable>
</ParamField>

Disabling Cache

javascript
// Via constructor
const testdriver = new TestDriver({ cache: false });

// Via environment variable
// TD_NO_CACHE=true npx vitest run

When cache is disabled, all thresholds are set to -1 internally, causing the API to skip cache lookups.

Per-Command Overrides

Override cache thresholds for individual commands:

javascript
// Stricter screen matching for this specific find
const el = await testdriver.find('submit button', {
  cache: {
    thresholds: { screen: 0.01, element: 0.95 },
  },
});

// Custom cache key for a specific assertion
await testdriver.assert('dashboard loaded', {
  cache: { threshold: 0.01 },
  cacheKey: 'dashboard-check',
});

Threshold Priority

Thresholds are resolved in priority order (highest wins):

PrioritySourceExample
1 (highest)Per-command optionfind(desc, { cache: { thresholds: { screen: 0.1 } } })
2Legacy number argumentfind(desc, 0.1)
3Global constructor confignew TestDriver({ cache: { thresholds: { find: { screen: 0.1 } } } })
4 (lowest)Hard-coded defaultsscreen: 0.05, element: 0.8, assert: 0.05

Auto-Generated Cache Key

When you don't specify a cacheKey, the SDK automatically generates one:

  1. Walks the call stack to find your test file
  2. Reads the file content
  3. Computes a SHA-256 hash of the content
  4. Uses the first 16 hex characters as the cache key

This means:

  • Same test file → same cache key → cache hits
  • Modified test file → different hash → automatic cache invalidation
  • Different test files → different keys → isolated caches
javascript
// Auto-generated cache key from test file hash
const testdriver = new TestDriver();
// cacheKey = "a3f2b1c4d5e6f7a8" (auto)

// Manual override
const testdriver = new TestDriver({ cacheKey: 'login-test-v2' });

Template Matching (OpenCV)

Element cache validation uses OpenCV's normalized cross-correlation coefficient (TM_CCOEFF_NORMED) to verify that the cached element is still visible at the expected position.

Algorithm:

  1. Load the cached element crop (needle) and current screenshot (haystack)
  2. Run cv.matchTemplate() with TM_CCOEFF_NORMED
  3. Binary threshold at the configured element threshold
  4. Find contours to extract match positions
  5. Return matches with { x, y, width, height, centerX, centerY }

Scale factors tried: [1, 0.5, 2, 0.75, 1.25, 1.5] Thresholds tried: [0.9, 0.8, 0.7] (picks highest matching threshold)

This accounts for minor scaling differences between screenshots taken at different times or resolutions.

Cache Partitioning

Cache entries are partitioned by:

  • cacheKey — identifies the test file
  • os — operating system (linux, windows, darwin)
  • resolution — screen resolution

This means cache from a Linux run won't be used for a Windows run, even with the same cache key.

Debugging Cache

API responses include cache metadata:

FieldDescription
cacheHittrue if cache was used
similarityPixel diff percentage between screenshots
cacheSimilarityOpenCV template match score

Use getDebugInfo() on an element to inspect cache results:

javascript
const el = await testdriver.find('submit button');
const debug = el.getDebugInfo();
console.log(debug);
// { cacheHit: true, similarity: 0.02, cacheSimilarity: 0.92, ... }

Types

typescript
interface CacheConfig {
  enabled?: boolean;            // Default: true
  thresholds?: CacheThresholds;
}

interface CacheThresholds {
  find?: FindCacheThresholds;
  assert?: number;              // Default: 0.05
}

interface FindCacheThresholds {
  screen?: number;              // Default: 0.05
  element?: number;             // Default: 0.8
}

interface CacheDebugInfo {
  cacheHit: boolean;
  similarity: number;
  cacheSimilarity: number;
}

Frequently asked questions

What does the Testdriver:Cache AI skill do?

Speed up tests with screenshot-based caching

Why use Testdriver:Cache on TypingMind?

Because you install it once and use it with any model. Testdriver:Cache is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Testdriver:Cache in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/testdriverai/testdriverai/tree/main/ai/skills/testdriver-cache. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Testdriver:Cache?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Testdriver:Cache?

As many as you like. As long as a model supports skills, you can use Testdriver:Cache with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Testdriver:Cache AI skill free?

It is published on GitHub by testdriverai. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇