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
100
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
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
170
AIエージェント時代のPlatform as a Product —— テックリードがPdMとして回す発見・導入・計測 / Platform as a Product in the AI Agent Era
toshi0607
0
190
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.7k
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
610
AIに書かせて、プラットフォームで縛る ― EKSプラットフォームで実践した責任境界と権限設計
elmodev09
0
570
What the customer really needed
kawaguti
PRO
3
230
Goodbye ShellScript, Hello File-based App
shunsock
0
1.1k
CI/CDではもう遅い - 人とAIが迂回しないDevSecOps Verify基盤の再設計 -
kintotechdev
1
260
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
14
9.9k
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
33
32k
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
3.1k
AI coding 整合正規方法
philipz
0
550
Featured
See All Featured
KATA
mclloyd
PRO
35
16k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
The agentic SEO stack - context over prompts
schlessera
0
940
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
250
Embracing the Ebb and Flow
colly
88
5.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Documentation Writing (for coders)
carmenintech
77
5.5k
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