Claude Code SDK – Anthropic

https://news.ycombinator.com/rss Hits: 5
Summary

The Claude Code SDK allows developers to programmatically integrate Claude Code into their applications. It enables running Claude Code as a subprocess, providing a way to build AI-powered coding assistants and tools that leverage Claude’s capabilities. The SDK currently support command line usage. TypeScript and Python SDKs are coming soon. Basic SDK usage The Claude Code SDK allows you to use Claude Code in non-interactive mode from your applications. Here’s a basic example: Advanced usage Multi-turn conversations For multi-turn conversations, you can resume conversations or continue from the most recent session: Custom system prompts You can provide custom system prompts to guide Claude’s behavior: You can also append instructions to the default system prompt: MCP Configuration The Model Context Protocol (MCP) allows you to extend Claude Code with additional tools and resources from external servers. Using the --mcp-config flag, you can load MCP servers that provide specialized capabilities like database access, API integrations, or custom tooling. Create a JSON configuration file with your MCP servers: Then use it with Claude Code: Note: When using MCP tools, you must explicitly allow them using the --allowedTools flag. MCP tool names follow the pattern mcp__<serverName>__<toolName> where: serverName is the key from your MCP configuration file toolName is the specific tool provided by that server This security measure ensures that MCP tools are only used when explicitly permitted. Available CLI options The SDK leverages all the CLI options available in Claude Code. Here are the key ones for SDK usage: FlagDescriptionExample--print, -pRun in non-interactive modeclaude -p "query"--output-formatSpecify output format (text, json, stream-json)claude -p --output-format json--resume, -rResume a conversation by session IDclaude --resume abc123--continue, -cContinue the most recent conversationclaude --continue--verboseEnable verbose loggingclaude --verbose--max-turnsLim...

First seen: 2025-05-19 18:56

Last seen: 2025-05-19 22:56