code_signature
code_signature returns the first line of a symbol’s definition — the name, parameters, return type, and any decorators. It skips the entire body, making it the cheapest way to verify a function’s interface.
code_signature(name="UserService.findById")code_signature(name="processPayment")Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | required | Symbol name to look up |
Output
Section titled “Output”async findById(id: string): Promise<User | null>Token savings
Section titled “Token savings”| Task | Instead of | Use |
|---|---|---|
| Check what params a function takes | code_get — full body | code_signature — 1 line |
| Verify return type before calling | Read entire file | code_signature — instant |
One line versus dozens or hundreds. Use code_signature when you only need to confirm the interface, not read the implementation.
When to use
Section titled “When to use”- Confirm a function’s parameter names and types before calling it
- Check the return type of a function referenced elsewhere
- Get a fast overview of many functions without loading their bodies