add_top_level
Add a function, class, or constant at a file's top level—after the preamble or at the end inside include guards—with correct indentation and spacing.
Instructions
Add top-level code (a function, class, constant or other statement) to a source file. "bottom" appends it at the end, inside a header's include guard; "top" puts it after the preamble, before the first declaration. It is set apart by a blank line, two around a Python def or class, but one-line code added at the bottom under stacked one-line code is stacked too. In Go, or a file indented with tabs, its indentation becomes tabs.
Use this when: adding a top-level symbol or statement. Don't use this when: placing it next to a symbol (insert_sibling), in a class (add_method, add_field), in a body (insert_in_body) or in a config file (add_key).
Example: content="MAX_CONNECTIONS = 10" position="top"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Top-level code, inserted as written; read_symbol's text of a nested symbol is moved to column 0 as a whole. | |
| position | No | 'bottom' (default) at the end of the file; 'top' after the preamble (package clause, `#!` and magic comments, module docstring, directives such as 'use strict', imports and includes). Other values are refused. | bottom |
| file_path | Yes | Absolute path to the source or config file. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |