Official agent skill

Adaptive Spin Wait

by microsoft in microsoft/garnet

Selects Garnet spin-wait policies based on the slow-path cost.

OfficialMITAuto-check passedDatabases

Install Adaptive Spin Wait

skills CLI
$ npx skills add microsoft/garnet --skill adaptive-spin-wait -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/garnet adaptive-spin-wait --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/garnet.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/adaptive-spin-wait .claude/skills/adaptive-spin-wait && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
adaptive-spin-wait
GitHub stars
12k
Token cost
~1k tokens
SKILL.md length
442 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Selects Garnet spin-wait policies based on the slow-path cost.

  • Works in 7 steps: Use ConfiguredSpinWait.CpuLocal() or… → Document why the selected policy matches… → Keep every aggressive phase bounded… → …
  • Changing spin loops
  • SKILL.md covers Choose the Policy, Requirements, Exponential Backoff and Validation
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Adaptive Spin Wait is an agent skill from microsoft/garnet, published by the product's own GitHub organization. Selects Garnet spin-wait policies based on the slow-path cost. Use when adding or changing spin loops, busy waits, retry polling, SpinWait, Thread.SpinWait, fixed spin counts, or spin-to-block/backoff transitions.

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases. The repository describes itself as: Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, key migration… The licence is MIT.

When your agent uses it

  • Changing spin loops
  • Thread.SpinWait
  • Fixed spin counts
  • Spin-to-block/backoff transitions

Example prompts

  • “Use the adaptive-spin-wait skill to select Garnet spin-wait policies based on the slow-path cost”
  • “/adaptive-spin-wait”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Use ConfiguredSpinWait.CpuLocal() or ConfiguredSpinWait.BoundedProgressive(...) for these
  2. Document why the selected policy matches the slow path.
  3. Keep every aggressive phase bounded unless indefinite progressive yielding is the intended slow path.
  4. Check completion and cancellation at the required cadence.
  5. Await a ValueTask directly when the slow path can complete synchronously. Do not call
  6. Account for condition cost. A collection scan can dominate the wait instruction itself.
  7. Measure before replacing a bounded progressive wait with the CPU-local policy; entering an

What it can do on your machine

Read from SKILL.md and the folder at commit 77d6770. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Adaptive Spin Wait loads about 1k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 442 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~58
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/garnet at commit 77d6770, republished under its MIT licence (© microsoft). 442 words, ~1,009 tokens.

