
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
claude-code-ts
Advanced tools
A powerful TypeScript wrapper for the Claude Code CLI
Seamlessly integrate Claude Code's powerful AI capabilities into your TypeScript applications
📚 Documentation • 🚀 Quick Start • 💡 Examples • 🔧 Development
npm install claude-code-ts
import { ClaudeCodeClient } from "claude-code-ts";
Before using this SDK, ensure you have:
export ANTHROPIC_API_KEY=your_api_key_here
import { ClaudeCodeClient } from "claude-code-ts";
// Initialize client
const client = new ClaudeCodeClient();
// Send a message to Claude
const response = await client.chat({
text: "Write a TypeScript function to calculate Fibonacci numbers"
});
console.log(response.content);
const client = new ClaudeCodeClient({
apiKey: "your_api_key", // Optional if ANTHROPIC_API_KEY is set
outputFormat: "json",
systemPrompt: "You are a senior TypeScript developer",
allowedTools: ["bash", "edit", "read"],
claudePath: "/custom/path/to/claude" // Optional
});
const stream = client.chatStream({
text: "Explain async/await in TypeScript with examples"
});
for await (const chunk of stream) {
if (chunk.type === "content") {
process.stdout.write(chunk.data as string);
} else if (chunk.type === "metadata") {
console.log("📊 Metadata:", chunk.data);
}
}
// Start a conversation
const response1 = await client.chat({
text: "Create a React component"
});
// Continue with the same session
const response2 = await client.chat({
text: "Now add TypeScript types to it",
sessionId: response1.sessionId
});
// List all sessions
const sessions = await client.listSessions();
console.log("Active sessions:", sessions);
const client = new ClaudeCodeClient({
outputFormat: "json",
systemPrompt: "You are an expert in modern web development",
allowedTools: ["bash", "edit", "read", "write"],
mcpConfig: "/path/to/mcp-config.json",
permissionPromptTool: "always"
});
// Update configuration dynamically
client.updateConfig({
systemPrompt: "You are now a Python expert"
});
new ClaudeCodeClient(config?: ClaudeCodeConfig)
Method | Description | Returns |
---|---|---|
chat(options) | Send a message to Claude | Promise<ClaudeCodeResponse> |
chatStream(options) | Stream responses from Claude | AsyncIterableIterator<StreamingResponse> |
listSessions() | Get all available sessions | Promise<SessionInfo[]> |
updateConfig(config) | Update client configuration | void |
interface ClaudeCodeConfig {
apiKey?: string; // API key (optional if env var set)
claudePath?: string; // Custom path to Claude CLI
systemPrompt?: string; // System prompt for conversations
outputFormat?: "text" | "json" | "streaming-json";
allowedTools?: string[]; // Tools Claude can use
mcpConfig?: string; // MCP configuration file path
permissionPromptTool?: string; // Permission prompt behavior
}
interface ClaudeCodeResponse {
content: string; // Main response content
sessionId?: string; // Session identifier
type?: string; // Response type
cost_usd?: number; // Cost in USD
duration_ms?: number; // Response duration
num_turns?: number; // Number of conversation turns
metadata?: {
toolsUsed?: string[]; // Tools used in response
tokensUsed?: number; // Tokens consumed
timestamp?: string; // Response timestamp
};
}
interface StreamingResponse {
type: "content" | "metadata" | "error"; // Chunk type
data: string | object; // Chunk data
}
interface SessionInfo {
id: string; // Session ID
createdAt: string; // Creation timestamp
lastActive: string; // Last activity timestamp
messageCount: number; // Number of messages
}
# Basic example
npx tsx examples/basic.ts
# Streaming example
npx tsx examples/streaming.ts
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
npm run dev # Start development server
npm test # Run tests
npm run build # Build for production
npm run publish # Publish to registry
We welcome contributions! Please follow these steps:
git checkout -b feature/amazing-feature
)npm test
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the developer community
Empowering developers to build amazing AI-powered applications
FAQs
TypeScript SDK wrapper for Claude Code
The npm package claude-code-ts receives a total of 4 weekly downloads. As such, claude-code-ts popularity was classified as not popular.
We found that claude-code-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.