2.2 Making Code Changes
Course: Claude Code - Essentials Section: Core Workflows Video Length: 2-5 minutes Presenter: Daniel Treasure
Opening Hook
Now that you know your codebase inside and out, it's time to make changes. Claude Code doesn't just read code—it edits files, creates new ones, and refactors existing code. But first, it asks for your approval. In this video, we'll show how the approval flow works, and how Claude proposes changes so you stay in control.
Key Talking Points
- Claude Proposes Before Changing
- When you ask Claude to edit a file, it shows you the diff first
- You see exactly what's changing, line by line
- No changes are made until you approve
-
Show on screen: Ask for a code change and see the approval prompt appear
-
The Diff View Tells the Story
- Green lines are additions; red lines are removals (or your terminal equivalent)
- It's easy to spot if Claude understood your request correctly
- You can approve once, for the session, or deny and ask for revisions
-
Show: A simple edit with visible diffs. Highlight what changed and why
-
File Edits vs. New Files
- Edit: Claude changes existing code—most common
- Create: Claude writes a brand new file when needed (e.g., a new component, utility module)
- Both require approval; new files show a full preview
-
Show: One edit (maybe fixing a bug) and one new file (e.g., a helper function)
-
Refactoring with Confidence
- Ask Claude to improve structure without changing behavior: "Refactor this module to use async/await"
- Claude understands intent and preserves functionality
- The diff preview lets you verify before accepting
-
Show: A refactor example where the logic stays the same but code is cleaner
-
Editing Multiple Files in One Request
- Claude can edit 2-3 files at once if changes are related
- Shows diffs for each file in sequence
- Approve them together or individually (depending on permission mode)
- Show: A request that touches 2 files (e.g., "add a new endpoint and update the router")
Demo Plan
Demo Project: Continue with the same project from 2.1 (so context carries over)
Setup: - Resume the session from 2.1, or start fresh with the same project - Have terminal and Claude Code session open - Confirm you understand the codebase from 2.1
On-Camera Sequence (2-3 minutes):
- Simple Edit (Permission Approval)
Fix the typo in the welcome message in main.js(Prepare a typo in a visible file beforehand, or ask Claude to add a comment with a typo) - Claude proposes the change with diff
- Show the approval prompt
- Accept it and show the file is updated
- Highlight the "until session end" vs. "once" vs. "deny" options
-
~45 seconds
-
Creating a New File
Create a utility module for date formatting in src/utils/dateFormatter.js - Claude writes the file and shows a preview
- Explain that new files also need approval
- Accept and confirm the file appears in the project
-
~30 seconds
-
Refactoring Request
Refactor the authentication logic to use async/await instead of promises(Use an existing file with promise-based async code) - Show Claude understands the intent
- Diffs show the structural changes
- Point out: same behavior, cleaner code
- Accept and verify the logic is preserved
-
~30 seconds
-
(Optional) Multi-File Change
Add a new /users endpoint. Update the router file and create a new controller file. - Show Claude handling 2 files
- Multiple diffs appear in sequence
- Option to approve both at once or review separately
- ~20 seconds
Code Examples & Commands
Asking for edits:
Fix the bug on line 42 of auth.js
Refactor this function to use async/await
Add input validation to the login form
Improve the comments in database.ts
Change the color scheme from blue to green
Asking for new files:
Create a new utility function for parsing JSON
Generate a test file for the Calculator class
Write a middleware for logging requests
During approval prompt:
- Type y or yes to approve once
- Type s or session to approve for the entire session (skip future prompts for edits)
- Type n or no to reject the change
- Type e or edit to request revisions (end edit mode, ask for changes)
Gotchas & Tips
-
Approval Modes Matter – In later videos, we'll show how to set "acceptEdits" mode to auto-approve. For now, approval is per-change.
-
Diffs Can Be Large – For big refactors, the diff might scroll off-screen. You can press spacebar to see more, or zoom out the terminal.
-
Claude Respects Existing Style – If you have a specific code style (indentation, naming, etc.), mention it once and Claude remembers. Future edits use that style.
-
You Can Always Revert – If you approve a change and regret it, just ask Claude to undo it or use git to revert (we cover that in 2.3).
-
Edits Are Instant – Once approved, Claude writes the file immediately. You see changes in your editor or IDE in real time.
-
New Files Don't Auto-Appear in Some IDEs – If you're using VS Code, it may not refresh immediately. You can refresh the file explorer or close/reopen the project.
Lead-out
You now know how to read code and make changes. But how do you track those changes? That's where Git comes in. In the next video, we'll show how Claude helps you create commits, switch branches, and manage your version control workflow.
Reference Material
- Common Workflows - Making Code Changes: https://code.claude.com/docs/en/common-workflows
- Quickstart - Make Your First Code Change: https://code.claude.com/docs/en/quickstart
- Edit Tool Documentation: https://code.claude.com/docs/en/cli-reference
- Permissions System: https://code.claude.com/docs/en/permissions
Relevant Articles & Posts
- Best Practices: Lukasz Fryc's "15 Tips from Running 6 Projects" (DEV Community) – covers code quality and verification
- Workflows: Joe Njenga's "17 Best Claude Code Workflows" (Medium) – includes refactoring patterns
- Official Guide: Best Practices - Claude Code Docs (https://code.claude.com/docs/en/best-practices)
Additional Notes
- Emphasize user control—Claude proposes, you approve
- Show diffs clearly; pause so viewers can read what changed
- Use a relatable example (fixing a typo, adding a comment) so first-time users aren't intimidated
- Mention that next videos (2.3 onward) build on this workflow
- If time, mention: CLAUDE.md files (coming in Section 3) let you set code style preferences for Claude