Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
An introduction to Claude Code SDK
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Akihiro Okuno
July 17, 2025
Technology
4.7k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
An introduction to Claude Code SDK
Akihiro Okuno
July 17, 2025
More Decks by Akihiro Okuno
See All by Akihiro Okuno
My 4 months with Nix
choplin
0
68
Hack Claude Code with Claude Code
choplin
8
3.7k
Introduction to ScalarDB and ScalarDB Analytics
choplin
0
440
Walk around functional web frontend programming
choplin
2
1.1k
Pre ScalaMatsuri 2020
choplin
2
190
Other Decks in Technology
See All in Technology
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
BigQuery の Cross-cloud Lakehouse への歩み
phaya72
2
550
React、まだ楽しくて草
uhyo
7
4.1k
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development with AI-DLC
yoshidashingo
0
140
GoとSIMDとWasmの今。
askua
3
510
JJUG CCC 2026 Spring AI時代の開発こそ標準化を武器に! ― 方式・プロセス・プラットフォームの標準化
s27watanabe
2
720
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Agentic ERPをどう設計するか ー 受発注エージェントを動かす、現場の知見と設計思想ー
recerqainc
1
1.5k
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
360
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
500
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
4
1.1k
AI と創る新たな世界 / A New World Created with AI
ks91
PRO
0
110
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Facilitating Awesome Meetings
lara
57
6.9k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
Tell your own story through comics
letsgokoyo
1
940
Visualization
eitanlees
152
17k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
400
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
30 Presentation Tips
portentint
PRO
1
320
A better future with KSS
kneath
240
18k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Transcript
Claude Code SDKの話 2025年7月17日 - #claudecode_findy Akihiro Okuno (@choplin) 1
Akihiro Okuno 株式会社Scalar 何をしている人? データベースの中の技術が好き データベース関連のミドルウェアウェア開 発 Links X: twitter.com/choplin
GitHub: github.com/choplin Claude Code活動 6月にClaude Maxで利用開始 Claude Codeが色々足りてないので周辺ツ ールを作り始める 作ったツール cclog: セッションログ管理CLI code-review.nvim: Neovimプラグイン mcp-gemini-cli: Gemini連携MCP amux(WIP): tmux+worktree管理 vault.md(WIP): Context Engineeringのため の文書管理 自己紹介 2
1. Opus 4の自走力 高度な推論能力と実装力 2. エージェントとしての自律性 計画・実行・修正の自動化 3. CLIの親和性 既存の開発フローに統合
+ 月額固定 コストを気にせず使い放題 Claude Codeの何がすごいのか? 参考: 「Claude CodeでClaude Codeをハックする」 https://speakerdeck.com/choplin/hack-claude-code-with-claude-code 3
既存の開発フローとの親和性 シェル: alias, function, スクリプト化 セッション: tmux/screenで並行作業 CI/CD: GitHub Actions,
Jenkins統合 テキストベースでの連携 履歴: ~/.claude/ にjsonl保存 検索: grep, jq, awkで自在に処理 再利用: セッション再開、プロンプト共有 コミュニティの拡張例 sniffle (Chip Huyen) / vibe-kanban (BloopAI) / cclog (自作) / code-review.nvim (自作) CLIの強み 4
Claude Codeをアプリケーションに統合するためのライブラリ https://docs.anthropic.com/en/docs/claude-code/sdk Claude Codeをサブプロセスとして実行 Claude Code SDKとは? ...SDK? 🤔
5
CLI SDK claude -p " コードをレビューして" TypeScript SDK import {
query } from "@anthropic-ai/claude-code"; for await (const message of query({ prompt: " コードをレビューして" })) { console.log(message); } Python SDK from claude_code_sdk import query async for message in query(prompt=" コードをレビューして"): print(message) SDKの使い方 6
@anthropic-ai/claude-code/sdk.mjs function query({ prompt, options: { // ... executable =
isRunningWithBun() ? "bun" : "node", // ... pathToClaudeCodeExecutable = join(__dirname2, "cli.js"), // ← claude コマンドの実体 } = {}, }) { // ... const child = spawn( executable, [...executableArgs, pathToClaudeCodeExecutable, ...args], { /* spawn options */ }, ); } TypeScript SDKの内部実装 CLIをサブプロセスとして実行している 7
非インタラクティブモードの必要性 通常のClaude Code: 対話的なセッションを開始 SDKやスクリプトから使う場合: ユーザー入力を待たない -p, --print オプション: 応答を出力して対話モードに入らない
# 通常(インタラクティブ) claude " コードを分析して" # → 対話セッションが開始 # -p オプション(非インタラクティブ) claude -p " コードを分析して" # → 応答を出力(対話モードなし) # パイプで他のコマンドと連携 echo "Explain this code" | claude -p CLI SDKの最重要オプション 8
出力形式オプション # JSON 形式で出力(スクリプティングに最適) claude -p " ファイルを読んで" --output-format json
# JSON Lines 形式でストリーミング出力 claude -p " コードを分析して" --output-format stream-json # 入出力を両方JSON Lines に claude -p --output-format stream-json --input-format stream-json セッション管理オプション # 最新の会話を継続 claude --continue # 特定のセッションID から再開 claude --resume abc123def456 CLI SDKのオプション 9
その他のオプション --system-prompt : カスタムシステムプロンプトを設定 --permission-prompt-tool : ツール使用の許可をプロンプトで確認 --max-turns : エージェントのターン数を制限
CLIのSDKのオプション 10
Claude Code CLI 強み: 既存の開発フローとの親和性 プログラマブル: JSON出力、セッション管理 拡張性: シェルスクリプト、CI/CD統合 Claude
Code SDK 実体: CLIをサブプロセスとして実行するラッパー 利点: 既存のCLI機能をそのまま活用可能 対応言語: TypeScript, Python (CLIを直接使えば何でも) まとめ 11