CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-anthropic-ai--claude-agent-sdk

SDK for building AI agents with Claude Code's capabilities to programmatically interact with Claude and build autonomous agents that can understand codebases, edit files, and execute workflows.

Overview
Eval results
Files

tools.mddocs/apis/

Built-in Tools

Claude Code's built-in tools for file operations, shell commands, web, and more.

Tool Input Types

type ToolInputSchemas =
  | AgentInput | BashInput | BashOutputInput | FileReadInput
  | FileEditInput | FileWriteInput | GlobInput | GrepInput
  | WebFetchInput | WebSearchInput | TodoWriteInput | NotebookEditInput
  | McpInput | ListMcpResourcesInput | ReadMcpResourceInput
  | KillShellInput | ExitPlanModeInput | AskUserQuestionInput;

File Tools

// Read
interface FileReadInput {
  file_path: string;
  offset?: number;
  limit?: number;
}

// Edit (string replacement)
interface FileEditInput {
  file_path: string;
  old_string: string;
  new_string: string;
  replace_all?: boolean;
}

// Write
interface FileWriteInput {
  file_path: string;
  content: string;
}

Search Tools

// Glob (find files)
interface GlobInput {
  pattern: string;
  path?: string;
}

// Grep (search contents)
interface GrepInput {
  pattern: string;
  path?: string;
  glob?: string;
  output_mode?: 'content' | 'files_with_matches' | 'count';
  '-B'?: number;
  '-A'?: number;
  '-C'?: number;
  '-n'?: boolean;
  '-i'?: boolean;
  type?: string;
  head_limit?: number;
  offset?: number;
  multiline?: boolean;
}

Shell Tools

// Bash (execute commands)
interface BashInput {
  command: string;
  timeout?: number;
  description?: string;
  run_in_background?: boolean;
  dangerouslyDisableSandbox?: boolean;
}

// BashOutput (read background shell)
interface BashOutputInput {
  bash_id: string;
  filter?: string;
}

// KillShell (terminate background)
interface KillShellInput {
  shell_id: string;
}

Web Tools

// WebFetch (fetch & process)
interface WebFetchInput {
  url: string;
  prompt: string;
}

// WebSearch
interface WebSearchInput {
  query: string;
  allowed_domains?: string[];
  blocked_domains?: string[];
}

Agent Tool

// Task tool (invoke subagents)
interface AgentInput {
  description: string;
  prompt: string;
  subagent_type: string;
  model?: 'sonnet' | 'opus' | 'haiku';
  resume?: string;
}

Other Tools

// NotebookEdit (Jupyter)
interface NotebookEditInput {
  notebook_path: string;
  cell_id?: string;
  new_source: string;
  cell_type?: 'code' | 'markdown';
  edit_mode?: 'replace' | 'insert' | 'delete';
}

// TodoWrite (task management)
interface TodoWriteInput {
  todos: Array<{
    content: string;
    status: 'pending' | 'in_progress' | 'completed';
    activeForm: string;
  }>;
}

// ListMcpResources
interface ListMcpResourcesInput {
  server?: string;
}

// ReadMcpResource
interface ReadMcpResourceInput {
  server: string;
  uri: string;
}

// McpInput (generic)
interface McpInput {
  [k: string]: unknown;
}

// ExitPlanMode
interface ExitPlanModeInput {
  [k: string]: unknown;
}

// AskUserQuestion
interface AskUserQuestionInput {
  questions: Array<{
    question: string;
    header: string;
    options: Array<{label: string; description: string}>;
    multiSelect: boolean;
  }>;
  answers?: {[k: string]: string};
}

Tool Configuration

// Specific tools
{tools: ['Read', 'Grep', 'Glob', 'Bash']}

// All Claude Code tools
{tools: {type: 'preset', preset: 'claude_code'}}

// Whitelist
{allowedTools: ['Read', 'Write', 'Edit']}

// Blacklist
{
  tools: {type: 'preset', preset: 'claude_code'},
  disallowedTools: ['Bash', 'WebFetch', 'WebSearch']
}

Usage Patterns

File Operations

// Agent uses tools automatically
const result = query({
  prompt: 'Read main.ts, find TODOs, update README',
  options: {tools: ['Read', 'Grep', 'Write']}
});
// 1. Read main.ts
// 2. Grep for TODOs
// 3. Write README

Search

const result = query({
  prompt: 'Find all TypeScript files importing React',
  options: {tools: ['Glob', 'Grep']}
});
// 1. Glob: *.ts, *.tsx
// 2. Grep: React imports

Shell

const result = query({
  prompt: 'Install dependencies and run tests',
  options: {
    tools: ['Bash'],
    sandbox: {enabled: true, autoAllowBashIfSandboxed: true}
  }
});
// 1. Bash: npm install
// 2. Bash: npm test

Web

const result = query({
  prompt: 'Search for TypeScript best practices',
  options: {tools: ['WebSearch', 'WebFetch']}
});
// 1. WebSearch: find results
// 2. WebFetch: fetch & analyze

Subagents

const result = query({
  prompt: 'Have architect analyze codebase',
  options: {
    tools: ['Read', 'Grep', 'Glob', 'Agent'],
    agents: {
      'architect': {
        description: 'Analyzes architecture',
        tools: ['Read', 'Grep', 'Glob'],
        prompt: 'You are an architecture expert...',
        model: 'opus'
      }
    }
  }
});
// Agent tool invokes 'architect' subagent

Tool Access Control

// Read-only
{allowedTools: ['Read', 'Grep', 'Glob']}

// No shell
{
  tools: {type: 'preset', preset: 'claude_code'},
  disallowedTools: ['Bash', 'WebFetch', 'WebSearch']
}

// Minimal
{tools: ['Grep', 'Glob']}

Install with Tessl CLI

npx tessl i tessl/npm-anthropic-ai--claude-agent-sdk

docs

apis

agents.md

hooks.md

mcp.md

messages.md

options.md

permissions.md

query-api.md

sandbox.md

tools.md

index.md

patterns.md

quick-reference.md

types.md

tile.json