Pascal — 127 Operations for AI Agents
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze Pascal code through the act MCP server. 127 operations available: 53 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.
Worked Pascal examples
act101 parses Pascal with the tree-sitter grammar and edits conditional statements, loop constructs, and literal expressions as syntax nodes, so a control-flow or extraction change lands on the exact declaration or statement it targets. It can invert an if/else statement, negating the condition and swapping the branches. It can convert a repeat...until loop into a while True do loop with an inverted-condition Break, preserving the original's run-at-least-once semantics. And it can extract a literal used in a statement into a const declaration, substituting the constant name at the use site. Each example below is the verbatim output of the command shown, run against the file shown.
Invert an if-else statement
sign.pas's if x > 0 then branch prints 'Positive' and its else branch prints 'Non-positive'.
$ act refactor-lang invert_conditional_pascal --file sign.pas --params '{"line":4,"column":1}'
Before
program Test;
begin
if x > 0 then
WriteLn('Positive')
else
WriteLn('Non-positive');
end.
After
program Test;
begin
if not (x > 0) then
WriteLn('Non-positive')
else
WriteLn('Positive');
end.
The condition becomes if not (x > 0) and the branches swap: 'Non-positive' now runs on the taken branch.
Convert a repeat-until loop to while-true
count.pas counts with a repeat ... until i > 10; loop.
$ act refactor-lang convert_repeat_until_to_while_pascal --file count.pas --params '{"line":8,"column":1}'
Before
program Test;
var
i: Integer;
begin
i := 1;
repeat
WriteLn(i);
i := i + 1;
until i > 10;
end.
After
program Test;
var
i: Integer;
begin
i := 1;
while True do
begin
WriteLn(i);
i := i + 1;
if i > 10 then
Break;
end;
end.
The loop becomes while True do begin ... end;, with the original until condition now guarding a Break inside the body.
Extract a string literal into a constant
greet.pas's Greet procedure calls WriteLn with the literal 'Welcome to Pascal Programming'.
$ act refactor-lang extract_constant_pascal --file greet.pas --params '{"constant_name":"DEFAULT_MESSAGE","line":5,"column":11}'
Before
program Test;
procedure Greet;
begin
WriteLn('Welcome to Pascal Programming');
end;
begin
Greet;
end.
After
program Test;
const
DEFAULT_MESSAGE = 'Welcome to Pascal Programming';
procedure Greet;
begin
WriteLn(DEFAULT_MESSAGE);
end;
begin
Greet;
end.
A const DEFAULT_MESSAGE = 'Welcome to Pascal Programming'; declaration is added before Greet, and the call site becomes WriteLn(DEFAULT_MESSAGE).
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-missing-begin-end |
Add begin/end where required by Pascal syntax |
add-parentheses |
Add explicit parentheses around sub-expression in complex condition |
add-property-accessors |
Add getter/setter procedures for Object Pascal property |
add-unit-to-uses |
Add required unit to uses clause |
change-parameter-passing |
Convert value parameter to var (by-reference) or const |
change-visibility |
Change visibility of procedure/function (Public/Private/Protected/Published) |
convert-case-to-if |
Convert case statement to if/else-if chain |
convert-for-to-while |
Convert for loop to while loop |
convert-function-to-procedure |
Convert function to procedure with out parameter |
convert-if-to-case |
Convert chain of if/else-if to case statement |
convert-procedure-to-function |
Convert procedure to function with return value |
convert-repeat-until-to-while |
Convert repeat-until loop to while loop |
convert-string-concatenation |
Convert multiple + operators to single concat or format call |
convert-to-begin-end-block |
Add begin/end block around statement |
convert-while-to-for |
Convert while loop to for loop |
extract-constant |
Extract literal value into a named constant with type inference |
extract-function |
Extract code block into a new named function with parameter inference |
extract-procedure |
Extract code block into a new named procedure with parameter inference |
extract-variable |
Extract expression into a named variable with type inference |
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-constructor |
Generate constructor procedure (Create) for record or class |
generate-destructor |
Generate destructor procedure for class |
generate-equality-comparison |
Generate function to compare two instances for equality |
generate-getter |
Generate getter procedure for field |
generate-implementation-stub |
Generate implementation procedure body stub |
generate-interface-type |
Generate interface type declaration for Object Pascal |
generate-setter |
Generate setter procedure for field |
generate-string-representation |
Generate ToString or AsString function for type |
generate-test-procedure |
Generate test procedure template |
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 |
Inline constant value at all use sites |
inline-function |
Inline function call into body at all use sites |
inline-procedure |
Inline procedure call into body at all use sites |
inline-variable |
Inline variable at all use sites, removing the declaration |
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)] |
introduce-constant-for-magic |
Replace magic number/literal with a named constant declaration |
invert-conditional |
Invert if condition and swap then/else blocks |
move-declaration |
Move variable/constant declaration to different scope |
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-uses |
Sort units in uses clause alphabetically |
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-begin-end-block |
Remove unnecessary begin/end block |
remove-unnecessary-assignment |
Remove self-assignments (x := x) |
remove-unnecessary-parentheses |
Remove redundant parentheses from expression |
remove-unused-unit |
Remove unused unit from uses clause |
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 variable, function, procedure, or type across all references |
simplify-boolean-expression |
Remove redundant boolean comparisons (if x = true then -> if x then) |
simplify-null-check |
Remove unnecessary nil checks in comparisons |
sort-uses-clause |
Alphabetically sort unit names in uses clause |
uses-alias |
Add or change unit alias in uses clause |
wrap-in-block |
Wrap statements in begin/end block |
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