Ruby — 175 Operations for AI Agents

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Ruby code through the act MCP server. 175 operations available: 130 refactor, 15 query, 30 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

15Query
130Refactor
30Analysis

Query

OperationDescription
callersFind every call site of a function or method across the codebase. Use to understand who depends on a function before changing its signature. Requires LSP. Params: symbol (string) [, file (string)]
control_flowGet a function's control flow — branches, loops, early returns, and basic blocks in execution order. Use to understand complex logic without reading the full implementation. Params: target (string), file (string)
definitionJump to definition — find where a symbol is defined given a usage location. Uses abstract syntax trees by default, no LSP required. Params: symbol (string), file (string), line (u32), column (u32)
diagnosticsGet compiler errors and warnings from the language server. Omit `file` for workspace-wide diagnostics. Pass a file path or directory path to scope results. Requires LSP.
fix_autoAuto-fix all deterministic issues in a file, directory, or workspace — missing imports, unused imports, simple type errors. Runs multiple fix-revalidate cycles. Use after making changes to clean up automatically. Requires LSP. Params: none [, file (string), workspace_mode (bool), category (string), commit (bool), max_rounds (u32)]
get_typeGet the compiler-inferred type of any expression at a position. Use to understand types without reading surrounding code. Requires LSP. Params: file (string), line (u32), column (u32)
graphBuild a dependency graph from a file — trace what it imports and what imports it, across multiple hops. Use to understand module relationships and change impact before refactoring. Params: file (string) [, depth (u32), direction (string), leaves (bool), order (string)]
import_organizeOrganize, sort, and deduplicate imports in a file. Removes unused imports. Use after adding new code or moving symbols to clean up import blocks automatically. Params: file (string) [, preview (bool)]
interfaceGet a symbol's public API — signatures, types, and docstrings without implementation bodies. Like skeleton but for a single symbol. Use to understand how to call something without reading its internals. Params: target (string), file (string) [, include_private (bool)]
mutationsIdentify side effects — what external state a function reads or writes (globals, file I/O, network, etc.). Use to understand if a function is pure or has hidden dependencies. Params: target (string), file (string)
referencesFind every usage of a symbol across the entire codebase — all files, not just the current one. Use before renaming, refactoring, or deleting to understand full impact. Requires LSP. Params: symbol (string), file (string)
repo_outlineGet a compressed overview of the entire repository in one call — file tree with languages, line counts, and optionally symbol names per file. Orders of magnitude cheaper than listing directories and reading files individually. Params: none [, path (string), depth (u32), include (glob), exclude (glob), symbols (bool), max_files (u32), relative (bool)]
skeletonGet a file's structure — function signatures, class declarations, type definitions — without implementation bodies. Use INSTEAD of reading the full file to understand its API. Typically 5-10x fewer tokens than reading the raw file. Params: file (string)
symbolsList all symbols (functions, classes, variables, types, constants) defined in a file with their locations and kinds. Use INSTEAD of reading a file when you need to know what's defined in it. Much cheaper than reading the full file. IMPORTANT: file must be a path to a single source file — never a directory or empty string. Params: file (string)
symbols_batchRetrieve symbols from multiple files in a single call. Use instead of calling symbols() in a loop — one request instead of N. Params: none [, files (string[]), ids (string[]), kinds (string[])] — provide files or ids

Refactor

