Skip to content
PluginStats

@tanstack/ai-code-mode-snippets weekly downloads statistics

By tanstack (53 listings) · npm · AI SDKs

Persistent runtime snippet library for TanStack AI Code Mode agents and sandboxed tool orchestration.

View on npm Fresh · Dec 6, 2026

@tanstack/ai-code-mode-snippets has 1,735 recorded weekly downloads on npm, a decrease of 5.3% over the past 30 days, ranking #1931 of 3,247 tracked listings.

Weekly downloads
1,735
Official API · Dec 5, 2026
7-day growth
+9.9%
+156 weekly downloads
30-day growth
-5.3%
-97 weekly downloads
90-day growth
+1288%
+1.6K weekly downloads
Rank
#1931
▼ 72 in 7 days

About @tanstack/ai-code-mode-snippets

<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/api/readme/ai.png?theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/api/readme/ai.png" /> <img src="https://tanstack.com/api/readme/ai.png" alt="TanStack AI" width="900" /> </picture> </div> <br />

@tanstack/ai-code-mode-snippets

Persistent snippet library for TanStack AI Code Mode - LLM-created reusable code snippets.

Overview

The Snippets System extends Code Mode with persistent, LLM-creatable reusable code snippets. Snippets are TypeScript functions that the LLM can create, catalog, and invoke across sessions—enabling compounding capability over time.

Installation

pnpm add @tanstack/ai-code-mode-snippets

Usage

import {
  codeModeWithSnippets,
  createAlwaysTrustedStrategy,
} from '@tanstack/ai-code-mode-snippets'
// Node-only file storage lives behind the `/storage` subpath so the root
// export stays safe for Worker/browser bundlers.
import { createFileSnippetStorage } from '@tanstack/ai-code-mode-snippets/storage'
import { createNodeIsolateDriver } from '@tanstack/ai-isolate-node'

// Create snippet storage
const snippetStorage = createFileSnippetStorage({
  directory: './.snippets',
  trustStrategy: createAlwaysTrustedStrategy(),
})

// Create code mode config
const codeModeConfig = {
  driver: createNodeIsolateDriver(),
  tools: allTools, // Your external tools
  timeout: 60000,
  memoryLimit: 128,
}

// Build a dynamic registry and system prompt with snippets
const { toolsRegistry, systemPrompt, selectedSnippets } =
  await codeModeWithSnippets({
    config: codeModeConfig,
    adapter: anthropic('claude-haiku-4-5'), // Cheap model for snippet selection
    snippets: {
      storage: snippetStorage,
      maxSnippetsInContext: 5,
    },
    messages,
    threadId: 'thread-1',
  })

// Use in chat
const stream = chat({
  adapter: anthropic('claude-sonnet-4-6'), // Main model
  toolRegistry: toolsRegistry,
  messages,
  threadId: 'thread-1',
  systemPrompts: [basePrompt, systemPrompt],
})

Testing

This package includes a CLI for testing the snippets system. The tests verify the complete snippets lifecycle:

  1. First run (Snippet Creation): LLM uses execute_typescript to solve a problem and registers a reusable snippet
  2. Second run (Snippet Reuse): LLM calls the saved snippet directly without needing execute_typescript
Running the Simulated Test

The simulated test uses a mock adapter with predetermined responses for fully deterministic testing. No API key required.

# From the package directory
cd packages/ai-code-mode-snippets

# Run the simulated test
pnpm test:cli:simulated
Running the Live Test

The live test uses a real LLM (OpenAI or Anthropic) to verify the snippets flow with actual LLM responses.

Setup
  1. Copy the environment example file:

    cp test-cli/env.example test-cli/.env.local
    
  2. Edit test-cli/.env.local and add your API key:

    OPENAI_API_KEY=sk-...
    # or
    ANTHROPIC_API_KEY=sk-ant-...
    
Run the test
# Run with OpenAI (default)
pnpm test:cli:live

# Run with Anthropic
pnpm test:cli:live --provider anthropic

# Run with a specific model
pnpm test:cli:live --model gpt-4o-mini

# Run with verbose output
pnpm test:cli:live -v
CLI Commands
# Show help
pnpm test:cli --help

# Run simulated test (deterministic, no API key)
pnpm test:cli simulated

