HTML — 103 Operations for AI Agents

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze HTML code through the act MCP server. 103 operations available: 29 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
29Refactor
42Analysis
14Verify

Worked HTML examples

act101 edits HTML using the element tree the tree-sitter grammar exposes, so an edit targets a specific tag or attribute rather than a raw line offset. It can add the lang attribute to the root <html> element, which assistive technology and search engines both read. And it can reorder an element's attributes into a conventional order — type and name ahead of the rest on a form control, class ahead of href on a link — without altering a single name or value. Each example below is the verbatim output of the command shown, run against the file shown.

Declare the document language on the html element

page.html is a complete document skeleton whose root <html> element carries no lang attribute, so nothing states what language the content is in.

$ act refactor-lang add_lang_attribute --file page.html --params '{"language":"de","line":1,"column":1}'

Before

<html><head></head><body><p>Inhalt</p></body></html>

After

<html lang="de"><head></head><body><p>Inhalt</p></body></html>

lang="de" is added to the root <html> tag; the <head> and <body> are unchanged.

Reorder the attributes on a form control

field.html is a single <input> whose attributes are written in an arbitrary order, with value ahead of type and name.

$ act refactor-lang reorder_attributes --file field.html --params '{"element":"element","line":1,"column":1}'

Before

<input value="default" type="text" name="username" placeholder="Enter name" />

After

<input type="text" name="username" placeholder="Enter name" value="default" />

type and name move to the front and value to the back; every attribute name and value is preserved exactly.

Reorder the attributes on a link

link.html is a single <a> element whose class trails its href and title.

$ act refactor-lang reorder_attributes --file link.html --params '{"element":"element","line":1,"column":1}'

Before

<a href="https://example.com" title="Example" class="external">Link</a>

After

<a class="external" href="https://example.com" title="Example">Link</a>

class moves ahead of href and title; the link text and every attribute value are untouched.

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_alt_text Add or update alt attribute on img elements
add_aria_attributes Add ARIA attributes for accessibility
add_attribute Add an attribute to an element or set of elements
add_closing_tag Add missing closing tag for unclosed element
add_lang_attribute Add or update lang attribute on html element
add_meta_charset Add or update charset meta tag
add_viewport_meta Add or update viewport meta tag for responsive design
convert_element_type Convert one element type to another
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_to_file Extract selected HTML snippet to a separate file
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)]
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)]
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)]
move_element Move an element to a different location in the DOM
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)]
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_attribute Remove a specific attribute from one or all elements
remove_deprecated_attribute Remove deprecated HTML attributes
remove_element Remove an element and optionally preserve its content
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_attribute Rename an HTML attribute across all elements
rename_class Rename a CSS class across all elements and attributes
rename_element Rename an HTML element tag across all occurrences
rename_id Rename an ID across all elements and references
reorder_attributes Reorder attributes on an element
replace_deprecated_element Replace deprecated HTML element with modern equivalent
sort_attributes Sort element attributes alphabetically or by importance
unwrap_element Remove element wrapper, preserving content and attributes
wrap_selection Wrap selected content in a specified element

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

← HOCONINI →