Download SKILL.mdSave it as .claude/skills/adaptive-spin-wait/SKILL.md (or your agent's skills folder).
name
adaptive-spin-wait
description
Selects Garnet spin-wait policies based on the slow-path cost. Use when adding or changing spin loops, busy waits, retry polling, SpinWait, Thread.SpinWait, fixed spin counts, or spin-to-block/backoff transitions.

Adaptive Spin Waits

Use this skill whenever code aggressively spins while waiting for another thread or asynchronous operation to make progress.

Choose the Policy

There is no universal spin policy. Choose based on the expected hold time, condition cost, and the cost of entering the slow path. Use ConfiguredSpinWait so that choice is explicit at the call site instead of encoding policy in a raw loop.

CPU-Local Spin

Use NextSpinWillYield when the slow path is cheap and should begin as soon as CPU-local spinning would yield:

csharp
var spinner = ConfiguredSpinWait.CpuLocal();
while (true)
{
    if (ConditionSatisfied())
        return;

    if (!spinner.TryWait())
        break;
}

WaitSlowPath();

This policy performs only CPU-local spins. It does not use SpinWait's allocation-free Thread.Yield, Sleep(0), or Sleep(1) progression.

Bounded Progressive Wait

Use a measured fixed number of SpinOnce calls when the slow path is comparatively expensive, such as allocating an asynchronous timer or arming and blocking on a waiter:

csharp
var spinner = ConfiguredSpinWait.BoundedProgressive(
    maxIterations,
    sleep1Threshold: -1);
while (true)
{
    if (ConditionSatisfied())
        return;

    if (!spinner.TryWait())
        break;
}

WaitSlowPath();

SpinOnce starts with CPU-local spinning and then progressively uses scheduler yielding. Passing sleep1Threshold: -1 permits Thread.Yield and Sleep(0) but prevents Sleep(1). Use the default overload when occasional millisecond sleeps are acceptable.

Pure Busy Spin

Use bounded Thread.SpinWait only for calibrated ultra-short waits where scheduler yielding would be more expensive:

csharp
for (var i = 0; i < maxIterations && !ConditionSatisfied(); i++)
    Thread.SpinWait(pauseIterations);
Time-Budgeted Spin

Retain a duration-based loop when the configured or public behavior is explicitly expressed as time. Do not replace a time budget with an iteration count or NextSpinWillYield.

Show full SKILL.md (230 more words)Show less

Requirements

  1. Use ConfiguredSpinWait.CpuLocal() or ConfiguredSpinWait.BoundedProgressive(...) for these policies; do not reproduce their mechanics inline.
  2. Document why the selected policy matches the slow path.
  3. Keep every aggressive phase bounded unless indefinite progressive yielding is the intended slow path.
  4. Check completion and cancellation at the required cadence.
  5. Await a ValueTask directly when the slow path can complete synchronously. Do not call AsTask() unless an API specifically requires Task.
  6. Account for condition cost. A collection scan can dominate the wait instruction itself.
  7. Measure before replacing a bounded progressive wait with the CPU-local policy; entering an asynchronous slow path earlier can increase both latency and allocations.

Exponential Backoff

Exponential backoff is an asynchronous slow path, not a spin policy. Task.Delay can allocate when the operation suspends. A bounded progressive wait can avoid that cost for short transitions, while the capped backoff still prevents long-held operations from burning a core. Cap and jitter the delay, honor cancellation, and measure polling CPU, allocations, and release-to-observation latency.

Validation

Exercise at least:

  • Immediate completion.
  • Completion during the CPU-local spin.
  • Entry into and completion from the slow path.
  • Cancellation or timeout, when supported.
  • Multiple concurrent waiters.

For performance-sensitive changes, compare CPU, allocations, slow-path entry count, wait latency percentiles, and predicate invocation count across short and long hold times. Treat calibrated fixed counts as application-specific values and preserve the benchmark evidence supporting them.

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/adaptive-spin-wait of microsoft/garnet.

Open the folder on GitHubat commit 77d6770

Compare with similar skills

Adaptive Spin Wait next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Adaptive Spin Wait compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Adaptive Spin Wait this skillmicrosoft/garnet12k—~1kAutomated safety check: PassMIT
Keeper Stress AnalysisClickHouse/ClickHouse50k—~4.7kAutomated safety check: PassApache-2.0
Perf ComparisonClickHouse/ClickHouse50k—~3.9kAutomated safety check: NotesApache-2.0
Patch Release CheckClickHouse/ClickHouse50k—~4kAutomated safety check: NotesApache-2.0
Evolving The Data ModelTriliumNext/Trilium38k—~2.1kAutomated safety check: PassAGPL-3.0
Hybrid Cloud Outboxesgetsentry/sentry46k—~4.8kAutomated safety check: PassCustom licence

Similar skills

  • Keeper Stress Analysis

    ClickHouse/ClickHouse

    Analyze ClickHouse Keeper stress-test results from play.clickhouse.com / keeperstresstests data warehouse.

    50k GitHub stars~4.7k tokensUpdated today
    DatabasesAuto-check passed
  • Perf Comparison

    ClickHouse/ClickHouse

    Evaluate ClickHouse performance test results from existing CI/dashboard data or local perf.py runs.

    50k GitHub stars~3.9k tokensUpdated today
    DatabasesAuto-check: notes
  • Patch Release Check

    ClickHouse/ClickHouse

    Check whether ClickHouse's supported versions (last 3 majors + latest LTS) have recent stable patch releases, diagnose why the scheduled AutoReleases pipeline failed, and identify which releases…

    50k GitHub stars~4k tokensUpdated today
    DatabasesAuto-check: notes
  • Evolving The Data Model

    TriliumNext/Trilium

    A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

    38k GitHub stars~2.1k tokensUpdated today
    DatabasesAuto-check passed
  • Hybrid Cloud Outboxes

    getsentry/sentry

    Official

    Guide for creating and maintaining outbox-based eventually consistent operations in Sentry.

    46k GitHub stars~4.8k tokensUpdated today
    DatabasesAuto-check passed
  • A skill your agent uses when changing Electron SQLite IPC, database-worker operations, request-scoped progress or cancellation, worker packaging, or runtime verification of non-EPG database work.

    7.3k GitHub stars~824 tokensUpdated today
    DatabasesAuto-check passed

More from microsoft/garnet

  • PR Finalize Review

    microsoft/garnet

    Official

    Checks that a pull request's title and description match its implementation and reviews the code for Garnet best practices, reporting findings without posting them.

    12k GitHub stars~3.1k tokensUpdated today
    Auto-check passed
  • Add Garnet RESP Command

    microsoft/garnet

    Official

    Step-by-step guide for adding a new built-in RESP command to Garnet, from the command enum and parser to storage callbacks, command metadata JSON and tests.

    12k GitHub stars~9.7k tokensUpdated today
    Auto-check passed

Categories

Questions about Adaptive Spin Wait

What does Adaptive Spin Wait do?

Selects Garnet spin-wait policies based on the slow-path cost. Adaptive Spin Wait is an agent skill from microsoft/garnet, published by the product's own GitHub organization. Selects Garnet spin-wait policies based on the slow-path cost.

When should I use Adaptive Spin Wait?

Adaptive Spin Wait fits situations like: changing spin loops; thread.SpinWait; fixed spin counts; spin-to-block/backoff transitions.

How do I install Adaptive Spin Wait in Claude Code?

Run `npx skills add microsoft/garnet --skill adaptive-spin-wait -a claude-code`. Or copy the skill folder (.github/skills/adaptive-spin-wait in microsoft/garnet) into .claude/skills/adaptive-spin-wait in your project. Claude Code loads it when a task matches its description.

How do I install Adaptive Spin Wait in Codex?

Run `npx skills add microsoft/garnet --skill adaptive-spin-wait -a codex`. Or copy the skill folder (.github/skills/adaptive-spin-wait in microsoft/garnet) into .agents/skills/adaptive-spin-wait in your project. Codex loads it when a task matches its description.

Can I use Adaptive Spin Wait in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/garnet --skill adaptive-spin-wait -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/adaptive-spin-wait, .gemini/skills/adaptive-spin-wait, .github/skills/adaptive-spin-wait and .opencode/skills/adaptive-spin-wait in your project.

What does Adaptive Spin Wait need to run?

SKILL.md names no scripts, command-line tools or credentials: Adaptive Spin Wait is instructions for the agent only.

Does Adaptive Spin Wait access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Adaptive Spin Wait safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Adaptive Spin Wait use?

Adaptive Spin Wait is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Adaptive Spin Wait use?

About 1k tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Adaptive Spin Wait?

Skills that share tags, products or a category with Adaptive Spin Wait: Keeper Stress Analysis (ClickHouse/ClickHouse, 50k stars), Perf Comparison (ClickHouse/ClickHouse, 50k stars), Patch Release Check (ClickHouse/ClickHouse, 50k stars) and Evolving The Data Model (TriliumNext/Trilium, 38k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Adaptive Spin Wait?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/garnet, which has 12,045 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 8, 2026.

Source: microsoft/garnet on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.