# Usage Examples

Claude IDE Bridge — realistic prompts and what they unlock

These examples show how Claude Code uses the bridge to interact with your live IDE. Each example includes the user prompt, the bridge tools involved, and the outcome.

## 1 Fix all errors in the current file

Fix all the TypeScript errors in the file I have open right now.

### What happens

1. Bridge calls `getActiveFile` — reads the path of the file currently focused in the editor.
2. Bridge calls `getDiagnostics` for that file — returns the live compiler errors from VS Code's language server, with exact line numbers, error codes, and messages (e.g. "TS2345: Argument of type 'string' is not assignable to parameter of type 'number'").
3. Bridge calls `readFile` to get the current file contents.
4. Claude reasons over the errors and the code, writes corrected content.
5. Bridge calls `editFile` — applies the changes directly in the open editor, preserving unsaved state and undo history.
6. Bridge calls `getDiagnostics` again to confirm the error count dropped to zero.

### Why the bridge is needed

Without the bridge, Claude Code has no access to live compiler diagnostics — it can only read files from disk. The bridge exposes VS Code's Language Server Protocol output in real time, so Claude sees the same errors you see in the Problems panel, including errors in files that haven't been saved yet.

Tools used: getActiveFile, getDiagnostics, readFile, editFile

## 2 Find every caller of a function and rename it safely

Rename the function `getUserById` to `fetchUserById` everywhere it's used across the project.

### What happens

1. Bridge calls `getDocumentSymbols` on the file containing `getUserById` — locates the exact definition position.
2. Bridge calls `findReferences` with that position — returns every call site across all project files, with file paths and line numbers, using the live LSP index.
3. Claude groups the edits by file (definition + all callers) and builds a minimal change set.
4. Bridge calls `editFile` for each file — applies the rename atomically, one file at a time, without touching unrelated lines.
5. Bridge calls `getDiagnostics` project-wide to confirm no import or type errors were introduced.

### Why the bridge is needed

A naive text search would miss dynamic call patterns, miss callers in files that import via re-exports, and have no way to verify correctness. The bridge uses the actual LSP reference index — the same source of truth that powers VS Code's built-in rename refactor — so every caller is found, even across dozens of files.

Tools used: getDocumentSymbols, findReferences, editFile, getDiagnostics

## 3 Run tests, read failures, and fix the code

Run the tests for the auth module, find out what's failing, and fix it.

### What happens

1. Bridge calls `runTests` targeting the auth module — executes the test runner (Jest/Vitest/pytest/etc.) and returns structured results: pass/fail counts, test names, failure messages, and stack traces.
2. Claude reads the failure output — e.g. "Expected 401 but received 200 on POST /login with expired token".
3. Bridge calls `readFile` on the relevant source and test files to understand the implementation.
4. Claude identifies the bug (e.g., token expiry check using `>` instead of `>=`) and writes the fix.
5. Bridge calls `editFile` to apply the change in the editor.
6. Bridge calls `runTests` again — confirms all tests now pass before reporting back.

### Why the bridge is needed

The bridge runs the test suite through the IDE's integrated test runner and returns machine-readable results — not raw terminal output. Claude gets structured pass/fail data it can reason over directly, and can loop: fix → re-run → verify, without any manual copy-pasting from a terminal window.

Tools used: runTests, readFile, editFile

## Prerequisites

All examples require:

1. Claude IDE Bridge running locally (`npm install -g claude-ide-bridge && claude-ide-bridge start-all`)
2. The companion VS Code extension installed and connected (shown as "Connected" in the status bar)
3. Claude Code CLI configured to use the bridge (`claude-ide-bridge gen-claude-md` adds the MCP config)

See the README for full setup instructions.