add_method
Add a method to the end of an existing class body, matching the class's member spacing and access rules. Use it for class methods, not fields or top-level functions.
Instructions
Add a method at the end of a class body, after its last member, spaced like the class's methods. In Go it goes after the type declaration. In a C++ class whose last method is followed by an access label, it goes right after that method, so it gets the same access. A one-line Python or Ruby class is refused, and so is a function target (use insert_in_body).
Use this when: adding a method to an existing class. Don't use this when: adding a field (add_field) or a top-level function (add_top_level).
Example: class_target="LRUCache" content='def clear(self):\n self.items.clear()'
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>",
"class_target": "<class_target>",
"content": "<content>"
},
"name": "add_method"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Complete method source, re-indented like the class's members, keeping its own relative indentation. | |
| file_path | Yes | Absolute path to the source or config file. | |
| class_target | Yes | Class name as list_symbols lists it (a struct, interface or Go struct type too), dotted for nesting ('A.B'). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |