claude-agent-ruby
SKILL.md
Claude Agent Ruby SDK
Overview
Use this skill to build or refactor Ruby integrations with Claude Code via claude-agent-sdk, favoring the gem's README and types for exact APIs.
Decision Guide
- Choose
ClaudeAgentSDK.queryfor one-shot queries or streaming input. Internally uses the control protocol (streaming mode) since v0.7.0. - Choose
ClaudeAgentSDK::Clientfor multi-turn sessions, hooks, permission callbacks, or dynamic model switching; wrap inAsync do ... end.wait. - Choose SDK MCP servers (
create_tool,create_sdk_mcp_server) for in-process tools; choose external MCP configs for subprocess/HTTP servers.
Implementation Checklist
- Confirm prerequisites (Ruby 3.2+, Node.js, Claude Code CLI).
- Build
ClaudeAgentSDK::ClaudeAgentOptionsand pass it toqueryorClient.new. - Handle messages by type (
AssistantMessage,ResultMessage,UserMessage, etc.) and content blocks (TextBlock,ToolUseBlock, etc.). - Use
output_formatand readStructuredOutputtool-use blocks for JSON schema responses. - Use
thinking:withThinkingConfigAdaptive,ThinkingConfigEnabled(budget_tokens:), orThinkingConfigDisabledto control extended thinking. Useeffort:('low','medium','high') for effort level. - Define hooks and permission callbacks as Ruby procs/lambdas; do not combine
can_use_toolwithpermission_prompt_tool_name. Hook inputs includetool_use_idonPreToolUseHookInputandPostToolUseHookInput. - For SDK MCP tools, include
mcp__<server>__<tool>inallowed_tools. Useannotations:oncreate_toolfor MCP tool annotations. - Use
toolsorToolsPresetfor base tool selection; useappend_allowed_toolswhen extending defaults. - Configure sandboxing via
SandboxSettingsandSandboxNetworkConfigwhen requested. - Use
resume,session_id, andfork_sessionfor session handling; enable file checkpointing only when explicitly needed. - Note: when
system_promptis nil (default), the SDK passes--system-prompt ""to suppress the default Claude Code system prompt.
Where To Look For Exact Details
- Locate the gem path with
bundle show claude-agent-sdkorruby -e 'puts Gem::Specification.find_by_name(\"claude-agent-sdk\").full_gem_path'. - Read
<gem_path>/README.mdfor canonical usage and option examples. - Inspect
<gem_path>/lib/claude_agent_sdk/types.rbfor the full options and type list. - Inspect
<gem_path>/lib/claude_agent_sdk/errors.rbfor error classes and handling. - Use
references/usage-map.mdfor a README section map and minimal skeletons.
Resources
references/
Use references/usage-map.md to map tasks to README sections and gem paths.
Weekly Installs
2
Repository
ya-luotao/skillsGitHub Stars
1
First Seen
14 days ago
Security Audits
Installed on
opencode2
gemini-cli2
codebuddy2
github-copilot2
codex2
kimi-cli2