add_top_level
Append top-level code like functions, classes, or constants to the end of a file using AST-based editing for precise modifications.
Instructions
Append arbitrary top-level content to the end of the file: a function, class, constant, type alias, or any other top-level statement.
Use this when: You're adding any kind of top-level code at the end of a module.
Don't use this when: You need placement relative to another symbol -> use
insert_before/insert_after. You're adding to a class body -> use
add_method/add_field. You're adding a line inside an existing function
body -> use prepend_to_body/append_to_body.
Example: content="def parse_version(text):\n return tuple(int(x) for x in text.split('.'))" content="class Logger:\n pass" content="MAX_CONNECTIONS = 10"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| content | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |