From kitaru
Migrate existing Claude Agent SDK code to Kitaru's Claude Agent SDK adapter. Use when code mentions claude_agent_sdk, claude_agent_sdk.query, query, ClaudeAgentOptions, ClaudeSDKClient, ResultMessage, SystemMessage, session_id, resume, cwd, allowed_tools, Bash, Read, Write, Edit, MCP, hooks, permissions, file checkpointing, transcript, workspace, KitaruClaudeRunner, ClaudeRunRequest, ClaudeRunResult, ClaudeCapturePolicy, checkpoint_strategy, or invocation. Helps classify direct, approximate, and absent mappings, keep Claude-owned internals inside one invocation boundary, and produce a migration report with replay, workspace, session, tool, Bash, MCP, hook, and privacy risks called out.
How this skill is triggered — by the user, by Claude, or both
Slash command
/kitaru:kitaru-claude-agent-sdk-migrationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill to inspect existing Claude Agent SDK code and move the safe outer
Use this skill to inspect existing Claude Agent SDK code and move the safe outer
execution boundary to Kitaru's KitaruClaudeRunner, ClaudeRunRequest, and
ClaudeRunResult surfaces.
The output should be conservative:
direct,
approximate, or absent.MIGRATION_REPORT.md section or file that names behavior changes and
review risks.Do not promise that Kitaru can see or replay Claude-internal model calls, tool calls, Bash commands, MCP calls, hooks, permissions, workspace edits, or file checkpointing steps.
Claude Agent SDK owns the inner Claude Code-style loop. It decides which files to read, which Bash commands to run, which tools or MCP servers to call, which hooks fire, how permissions work, and how sessions/files are recorded.
Kitaru changes the doorway you use to enter that loop:
import kitaru
from claude_agent_sdk import ClaudeAgentOptions
from kitaru.adapters.claude_agent_sdk import KitaruClaudeRunner, ClaudeRunRequest
runner = KitaruClaudeRunner(
name="read_only_reviewer",
options=ClaudeAgentOptions(allowed_tools=["Read", "Glob", "Grep"]),
)
@kitaru.flow
def review(prompt: str) -> str:
result = runner.run_sync(ClaudeRunRequest.start(prompt))
return result.final_text or ""
Concrete story: Claude starts, reads files, maybe runs tools or Bash, maybe uses MCP or hooks, and eventually returns a final result message. Claude owns that story. Kitaru records one completed invocation around it.
Use it when the user asks to:
claude_agent_sdk.query(...) with KitaruClaudeRunner;ClaudeAgentOptions, cwd, max_turns, allowed_tools, MCP,
hooks, permissions, or sessions;session_id / resume through ClaudeRunRequest.resume(...);checkpoint_strategy="invocation";Do not use it to:
KitaruClaudeRunner from inside an existing Kitaru checkpoint unless the
user explicitly opts into direct execution and accepts replay risk.Classify each source pattern before editing:
direct: Kitaru has a close adapter surface for the same outer behavior.
Example: one query(prompt=...) task becomes
runner.run_sync(ClaudeRunRequest.start(prompt)).approximate: The code can move, but replay, session, transcript, workspace,
capture, or option behavior differs. Example: ClaudeAgentOptions becomes
fixed options= or per-request options_factory=.absent: There is no safe automatic migration. Example: a plan to checkpoint
each Claude Bash command as a Kitaru checkpoint.Unsupported patterns must not be silently approximated. Add a concrete
# TODO(migration): ... comment near proposed code, list it in the report, and
explain the redesign needed.
query(...), ClaudeSDKClient, options,
allowed_tools, cwd, max_turns, sessions, transcripts, MCP servers,
hooks, permissions, file checkpointing, Bash, workspace writes, and existing
Kitaru decorators.references/concept-map.md and
references/gaps-and-flags.md. Count direct, approximate, high-risk, and
blocked items.checkpoint_strategy="invocation".
One completed Claude SDK invocation becomes one Kitaru checkpoint.query(...) entrypoints with
KitaruClaudeRunner plus ClaudeRunRequest. Keep Claude options Claude-owned
and add explicit capture-policy review.MIGRATION_REPORT.md. Include the inventory, chosen boundary,
classifications, flags, behavior differences, and verification plan.allowed_tools=[] or safe
read-only tools. If provider execution is not run, say the check was static.Look for:
from claude_agent_sdk import query, query(...), ClaudeSDKClient,
client.query(...), or client.receive_response().ClaudeAgentOptions(...), cwd=, max_turns=, allowed_tools=,
permission_mode=, setting_sources=, mcp_servers=, hooks=, or custom
agents/skills/plugins.SystemMessage, ResultMessage, session_id, resume=,
continue_conversation, fork_session, transcripts, or session stores.enable_file_checkpointing=True, rewind_files(...), or checkpoint UUIDs.Read, Write, Edit, Bash, Glob, Grep,
WebSearch, WebFetch, or AskUserQuestion.@kitaru.flow or @kitaru.checkpoint wrappers.calls, runner_call, model_call, tool_call,
step, run, or granular checkpoints.claude_agent_sdk as the agent runtime.KitaruClaudeRunner(name=..., checkpoint_strategy="invocation").options= for fixed ClaudeAgentOptions and options_factory= when
options depend on the ClaudeRunRequest.ClaudeRunRequest.start(prompt, cwd=..., max_turns=...) for fresh tasks.ClaudeRunRequest.resume(prompt, session_id=..., cwd=...) when the source
resumes a specific Claude session.allow_direct_execution_inside_checkpoint=True and accepts
duplicate-invocation risk.Minimal read-only migration:
import kitaru
from claude_agent_sdk import ClaudeAgentOptions
from kitaru.adapters.claude_agent_sdk import KitaruClaudeRunner, ClaudeRunRequest
runner = KitaruClaudeRunner(
name="read_only_reviewer",
options=ClaudeAgentOptions(allowed_tools=["Read", "Glob", "Grep"]),
)
@kitaru.flow
def review_code(prompt: str) -> str:
result = runner.run_sync(ClaudeRunRequest.start(prompt))
return result.final_text or ""
print(review_code.run("Summarize the repository structure.").wait())
For full examples, load references/code-patterns.md.
When a pattern is unsafe or unsupported:
# TODO(migration): ... comment near the code if producing
code.LOW, MEDIUM, HIGH, or BLOCKER.Every non-trivial migration must include or draft MIGRATION_REPORT.md with:
Use references/report-template.md when a full report is needed.
Avoid these:
"invocation".runner.run_sync(...) from inside an active event loop.Load only the reference file needed for the current task:
references/concept-map.md — source-to-target mapping table and
classification guidance.references/code-patterns.md — import-complete migration examples.references/gaps-and-flags.md — severity definitions, upstream assumptions,
and must-flag patterns.references/report-template.md — Claude Agent SDK-specific migration report
template.Kitaru source references:
kitaru/docs/content/docs/adapters/claude-agent-sdk.mdxkitaru/src/kitaru/adapters/claude_agent_sdk/__init__.pykitaru/examples/integrations/claude_agent_sdk_agent/README.mdnpx claudepluginhub zenml-io/kitaru-skills --plugin kitaruGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.