npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

not-claude-agent-sdk

v1.0.2

Published

Lightweight drop-in replacement for @anthropic-ai/claude-agent-sdk — spawns the Claude CLI instead of bundling the SDK

Readme

not-claude-agent-sdk

A lightweight, zero-dependency alternative to @anthropic-ai/claude-agent-sdk. Instead of bundling the SDK, it spawns the claude CLI as a subprocess and streams back the same typed messages — giving you an identical async-generator API with no extra runtime dependencies.

Prerequisites

You must have Claude Code installed and authenticated before using this package.

1. Install Claude Code

npm install -g @anthropic-ai/claude-code

2. Authenticate

Run claude once in your terminal and follow the prompts to sign in with your Anthropic account (or configure an API key):

claude

You'll be guided through authentication on first launch. Once complete, the CLI stores your credentials locally and you're ready to go.

Tip: You can verify everything is working by running claude "Hello" — you should see a response streamed to your terminal.

Installation

npm install not-claude-agent-sdk

Or with your preferred package manager:

pnpm add not-claude-agent-sdk
yarn add not-claude-agent-sdk

Quick Start

import { query } from "not-claude-agent-sdk";

for await (const message of query({ prompt: "What is 2 + 2?" })) {
  if (message.type === "assistant") {
    for (const block of message.message.content) {
      if (block.type === "text") {
        process.stdout.write(block.text);
      }
    }
  }

  if (message.type === "result" && message.subtype === "success") {
    console.log(`\nCost: $${message.total_cost_usd.toFixed(4)}`);
  }
}

Usage

The query() function returns an async generator that yields typed SDKMessage objects — the same types as the official SDK.

import { query, type SDKMessage } from "not-claude-agent-sdk";

const conversation = query({
  prompt: "Refactor the auth module to use JWT",
  options: {
    model: "claude-sonnet-4-6",
    permissionMode: "plan",
    maxTurns: 20,
    systemPrompt: "You are a senior TypeScript engineer.",
  },
});

for await (const message of conversation) {
  switch (message.type) {
    case "system":
      if (message.subtype === "init") {
        console.log(`Model: ${message.model}, Tools: ${message.tools.length}`);
      }
      break;

    case "assistant":
      for (const block of message.message.content) {
        if (block.type === "text") process.stdout.write(block.text);
        if (block.type === "tool_use") console.log(`\n[tool] ${block.name}`);
      }
      break;

    case "result":
      console.log(`Done — ${message.num_turns} turns, $${message.total_cost_usd.toFixed(4)}`);
      break;
  }
}

Interrupting & Closing

const conversation = query({ prompt: "Do a long task" });

// Interrupt current tool execution (sends SIGINT)
await conversation.interrupt();

// Gracefully terminate the process
conversation.close();

Using an AbortController

const controller = new AbortController();

const conversation = query({
  prompt: "Analyze the codebase",
  options: { abortController: controller },
});

// Cancel from anywhere
setTimeout(() => controller.abort(), 30_000);

for await (const message of conversation) {
  // ...
}

MCP Servers

const conversation = query({
  prompt: "List all open issues",
  options: {
    mcpServers: {
      github: {
        command: "npx",
        args: ["-y", "@modelcontextprotocol/server-github"],
        env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN! },
      },
    },
  },
});

Custom Claude Binary Path

If claude isn't on your PATH, you can point to it explicitly:

query({
  prompt: "Hello",
  options: {
    pathToClaudeCodeExecutable: "/usr/local/bin/claude",
  },
});

Or set the CLAUDE_BIN environment variable:

CLAUDE_BIN=/usr/local/bin/claude node my-script.js

API Reference

query(params: QueryParams): Query

| Parameter | Type | Description | |---|---|---| | params.prompt | string | The prompt to send to Claude | | params.options | QueryOptions | Optional configuration (see below) |

Returns a Query object — an async generator yielding SDKMessage objects, with additional control methods:

| Method / Property | Description | |---|---| | interrupt() | Send SIGINT to interrupt the current tool execution | | close() | Gracefully terminate the Claude process | | childProcess | The underlying ChildProcess (available after iteration starts) |

QueryOptions

| Option | Type | Default | Description | |---|---|---|---| | model | string | CLI default | Model to use (e.g. "claude-sonnet-4-6") | | permissionMode | PermissionMode | "default" | Permission mode for tool execution | | maxTurns | number | — | Maximum number of agentic turns | | maxBudgetUsd | number | — | Maximum spend in USD | | systemPrompt | string | — | Custom system prompt | | allowedTools | string[] | — | Whitelist of allowed tools | | disallowedTools | string[] | — | Blacklist of disallowed tools | | tools | string[] | — | Additional tools to register | | mcpServers | Record<string, McpServerConfig> | — | MCP server configurations | | cwd | string | process.cwd() | Working directory for the Claude process | | env | Record<string, string> | — | Additional environment variables | | abortController | AbortController | — | Controller for cancellation | | thinking | ThinkingConfig | — | Extended thinking configuration | | effort | "low" \| "medium" \| "high" \| "max" | — | Reasoning effort level | | continue | boolean | — | Continue the most recent conversation | | resume | string | — | Resume a specific session by ID | | sessionId | string | — | Use a specific session ID | | debug | boolean | — | Enable debug output | | pathToClaudeCodeExecutable | string | "claude" | Path to the Claude CLI binary |

Message Types

The generator yields these message types (discriminated by message.type):

| Type | Description | |---|---| | system | Init info, status updates, task progress, hooks | | assistant | Claude's responses (text, tool calls, thinking) | | user | Tool results flowing back to Claude | | stream_event | Partial streaming events (when includePartialMessages is enabled) | | result | Final result with usage stats and cost | | tool_progress | Progress updates for long-running tools | | tool_use_summary | Summaries of tool usage | | auth_status | Authentication status changes | | rate_limit_event | Rate limit information | | prompt_suggestion | Suggested follow-up prompts |

License

ISC