Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
An introduction to Claude Code SDK
Search
Akihiro Okuno
July 17, 2025
Technology
4.9k
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
110
Hack Claude Code with Claude Code
choplin
8
3.8k
Introduction to ScalarDB and ScalarDB Analytics
choplin
0
470
Walk around functional web frontend programming
choplin
2
1.1k
Pre ScalaMatsuri 2020
choplin
2
200
Other Decks in Technology
See All in Technology
Amazon Bedrock Agents ClassicからAmazon Bedrock AgentCoreへ移行した際、ガードレール設定が2箇所に割れた話
matsunobu
0
160
AI Made Us Faster at Solving the Wrong Problems
marceloancelmo
0
110
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
180
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
0
110
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
240
認知負荷を吸収し、プロダクトをまたぐPR Preview基盤の設計事例
taiki45
2
560
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
220
AI臭い文章とは何なのか
nasuvitz
37
76k
CI/CDではもう遅い - 人とAIが迂回しないDevSecOps Verify基盤の再設計 -
kintotechdev
1
560
3人で1000GPU超を統合運用する?マルチクラウド&オンプレを跨ぐ、構築と運用のリアル!
kazukun0716
2
800
生成AIを使って「人が」考える技術 ― AI時代の人機共想と実践ノウハウ|UNITT AC2026
ishiirikie
0
500
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
The SEO Collaboration Effect
kristinabergwall1
1
580
How to build a perfect <img>
jonoalderson
1
6.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Optimising Largest Contentful Paint
csswizardry
37
4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
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