Skip to main content
Glama

AHK_File_Edit

Destructive

Edit AutoHotkey files directly to perform search/replace, insert lines, create new scripts, or delete content with regex support and preview options.

Instructions

Primary AutoHotkey file editor for direct on-disk modifications. Handles search/replace, line inserts, deletes, appends, prepends, and even new file creation. Supports regex, automatic backups, dry-run previews, and optional script execution after edits.

Common Usage

{
  "action": "replace",
  "search": "oldClassName",
  "newContent": "NewClassName",
  "filePath": "C:\\Scripts\\MyAutomation.ahk"
}

Batch Replace with Regex (Preview First)

{
  "action": "replace",
  "search": "class\\s+(\\w+)",
  "newContent": "class Refactored$1",
  "regex": true,
  "all": true,
  "dryRun": true
}

Shows a DRY RUN report instead of touching the file.

Create New Script

{
  "action": "create",
  "filePath": "C:\\AHK\\Helpers\\ClipboardTools.ahk",
  "newContent": "class ClipboardTools {\n    __New() {\n        ; init\n    }\n}"
}

What to Avoid

  • Using deprecated "content" parameter - migrate to "newContent"

  • Running batch replacements without dryRun: true first

  • Disabling backups on production files unless absolutely necessary

See also: AHK_File_Edit_Advanced, AHK_File_Edit_Small, AHK_File_View, AHK_Smart_Orchestrator

šŸ“Ž Active File: Not set. Use AHK_File_Active to select a target.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoEdit action to performreplace
searchNoText to search for (for replace/delete)
newContentNoPreferred parameter containing the replacement or inserted text (e.g., "MsgBox(\"Updated\")").
contentNoāš ļø Deprecated alias for newContent. Will be removed in a future release.
lineNoLine number for insert/delete (1-based)
startLineNoStart line for range operations
endLineNoEnd line for range operations
filePathNoFile to edit (defaults to activeFilePath)
regexNoUse regex for search
allNoReplace all occurrences
backupNoCreate backup before editing
runAfterNoRun the script after the edit completes successfully
dryRunNoPreview changes without modifying file. Shows affected lines and change count.
validateNoValidate AHK code before writing. Blocks edit if syntax errors are found.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds significant behavioral context beyond the annotations. While annotations indicate destructiveHint=true (mutation), the description elaborates with features like automatic backups, dry-run previews, optional script execution after edits, and validation of AHK code before writing. It also mentions that the tool defaults to active file path if not specified, providing practical implementation details not covered by annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (primary description, common usage examples, what to avoid, see also references, and active file note). While comprehensive, it remains focused with no redundant sentences - every part serves a purpose in guiding tool usage. The examples are illustrative rather than verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 14 parameters, destructive operations, and no output schema, the description provides excellent context. It covers operational scope, safety features (backups, dry runs, validation), parameter guidance, sibling relationships, and practical implementation details. The combination of structured guidance and examples makes it complete enough for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3, but the description adds substantial value through usage examples that demonstrate parameter combinations and semantics. The JSON examples show how parameters like action, search, newContent, regex, all, and dryRun work together in real scenarios, providing context that goes beyond the schema's individual parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Primary AutoHotkey file editor for direct on-disk modifications' and lists specific operations like search/replace, line inserts, deletes, appends, prepends, and new file creation. It distinguishes from siblings by explicitly mentioning AHK_File_Edit_Advanced, AHK_File_Edit_Small, AHK_File_View, and AHK_Smart_Orchestrator, establishing this as the main editing tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance with a 'What to Avoid' section warning against deprecated parameters, batch replacements without dry runs, and disabling backups on production files. It also includes 'See also:' references to sibling tools, helping the agent understand when to use alternatives like AHK_File_Edit_Advanced or AHK_File_View instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TrueCrimeDev/ahk-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server