OperationDescription
add-attr-accessorCreate explicit attr_accessor from getter+setter
add-attr-class-variableAdd @@var class variable
add-attr-readerCreate explicit attr_reader from getter method
add-attr-writerCreate explicit attr_writer from setter method
add-ensure-clauseAdd ensure block for cleanup
add-namespaceWrap code in module Namespace; end
add-raise-statementAdd explicit raise for error condition
add-self-parameterExplicit self in class method definition
add-type-commentAdd @type [Type] comment for static analysis
change-visibilityChange method access level (private/protected/public)
convert-block-to-lambdaConvert block to lambda declaration
convert-block-to-procConvert block to &:method_name syntax
convert-braces-to-do-endConvert { } block to do...end
convert-case-to-ifConvert case statement to if/elsif
convert-class-to-moduleConvert class to module (if no constructor)
convert-do-end-to-bracesConvert do...end block to { }
convert-double-to-single-quotesDouble quote to single quote literals
convert-each-to-forConvert .each to for loop
convert-exception-to-specific-typeMake rescue catch specific exception type
convert-for-to-eachConvert for loop to .each iteration
convert-for-to-whileConvert for loop to while
convert-heredoc-to-stringConvert heredoc back to string literal
convert-if-elseConvert between if-else patterns
convert-if-to-caseConvert multiple elsif to case
convert-if-to-unlessConvert if !x to unless x
convert-lambda-to-blockConvert lambda to block when passed to method
convert-loop-to-breakConvert loop to conditional iteration
convert-method-body-to-one-linerCollapse multi-line method to single line
convert-method-to-propertyConvert accessor method to attr_accessor
convert-modifier-ifConvert if modifier to block form
convert-module-to-classConvert module to class
convert-one-liner-to-method-bodyExpand one-liner to multi-line
convert-percent-literal-to-stringConvert %w() word array to string literal
convert-proc-to-blockConvert proc parameter to explicit block
convert-property-to-methodConvert attr_accessor to explicit getter/setter
convert-require-relative-to-requireConvert require_relative to require
convert-require-to-require-relativeConvert require to require_relative
convert-rescue-to-rescue-in-methodExtract rescue to method-level
convert-single-to-double-quotesSingle quote to double quote literals
convert-singleton-to-class-methodConvert singleton method to class method definition
convert-string-to-symbolConvert string to symbol for hash keys
convert-symbol-to-stringConvert symbol to string literal
convert-ternaryConvert ternary expressions and conditionals
convert-to-guard-clauseExtract common condition to guard at method start
convert-to-heredocConvert string to heredoc for multiline
convert-to-rbs-signatureConvert method to RBS type signature format
convert-to-safe-navigationConvert if check to safe navigation operator (&.)
convert-to-string-interpolationConvert string concatenation to interpolation
convert-unless-to-ifConvert unless x to if !x
convert-while-to-forConvert while loop to for
copy-methodDuplicate method declaration
deleteDelete unused symbol
extract-block-parameterName unnamed block parameters
extract-constantExtract value to named constant
extract-methodExtract code into a new method
extract-variableExtract expression to variable
extract_functionExtract a code selection into a new function — automatically infers parameters, return types, and inserts the call site. Use instead of manually cutting/pasting code. Works without LSP; LSP improves type inference. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool)]
extract_variableExtract an expression into a named variable — inserts the declaration and replaces the expression with the variable name. Works without LSP. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool)]
generate-accessorsGenerate attr_reader, attr_writer, attr_accessor
generate-classGenerate new class skeleton
generate-class-methods-blockGenerate class << self section
generate-cloneGenerate clone (deep copy)
generate-comparable-implementationGenerate <=> for sorting
generate-constructorGenerate initialize method from class variables
generate-custom-exceptionGenerate custom exception class
generate-debug-printAdd debug output statement
generate-define-methodGenerate define_method for dynamic methods
generate-dupGenerate dup (shallow copy)
generate-enum-like-classGenerate class with enum-like constants
generate-enumerable-delegationGenerate include Enumerable with iteration
generate-equalsGenerate ==, !=, eql? implementations
generate-example-usageGenerate usage examples in comments
generate-fixture-methodGenerate test fixture setup
generate-getter-methodGenerate a getter method for an instance variable
generate-guard-statementsGenerate nil/type guards at method start
generate-hashGenerate hash for use in collections
generate-initialize-from-attributesGenerate initialize accepting attribute hashes
generate-inspectGenerate inspect method
generate-keyword-initializeGenerate keyword argument initialize(**kwargs)
generate-method-missingGenerate method_missing handler
generate-method-signature-docGenerate method signature documentation
generate-mixinGenerate module for inclusion as mixin
generate-mock-objectGenerate mock/stub object for testing
generate-moduleGenerate module with namespace
generate-precondition-checksGenerate argument validation
generate-rdoc-commentGenerate RDoc documentation skeleton
generate-respond-to-missingGenerate respond_to_missing?
generate-setter-methodGenerate a setter method for an instance variable
generate-singleton-classGenerate singleton methods for object
generate-subclassGenerate subclass extending parent
generate-testsGenerate test method skeleton
generate-to-hGenerate to_h for hash conversion
generate-to-stringGenerate to_s string representation
generate-todo-commentGenerate TODO/FIXME placeholder
generate-validation-methodGenerate method for parameter validation
generate-with-index-iterationGenerate each_with_index method
import-addAdd require statement
import-organizeOrganize and sort requires
import-removeRemove unused require statement
inlineInline a variable, function, or method — replace every usage with its definition body, then remove the original. The inverse of extract. Works without LSP (single-file); LSP enables cross-file inlining. Params: file (string), symbol (string) [, line (u32), preview (bool)]
inline-methodInline method body at call sites
inline-variableInline variable at all references
insert_bodyReplace a function's implementation body with new code. AST-validated — rejects if the result has parse errors, so you can't accidentally break syntax. Use instead of manual text editing for function rewrites. Params: file (string), symbol (string), code (string) [, commit (bool)]
introduce-variableExtract expression to local variable
invert-if-elseSwap if and else branches, negate condition
join-string-literalsConcatenate adjacent string literals
make-method-instanceConvert class method to instance method
make-method-staticConvert instance method to class method
merge-nested-ifMerge nested if conditions into compound condition
merge-rescue-clausesCombine multiple rescue handlers
moveMove method to another class/module
move_symbolMove a function, class, or type to a different file and automatically update all imports across the codebase. Use instead of manually cut/paste + fixing imports. Works without LSP (single-file); LSP enables cross-file import updates. Params: file (string), symbol (string), destination (string) [, preview (bool)]
remove-attr-class-variableConvert class variable to instance variable
remove-empty-elseRemove empty else clause
remove-empty-rescueRemove rescue clause that does nothing
remove-redundant-requireRemove duplicate or unnecessary require
remove-safe-navigationConvert &.method to .method when safe
remove-self-parameterRemove explicit self when not needed
remove-type-commentRemove type comment annotation
remove-unnecessary-blockRemove block when method doesn't use it
renameRename a symbol and automatically update ALL references across the codebase. Safer and faster than find-and-replace — AST-aware, won't rename strings or comments. Works without LSP (single-file); LSP enables cross-file renames. Params: file (string), old_name (string), new_name (string) [, line (u32), column (u32), preview (bool)]
renameRename symbol and all references
simplify-boolean-assignmentSimplify x = x || y to x ||= y
sort-method-declarationsSort methods by visibility (private/public)
split-if-conditionSplit compound if into nested if
split-string-literalSplit long string into multiple parts
swap-statementsReorder two adjacent statements
wrap-in-begin-rescueWrap statement in exception handler
wrap-null-checkWrap expression in nil check guard
wrap-try-catchWrap code in begin...rescue...end block

