Let Claude Code Touch Your Files: First Steps With AI Pair Programming

hero

If you've installed Claude Code and only used it to generate code snippets you paste in manually, you're leaving the best part on the table. This guide walks through how to point Claude at your actual project files and let it make surgical edits — with a diff-based approval step so nothing changes without your sign-off.

overall flow diagram

The Problem With Copy-Paste AI Coding

Most developers start using an AI assistant the same way: ask it a question in a chat window, get a code block back, copy it, switch to your editor, find the right file, paste it in the right spot. Repeat twenty times a day.

It works. But it's slow, and the friction adds up fast — especially when the AI doesn't know your actual file structure, import paths, or naming conventions. You end up doing a lot of manual stitching that the AI could handle itself.

Claude Code fixes this by running inside your terminal, in your project directory, with direct read/write access to your files. The leap in iteration speed is real.

copy-paste vs direct edit

Section 1: Giving Claude Its First Task

Once Claude Code is installed, open a terminal in your project root and just talk to it like you'd talk to a colleague sitting next to you. No special syntax, no rigid command flags.

claude 'Look at main.py and tell me what it does'

Claude scans the directory tree, reads the relevant files, and responds with context that actually reflects your project — not a generic answer. That's the key difference from a web-based chat interface: it sees what you see.

For your first edit task, keep it concrete:

claude 'Add a hello_world function to main.py'

Claude will open main.py, figure out the right location for the new function (respecting imports, class structure, whatever's already there), and draft the change.

file scan and edit sequence

Section 2: The Approval Gate (The Part That Keeps You Safe)

Here's the part that matters most for trust: Claude Code does not apply edits automatically. Before any file changes, it surfaces a diff — the same unified diff format you see in pull requests.

A typical output looks like this:

--- a/main.py
+++ b/main.py
@@ -12,6 +12,12 @@ def setup():
     pass

+def hello_world():
+    """Print a greeting."""
+    print("Hello, world!")
+
 def main():
     setup()

You get two choices:

Key Action
y Apply the change to disk
n Discard the change, no file touched

Nothing is written until you press y. This is what makes it practical to let an AI touch production-adjacent files — you're always the last line of approval.

What worked for me was treating this diff view as a mandatory code review step, not just a formality. If Claude's edit looks slightly off, you can say "that's close, but move the function above main()" and it will re-draft before asking again.

approval gate decision

Section 3: Variations, Chains, and Gotchas

Multi-file edits work too. Claude can hold changes to several files in one session. If you ask it to "add a hello_world endpoint in app.py and wire it into routes.py," it'll show you diffs for both files and ask for approval on each.

Session memory is scoped to the terminal window. This is the thing most people miss early on. As long as you stay in the same Claude Code session, it remembers every edit it proposed or applied, and every question you asked. Close the terminal and that context is gone. What that means practically:

  • Don't context-switch mid-refactor. Finish the thought in one session.
  • If you need to pause, write a quick note in a TODO.md before closing — Claude can read it when you restart.

The gotcha with large files. On files over ~500 lines, Claude sometimes misidentifies the insertion point, especially if your file mixes classes, standalone functions, and module-level code in a non-standard way. What worked for me: add context to the request.

# Vague — works on small files, risky on large ones
claude 'Add a retry function to utils.py'

# Better — anchors the insertion point
claude 'Add a retry function to utils.py, right after the existing log_error function on line 47'

Environment differences. Claude Code runs in whatever shell environment you have active. On macOS with Homebrew Python vs. a Docker container vs. a Linux CI box, the file paths and Python environment it sees will differ. Always cd into the correct project root before starting a session, and verify with pwd if anything looks off.

# Confirm you're where you think you are
pwd
ls -la

# Then start your session
claude 'Add the retry function to utils.py after log_error'

Selective file scope. If you're worried about Claude touching the wrong files, you can narrow its scope explicitly:

claude --file main.py 'Add a hello_world function'

This restricts Claude's read and write access to just that file for the session. Useful when you're working in a monorepo with lots of services you don't want touched.

Closing

The core payoff here isn't the individual edits — it's continuity. Claude Code maintains the full context of your project and your conversation for the duration of the session, which turns it into something closer to a pair programmer than an autocomplete engine. The diff approval step means you stay in control without becoming a manual paste machine.

Next step worth exploring: chaining multiple edit requests in a single session to do a full feature implementation — model, routes, tests — without leaving the terminal once.


TAGS: claude-code, ai-coding, terminal-development, developer-tools, pair-programming


🐦 Faster updates on X: @baegseungh7061
📚 More in this series: Code Intro
💌 Subscribe: Follow on X or grab the RSS

댓글