organize_imports

[codefix]

Organizes TypeScript or JavaScript imports with TypeScript language-service edits.

Why this tool exists

Import cleanup should follow TypeScript project semantics instead of text sorting that can remove needed syntax or miss type-only imports.

How it helps the agent

The model can preview sorted, combined, or unused-import cleanup edits while preserving live document version guards.

Try it locally in the TGlider playground

Parameters

NameTypeRequiredDescription
filePathstringYesWorkspace-relative or absolute file path.
applyChangesbooleanNoApply organize-import edits to live workspace state instead of returning preview only.
includeDiffbooleanNoInclude a unified diff in the response.
maxDiffCharsnumberNoMaximum diff characters to return before truncating.
skipDestructiveCodeActionsbooleanNoSort and combine imports without removing unused imports.

Examples

Preview import organization edits

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "organize_imports",
    "arguments": {
      "filePath": "src/app.ts"
    }
  }
}

Response Notes

Returns organize-import edits, preview diff metadata, live-document version state, and whether changes were applied.

↑/↓ NavigateEnter OpenSpace Expand