Analysis

OperationDescription
analyze_chokepointsFind files that act as critical bottlenecks — high betweenness centrality in the dependency graph (R4). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_clustersIdentify tightly coupled groups of files using community detection. Use to discover natural module boundaries and understand which files change together. Params: none [, granularity (string), min_size (u32), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_cohesionMeasure intra-module cohesion for each file — ratio of internal to total symbol edges (H2). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_couplingMeasure coupling per file — how many files depend on it (afferent) vs how many it depends on (efferent), plus instability and abstractness scores. Use to find the most critical/fragile files. Params: none [, granularity (string), sort (string), threshold (f64), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_cycle_riskScore each circular dependency cycle by its external risk surface (R6 circular risk zones analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_cyclesFind circular dependency chains in the codebase. Use to identify import cycles that cause build issues or indicate architecture problems. Params: none [, granularity (string), max_length (u32), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_dead_codeFind dead code — functions, classes, and types that are never referenced from any entry point. Use before cleanup to safely identify what can be deleted. Params: none [, entry (string[]), granularity (string), include_tests (bool), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_depthCompute longest transitive dependency chain per file (S4 dependency depth analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_entry_pointsDetect entry points: main functions, HTTP routes, CLI commands, event listeners, test files (S5). Params: none [, include (string[]), exclude (string[])].
analyze_exportExport the full semantic graph (files, symbols, dependencies) in JSON, DOT (Graphviz), or CSV format. Use for visualization or external analysis. Params: none [, format (string), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_extractionScore clusters for service or package extraction viability (M2 extraction candidates analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_fan_balanceCompute fan-in/fan-out imbalance for migration ordering guidance (M6 fan balance analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_featuresInventory language-specific AST features used in the codebase — async, generics, decorators, etc. (M3). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_hotspotsRank files by composite complexity score — max cyclomatic complexity, statement count, nesting depth (H1). Params: none [, top_n (u32), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_impactCompute change impact for a target file — finds all files directly and transitively depending on it (R1). Params: target (string) [, max_depth (u32), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_inconsistenciesDetect inconsistent abstractions — sibling files in the same directory that diverge from the group's structural pattern (H5). Params: none [, include (string[]), exclude (string[])].
analyze_inheritanceDetect tangled inheritance — deep hierarchies (>N levels) and diamond inheritance (H6). Params: none [, include (string[]), exclude (string[])].
analyze_interface_bloatDetect interface bloat — files where the public API is disproportionately large relative to implementation (H3). Params: none [, include (string[]), exclude (string[])].
analyze_interfacesMap cross-module interfaces — symbols that cross directory-module boundaries, ranked by interface width (M4). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_layersDetect architectural layers from directory names and find dependency direction violations (S1+S2). Params: none [, detect_only (bool), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_orphan_typesFind type definitions used exclusively outside their defining directory (H4 orphan types analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_patternsFind code smells — god functions, deep nesting, high coupling, and other structural issues. Use to identify refactoring targets or assess code quality. Params: none [, tier (string), pattern (string), file (string), severity (string), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_platform_depsDetect platform-specific API usage by scanning imports (M5 platform dependencies analysis). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_readinessCompute migration readiness scores per file — composite of complexity, coupling, porting blockers (M1). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_rolesClassify files by architectural role: entry point, routing, business logic, data access, config, test, utility, types, generated (S3). Params: none [, include (string[]), exclude (string[])].
analyze_seamsFind the natural boundaries between file clusters — the narrowest points where groups of files communicate. Use to identify where to split modules or add API boundaries. Params: none [, min_cluster_size (u32), max_seam_width (u32), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_stabilityCompute stability index (R2) and detect stable dependency violations (R3) — flags edges where stable modules depend on unstable ones. Params: none [, index_only (bool), include (string[]), exclude (string[])].
analyze_surfaceMeasure API surface area — count exposed functions, types, and complexity at a module boundary. Use to assess whether an API is too large or leaky. Params: none [, boundary (string), files (string), include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_test_gapsDetect source files with no or partial test coverage based on graph import analysis (R5). Params: none [, include (string[]), exclude (string[])]. Use include/exclude to restrict the scan scope (e.g. include=["crates"], exclude=["corpus"]).
analyze_type_completenessAnalyze type boundary completeness — detect 'any' types, untyped parameters, missing return types at exported function boundaries (M7). Params: none [, include (string[]), exclude (string[])].
← Robot FrameworkRust →