Clarity — 143 Operations for AI Agents
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Clarity 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.
Premium language. Operations on Clarity require an Elite license or above. See pricing.
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-contract-caller-check |
Add contract-caller authorization guard |
add-overflow-check |
Add overflow guard before arithmetic |
add-parameter-to-private-function |
Add parameter to private function |
add-principal-check |
Add tx-sender authorization guard |
add-response-check |
Wrap call in (try! ...) for error propagation |
add-stx-transfer-guard |
Add balance check before STX transfer |
convert-err-value-to-response |
Wrap value in (err ...) for response type |
convert-if-to-match |
Convert if to match for response/optional |
convert-integer-to-uint |
Convert signed int to unsigned uint |
convert-is-ok-to-match |
Convert is-ok check to match |
convert-is-some-to-match |
Convert is-some check to match |
convert-match-to-if |
Convert match to if when simple |
convert-ok-unwrap-to-try |
Replace unwrap! pattern with try! macro |
convert-ok-value-to-response |
Wrap value in (ok ...) for response type |
convert-string-to-ascii |
Convert string-utf8 literal to string-ascii |
convert-unwrap-err-panic-to-match |
Replace unwrap-err-panic with match |
convert-unwrap-panic-to-unwrap |
Replace unwrap-panic with unwrap! |
demote-to-private-function |
Change public function to private |
extract-access-control-guard |
Extract repeated asserts into private function |
extract-constant |
Extract literal into named constant |
extract-filter-predicate |
Extract filter predicate into function |
extract-let-binding |
Extract an expression into a let binding |
extract-private-function |
Extract code block into private function |
extract-read-only-function |
Extract pure code into read-only function |
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-access-control-map |
Generate access control map with helpers |
generate-clarity-doc-comment |
Generate documentation comment |
generate-contract-call-wrapper |
Generate contract-call wrapper function |
generate-define-constant |
Generate define-constant declaration |
generate-define-data-var |
Generate define-data-var declaration |
generate-define-fungible-token |
Generate define-fungible-token declaration |
generate-define-map |
Generate define-map declaration |
generate-define-non-fungible-token |
Generate define-non-fungible-token declaration |
generate-define-private-stub |
Generate private function stub |
generate-define-public-stub |
Generate public function stub |
generate-define-read-only-stub |
Generate read-only function stub |
generate-error-constants |
Generate block of error constant definitions |
generate-ft-mint-public |
Generate public FT mint function |
generate-ft-token-scaffold |
Generate full SIP-010 FT token scaffold |
generate-impl-trait |
Generate impl-trait declaration |
generate-nft-collection-scaffold |
Generate full SIP-009 NFT collection scaffold |
generate-nft-mint-public |
Generate public NFT mint function |
generate-owner-only-guard |
Generate owner constant and guard function |
generate-sip009-get-owner |
Generate SIP-009 get-owner function |
generate-sip009-transfer |
Generate SIP-009 transfer function |
generate-sip010-get-balance |
Generate SIP-010 get-balance function |
generate-sip010-get-total-supply |
Generate SIP-010 get-total-supply function |
generate-sip010-transfer |
Generate SIP-010 transfer function |
generate-stx-transfer-public |
Generate public STX transfer function |
generate-trait-definition |
Generate trait definition skeleton |
generate-use-trait |
Generate use-trait import |
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-constant |
Replace constant with its value |
inline-let-binding |
Inline a let binding into all uses |
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-boolean-condition |
Negate if condition and swap branches |
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)] |
normalize-error-constants |
Replace inline error literals with named constants |
promote-to-public-function |
Change private function to public |
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. |
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-identifier |
Rename an identifier across all references |
rename-map-key-tuple-field |
Rename field in map tuple definition and usages |
reorder-function-parameters |
Reorder parameters of a function |
rewrite-fold-as-map |
Convert fold to map when appropriate |
rewrite-map-as-fold |
Convert map to fold when needed |
simplify-boolean-expression |
Simplify boolean expressions (double negation, constants) |
unwrap-option-to-default |
Replace default-to with direct expression |
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