How to navigate and edit files using Claude Code's interactive mode
Claude Code CLI installed and authenticated with an Anthropic account
What this does
Claude Code provides an interactive REPL mode that enables navigation through project directories, reading file contents, and making targeted edits with confirmation before applying changes. This workflow enables precise, context-aware code modifications without leaving the terminal.
Steps
- Launch Claude Code in interactive mode by running
claudefrom any directory. The terminal enters a chat-style REPL prompt. - List the current directory contents by running the
/lscommand. A formatted list of files and folders appears in the output. - Navigate into a subdirectory using the
/cdcommand followed by the directory name, for example/cd src. - Read the contents of a specific file by typing
/read <relative-path>, for example/read src/index.ts. The file contents display with line numbers. - Request a targeted edit by describing the change in natural language, for example "Update the error handling in the
validateInputfunction to return null instead of throwing". - Claude Code displays a unified diff showing the proposed change, highlighting removed lines in red and added lines in green.
- Accept the proposed change by typing
yor pressing Enter. Reject it by typingn. - For bulk edits across multiple files, specify the scope in the prompt, for example "Refactor all
console.logcalls in theutils/directory to use the logging module". - Review the full diff summary before accepting multiple changes across files.
- Save and exit the session by typing
/exit. Unsaved in-memory edits are discarded, but accepted changes are written to disk immediately upon confirmation.
Verification
claude
/lcd src
/read index.ts
exit
Expected output:
[interactive mode started]
Switched to: src/
--- src/index.ts ---
1: import { app } from './app';
2: export const index = app;
[interactive mode ended]
Common failures
File not found error during
/read— The path provided must be relative to the current working directory. Re-run/lsto confirm the file exists, or use/cdto navigate to the correct location before reading.Edit diff rejected but session state corrupted — If a complex edit is partially applied, the file may be left in an inconsistent state. Use
git diffto review changes andgit checkout -- <file>to restore the original.Long file reads truncated in terminal — Claude Code may truncate display for files larger than a few hundred lines. Request a specific section using a line range in the
/readcommand, for example/read src/large-file.ts:50-100.
Related guides
- Install Claude Code CLI and authenticate with your Anthropic account
- Use Claude Code in a read-only reviewing mode for security-sensitive environments