skim
Read and display the first lines of the current file to quickly review content without opening the entire document.
Instructions
Read text from the current file, truncated to the first SKIM_MAX_LINES lines.
Returns: dict: lines, total_lines, max_select_lines
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/text_editor/server.py:420-452 (handler)Implementation of the 'skim' tool handler. Reads the first up to 500 lines (configurable via SKIM_MAX_LINES) from the current file set by set_file(), formats as list of [line_number, content], includes total lines and max_select_lines, warns if truncated.async def skim() -> Dict[str, Any]: """ Read text from the current file, truncated to the first `SKIM_MAX_LINES` lines. Returns: dict: lines, total_lines, max_select_lines """ if self.current_file_path is None: return {"error": "No file path is set. Use set_file first."} with open(self.current_file_path, "r", encoding="utf-8") as file: lines = file.readlines() formatted_lines = [] max_lines_to_show = int(os.getenv("SKIM_MAX_LINES", "500")) lines_to_process = lines[:max_lines_to_show] for i, line in enumerate(lines_to_process, 1): formatted_lines.append((i, line.rstrip())) result = { "lines": formatted_lines, "total_lines": len(lines), "max_select_lines": self.max_select_lines, } # Add hint if file was truncated if len(lines) > max_lines_to_show: result["truncated"] = True result["hint"] = ( f"File has {len(lines)} total lines. Only showing first {max_lines_to_show} lines. Use `read` to view specific line ranges or `find_line` to search for content in the remaining lines." ) return result