# Run live test (requires API key)
pnpm test:cli live [options]

Options:
  --provider <provider>  LLM provider: openai or anthropic (default: openai)
  --model <model>        Model to use (default depends on provider)
  -v, --verbose          Enable verbose output

API Reference

codeModeWithSnippets(options)

Creates Code Mode tools and system prompt with snippets integration.

Options:

  • config - Code Mode tool configuration (driver, tools, timeout, memoryLimit)
  • adapter - Text adapter for snippet selection (should be a cheap/fast model)
  • snippets.storage - Snippet storage implementation
  • snippets.maxSnippetsInContext - Maximum snippets to load into context (default: 5)
  • messages - Current conversation messages
  • threadId - Thread id of the conversation (required). The snippet selection chat uses it.
  • snippetsAsTools - Whether to include snippets as direct tools (default: true)

Returns:

  • toolsRegistry - Mutable ToolRegistry containing execute_typescript, snippet management tools, and selected snippet tools
  • systemPrompt - System prompt documenting available snippets and external functions
  • selectedSnippets - Snippets that were selected for this request
Storage

The worker/browser-safe in-memory storage (createMemorySnippetStorage) is re-exported from the root entry. The Node-only file storage (createFileSnippetStorage) imports node:fs / node:path, so it is only available from the /storage subpath — keeping the root export safe to import from Cloudflare Workers and browser bundlers:

// Worker/browser-safe — root export
import { createMemorySnippetStorage } from '@tanstack/ai-code-mode-snippets'

// Node-only — `/storage` subpath
import { createFileSnippetStorage } from '@tanstack/ai-code-mode-snippets/storage'
createFileSnippetStorage(options)

Git-friendly file-based storage:

.snippets/
├── compare_react_state_libraries/
│   ├── meta.json      # Metadata, schemas, stats
│   └── code.ts        # TypeScript implementation
└── fetch_github_stats/
    ├── meta.json
    └── code.ts
createMemorySnippetStorage(options)

In-memory storage for testing.

Trust Strategies

Snippets track execution success and promote trust levels over time:…

Description from the npm listing.

  • ai
  • ai-sdk
  • typescript
  • tanstack
  • code-mode
  • snippets
  • agents
  • llm
  • sandbox
  • tool-calling
  • tanstack-intent

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

@tanstack/ai-code-mode-snippets weekly downloads on npm, last 90 days: 1,735 weekly downloads as of Dec 5, 2026, +1288% over 90 days.@tanstack/ai-code-mode-snippetsWeekly downloads on npm · Last 90 days1,735downloads / week+1288% over 90 days01K2K3K4K5KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
@tanstack/ai-code-mode-snippets weekly downloads on npm, last 90 days: 1,735 weekly downloads as of Dec 5, 2026, +1288% over 90 days.

7/30/90-day growth

@tanstack/ai-code-mode-snippets weekly downloads growth on npm: +9.9% over 7 days, -5.3% over 30 days, +1288% over 90 days.@tanstack/ai-code-mode-snippetsWeekly downloads growth on npm1,735downloads / week now7-day growth+156 weekly downloads+9.9%30-day growth-97 weekly downloads-5.3%90-day growth+1,610 weekly downloads+1288%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
@tanstack/ai-code-mode-snippets weekly downloads growth on npm: +9.9% over 7 days, -5.3% over 30 days, +1288% over 90 days.

Ranking history

@tanstack/ai-code-mode-snippets npm ranking history: currently #1931 (by weekly downloads).@tanstack/ai-code-mode-snippetsnpm ranking · by weekly downloads · Last 90 days#1931current rank#1400#1500#1600#1700#1800#1900#2000Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 42 observations · Updated Dec 5, 2026pluginstats.com
@tanstack/ai-code-mode-snippets npm ranking history: currently #1931 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 97, #11 (overall #1,931)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 10, #9 (overall #189)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for @tanstack/ai-code-mode-snippets
Date (UTC)Weekly downloadsChange vs. previous
1,735+29
1,706-33
1,739-30
1,769-47
1,816+42
1,774+107
1,667+88
1,579+43
1,536+95
1,441+11
1,430+80
1,350-267
1,617+40
1,577—

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/@tanstack/ai-code-mode-snippets. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.