From claude-agent-ruby
Implements Ruby code using claude-agent-sdk gem for Claude Code: one-shot queries, Client sessions, 27 hooks, permissions, MCP servers, message types, Rails integration.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-agent-ruby:claude-agent-rubyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
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.
ClaudeAgentSDK.query for one-shot queries or streaming input. Internally uses the control protocol (streaming mode).ClaudeAgentSDK::Client for multi-turn sessions, hooks, permission callbacks, MCP server control, or dynamic model switching; wrap in Async do ... end.wait.create_tool, create_sdk_mcp_server) for in-process tools; choose external MCP configs for subprocess/HTTP servers.ClaudeAgentSDK.list_sessions / ClaudeAgentSDK.get_session_messages for browsing previous session transcripts (pure filesystem, no CLI needed).ClaudeAgentSDK::ClaudeAgentOptions and pass it to query or Client.new.AssistantMessage, UserMessage, ResultMessage, StreamEvent, RateLimitEventInitMessage (session start / /clear — carries uuid, session_id, tools, model, cwd, agents, betas, claude_code_version, permission_mode, slash_commands, output_style, skills, plugins, fast_mode_state)CompactBoundaryMessage (uuid, session_id, compact_metadata with pre_tokens, trigger, preserved_segment)StatusMessage (compacting status, permission mode changes)TaskStartedMessage (+ workflow_name, prompt), TaskProgressMessage (+ summary), TaskNotificationMessageHookStartedMessage, HookProgressMessage, HookResponseMessageSessionStateChangedMessage (idle/running/requires_action)ToolProgressMessage (elapsed_time_seconds per tool), ToolUseSummaryMessageAuthStatusMessage (isAuthenticating, output, error)FilesPersistedMessage (files, failed, processed_at)APIRetryMessage (attempt, max_retries, retry_delay_ms, error_status)LocalCommandOutputMessage, ElicitationCompleteMessage, PromptSuggestionMessagenil (forward-compatible)TextBlock, ThinkingBlock, ToolUseBlock, ToolResultBlock, UnknownBlockResultMessage carries: stop_reason, model_usage (per-model breakdown), permission_denials, errors (on error subtypes), uuid, fast_mode_stateoutput_format for JSON schema structured outputthinking: with ThinkingConfigAdaptive, ThinkingConfigEnabled(budget_tokens:), or ThinkingConfigDisabled. Use effort: for effort level.All hook events: PreToolUse, PostToolUse, PostToolUseFailure, Notification, UserPromptSubmit, SessionStart, SessionEnd, Stop, StopFailure, SubagentStart, SubagentStop, PreCompact, PostCompact, PermissionRequest, PermissionDenied, Setup, TeammateIdle, TaskCreated, TaskCompleted, Elicitation, ElicitationResult, ConfigChange, WorktreeCreate, WorktreeRemove, InstructionsLoaded, CwdChanged, FileChanged.
Define hooks as Ruby procs/lambdas. Do not combine can_use_tool with permission_prompt_tool_name. Tool-lifecycle hooks carry agent_id and agent_type when firing inside subagents. StopHookInput and SubagentStopHookInput include last_assistant_message.
Hook-specific outputs with to_h: PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, NotificationHookSpecificOutput, SubagentStartHookSpecificOutput, SessionStartHookSpecificOutput, SetupHookSpecificOutput, PermissionRequestHookSpecificOutput, PermissionDeniedHookSpecificOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput.
Use bare: true for minimal startup — skips hooks, LSP, plugin sync, CLAUDE.md auto-discovery, auto-memory, keychain reads. Explicitly provide context via system_prompt, add_dirs, setting_sources, allowed_tools.
options = ClaudeAgentSDK::ClaudeAgentOptions.new(
bare: true,
system_prompt: 'You are a code reviewer.',
permission_mode: 'bypassPermissions'
)
SandboxSettings: enabled, fail_if_unavailable, auto_allow_bash_if_sandboxed, excluded_commands, allow_unsandboxed_commands, network, filesystem, ignore_violations (Hash), enable_weaker_nested_sandbox, enable_weaker_network_isolation, ripgrepSandboxNetworkConfig: allowed_domains, allow_managed_domains_only, allow_unix_sockets, allow_all_unix_sockets, allow_local_binding, http_proxy_port, socks_proxy_portSandboxFilesystemConfig: allow_write, deny_write, deny_read, allow_read, allow_managed_read_paths_onlymcp__<server>__<tool> in allowed_toolsannotations: on create_tool for MCP tool annotationsinput_schema hashes are acceptedresume, session_id, fork_session for session handlingClient#reconnect_mcp_server(name), Client#toggle_mcp_server(name, enabled), Client#stop_task(task_id) for live controlClient#rewind_files(uuid) with enable_file_checkpointing: trueMcpStatusResponse.parse(client.get_mcp_status) for typed MCP statusbundle show claude-agent-sdk<gem_path>/README.md for canonical usage and option examples<gem_path>/lib/claude_agent_sdk/types.rb for all types<gem_path>/lib/claude_agent_sdk/message_parser.rb for message parsing<gem_path>/lib/claude_agent_sdk/sessions.rb for session browsing<gem_path>/lib/claude_agent_sdk/errors.rb for error classesreferences/usage-map.md for a README section map and minimal skeletonsreferences/usage-map.md to map tasks to README sections, gem paths, and minimal skeletons.references/message-handling.md to extract text/tool blocks, build streaming input, use Client runtime APIs, and capture UUIDs for rewind.references/options.md to configure ClaudeAgentOptions (defaults, tools, permissions, output formats, budgets, sandbox, sessions, agents, custom transports), and to browse/mutate sessions.references/mcp-servers.md to define in-process SDK MCP tools/resources/prompts, configure external MCP servers, or manage MCP servers at runtime.references/rails.md for initializers, background jobs, ActionCable streaming, and session resumption patterns.references/troubleshooting.md for common setup/runtime errors and timeout tuning.npx claudepluginhub ya-luotao/claude-agent-sdk-ruby --plugin claude-agent-rubyBuilds autonomous AI agents using the Claude Agent SDK (TypeScript and Python). Covers hooks, MCP servers, sandbox, session management, and structured outputs.
Implements Anthropic Claude Agent SDK for autonomous agents, subagents, tool orchestration, MCP servers, and multi-step workflows. Useful for session management, permissions, and errors like CLI not found or context exceeded.
Guides programmatic control of Claude Code sessions via Claude Agent SDK in TypeScript/JavaScript or Python. Supports custom agents, tools, streaming, and event handling for building AI agents.