Zig — 143 Operations for AI Agents

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Zig code through the act MCP server. 143 operations available: 69 refactor, 18 query, 42 analysis, 14 verification. 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.

18Query
69Refactor
42Analysis
14Verify

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

Refactor

Operation Description
add-allocator-parameter Add allocator: std.mem.Allocator parameter to function
add-catch-handler Add catch error handler
add-const-qualifier Mark variable or parameter as const
add-defer Add defer statement
add-doc-comment Add doc comment to declaration
add-errdefer Add errdefer statement
add-error-return Add error return type
add-error-union Wrap return type with error union
add-explicit-type Add explicit type annotation to variable
add-function-parameter Insert new parameter to function
add-import Insert module import at file top
add-module-comment Add module-level doc comment
add-null-guard Wrap expression in null check or optional chaining
add-parameter-docs Add documentation for function parameters
add-todo-comment Add TODO comment
change-function-return-type Modify function return type annotation
change-parameter-type Modify parameter type annotation
change-visibility Modify function/struct visibility
consolidate-imports Merge duplicate module imports
convert-catch-to-try Convert catch to try expression
convert-defer-to-errdefer Convert defer to errdefer
convert-loop-to-inline Convert loop to inline loop
convert-loop-to-while Convert for loop to while loop
convert-optional-unwrap Convert optional access to unwrap with .?
convert-string-literal Convert between string literal types
convert-to-comptime Convert to comptime expression
convert-to-doc-comment Convert regular comment to doc comment
convert-to-packed Convert struct to packed struct
convert-while-to-for Convert while loop to for loop
extract-function Extract code into a new function
extract-variable Extract expression to variable
extract_function Extract 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), receipt (bool)]
extract_variable Extract 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-enum Generate tagged union enum
generate-equality-operator Generate equality comparison function for struct
generate-field-accessor Create getter function for struct field
generate-field-setter Create setter function for struct field
generate-function Generate stub function
generate-init-function Create constructor-like initialization function
generate-main Scaffold main function entry point
generate-string-representation Create string conversion function
generate-struct Generate struct definition
generate-switch-cases Generate exhaustive switch cases for union
generate-test-function Create unit test stub
generate-union-variant Add variant to tagged union
import-add Add an @import binding
inline Inline 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), receipt (bool)]
inline-function Inline a function call, replacing with function body
inline-variable Inline a local variable by replacing with its value
insert_body Replace 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)]
invert-conditional-expression Swap ternary branches and negate condition
invert-if Swap if/else branches and negate condition
make-parameter-comptime Make function parameter comptime
move-function-definition Relocate function to different position
move_symbol Move 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), receipt (bool)]
organize-imports Sort and group imports
recipe_run Run a codemod recipe: declarative match → transform → optional verify across modeled grammars. Preview lists matches; apply writes with optional E7 receipts and all-or-nothing rollback. Returns a per-site report.
remove-comment Remove comment
remove-const-qualifier Remove const from variable
remove-function-parameter Delete parameter from function
remove-import Delete unused module import
remove-type-annotation Remove explicit type annotation
remove-unused-parameter Remove unused function parameter
remove-unused-variable Remove unused local variable declaration
rename Rename 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), receipt (bool)]
rename Rename symbol and all references
rename-struct-field Rename struct member and update references
swap-function-parameters Reorder function parameters
unwrap-with-default Unwrap optional with default value

Analysis

42 analysis tools, the same on every supported language. Descriptions live in the shared reference: /docs/analysis-tools.

analyze_api_diff analyze_chokepoints analyze_clones analyze_clusters analyze_cohesion analyze_conformance analyze_coupling analyze_cycle_risk analyze_cycles analyze_dead_code analyze_depth analyze_entry_points analyze_export analyze_extraction analyze_fan_balance analyze_features analyze_hotspots analyze_impact analyze_inconsistencies analyze_inheritance analyze_interface_bloat analyze_interfaces analyze_layers analyze_orphan_types analyze_patterns analyze_platform_deps analyze_readiness analyze_roles analyze_seams analyze_stability analyze_surface analyze_test_gaps analyze_thickness analyze_type_completeness churn_hotspots co_change_clusters coverage_overlay ownership_map profile_overlay simulate split_module trace_overlay

Verify

14 verify tools, the same on every supported language. Descriptions live in the shared reference: /docs/verification.

bisect_regression gate generate_test_harness scan secret_surface summarize_pr taint_flow unsafe_surface verify_behavioral_equivalence verify_contract_preserved verify_diff_semantics verify_port_parity verify_side_effects verify_test_impact

← YANGZsh →