Skip to main content
Glama

insert_before

Insert code as a sibling before a named symbol like functions or classes in AST-based files. Use for precise placement when adding helpers before callers or constants above dependent code.

Instructions

Insert content as a sibling immediately before a named symbol (function, class, method, or top-level assignment).

Use this when: You need precise placement relative to another symbol (e.g. inserting a helper function just before its caller, or a constant above a class that uses it). Don't use this when: You just want to append to the end of the file -> use add_top_level.

Example: target="LRUCache" content="CACHE_SIZE = 100"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
targetYes
contentYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

No annotations are provided, so the description carries full burden. It describes the core behavior (inserting before a named symbol) and gives an example, but lacks details on error handling (e.g., if target doesn't exist), file modification effects, or permissions needed. It adds some context but not comprehensive behavioral disclosure.

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

Conciseness5/5

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

The description is front-loaded with the core purpose, followed by usage guidelines and an example. Every sentence adds value: the first defines the tool, the next two provide when/when-not guidance, and the example illustrates parameters. No wasted words.

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

Completeness4/5

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

Given 3 parameters with 0% schema coverage and no annotations, the description does well by explaining purpose, usage, and providing an example. An output schema exists, so return values needn't be described. However, it could better address error cases or file system implications for a mutation tool.

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?

Schema description coverage is 0%, so the description must compensate. It explains 'target' as a named symbol (function, class, method, or top-level assignment) and 'content' as what to insert, with an example showing usage. However, it doesn't clarify 'file_path' semantics or parameter constraints beyond the example, leaving some gaps.

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 action ('Insert content as a sibling immediately before a named symbol') and specifies the resource types (function, class, method, or top-level assignment). It distinguishes from sibling 'add_top_level' by emphasizing precise placement relative to another symbol rather than appending to the end of the file.

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 explicitly provides 'Use this when' guidance with concrete examples (e.g., inserting a helper function just before its caller) and 'Don't use this when' with a named alternative ('add_top_level'). This gives clear context for when to choose this tool over others.

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/kambleakash0/agent-skills'

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