HOW-TO · DEV

How to navigate and edit files using Claude Code's interactive mode

intermediate20 minBy Fredoline Eruo
Target environment
Ubuntu 24.04 · Claude Code 1.xmacOS 14.x · Claude Code 1.x
PREREQUISITES

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

  1. Launch Claude Code in interactive mode by running claude from any directory. The terminal enters a chat-style REPL prompt.
  2. List the current directory contents by running the /ls command. A formatted list of files and folders appears in the output.
  3. Navigate into a subdirectory using the /cd command followed by the directory name, for example /cd src.
  4. 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.
  5. Request a targeted edit by describing the change in natural language, for example "Update the error handling in the validateInput function to return null instead of throwing".
  6. Claude Code displays a unified diff showing the proposed change, highlighting removed lines in red and added lines in green.
  7. Accept the proposed change by typing y or pressing Enter. Reject it by typing n.
  8. For bulk edits across multiple files, specify the scope in the prompt, for example "Refactor all console.log calls in the utils/ directory to use the logging module".
  9. Review the full diff summary before accepting multiple changes across files.
  10. 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

  1. File not found error during /read — The path provided must be relative to the current working directory. Re-run /ls to confirm the file exists, or use /cd to navigate to the correct location before reading.

  2. 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 diff to review changes and git checkout -- <file> to restore the original.

  3. 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 /read command, 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