rails_get_edit_context
Returns matching lines with surrounding code and line numbers so you can edit a specific method or section without reading the whole file. Use a file plus near text or line number to locate it.
Instructions
Get targeted code context for surgical edits: returns matching lines with surrounding code and line numbers. Use when: you need to edit a specific method or section without reading the entire file. Requires file:"app/models/user.rb" and near:"def activate" (or line:42) to locate the code region.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | File path relative to Rails root (e.g. 'app/models/post.rb', 'app/controllers/posts_controller.rb'). | |
| line | No | Show context_lines either side of this line number instead of searching for `near` (e.g. a line from a stack trace). | |
| near | No | What to find in the file - a method name, keyword, or string to locate (e.g. 'scope', 'def index', 'validates', 'STATUSES'). | |
| context_lines | No | Lines of context above and below the match. Default: 5. |