Skip to main content

Installation

Setup

Set your API key:
Get your key from the dashboard.

Usage

Swap your import — everything else stays the same:
All Claude SDK types are re-exported from raysurfer, so you don’t need a separate import:

How It Works

  1. On query: Retrieves cached code blocks matching your task
  2. Injects into prompt: Agent sees proven code snippets
  3. After success: New code is cached for next time
Caching is enabled automatically when RAYSURFER_API_KEY is set. Without it, behaves exactly like the original SDK.

Agent-Owned Repos

Set agentId to isolate uploads/searches into an agent-owned repo:

Agent-Accessible Functions

Decorator flow:
raysurfer.yaml flow:

Class-based API

For users who prefer a class-based interface:
RaysurferClient is also exported as an alias for ClaudeSDKClient — use whichever name you prefer.

System Prompt Preset

Use the Claude Code preset system prompt with appended instructions:

Query Control Methods

The query() function returns a Query object with full control methods:

Snippet Retrieval Scope

Control which cached snippets are retrieved:

Public Snippets

Include community public snippets (crawled from GitHub) alongside your private snippets:
See How It Works — Public Snippets for details.

Low-Level API

For custom integrations, use the RaySurfer client directly:

Low-Level Client Options

Response Fields

The search() response includes: Each CodeFile contains:

Search Response

The search() method returns a SearchResponse: Each SearchMatch contains:

Method Reference

Programmatic Tool Calling

Also available as an integration guide: Register TypeScript Functions. Register local tools, then either pass userCode (primary mode) or use optional sandbox codegen with your own key + prompt:
tool() lets you wrap any local function as a tool callback. The description string you pass is included in the tool schema payload.

How It Works

  1. SDK opens a live callback channel for tool call routing
  2. Your app sends either userCode (primary mode) or codegen (optional mode) to /api/execute/run
  3. Code runs in a Modal sandbox — tool calls are routed back to your local functions through that callback channel
  4. Results are returned with full tool call history
Use exactly one mode per call:
  • userCode: run pre-generated code directly (recommended default)
  • codegen: generate code in sandbox and run it

Execute Options

ExecuteResult Fields