DaleSchool

Working Across the Entire Project

Intermediate25min

Learning Objectives

  • Request multi-file refactoring from Claude
  • Know how to set up safety measures before large-scale changes
  • Use @filename to include specific files in the context

Working Code

Let's request changes across multiple files:

> Find all console.log statements in the project and replace them with a proper logging library (winston).
> Also create a logger configuration file.

Claude modifies several files at once, showing you the diff for each file and asking for approval.

More complex refactoring is also possible:

> Apply error handling middleware to all route handlers in src/api/.
> Find handlers that don't have try-catch and wrap them with asyncHandler.

Try It Yourself

Use the @ symbol to include specific files in the context:

> Based on the User type in @src/types/user.ts,
> add types to all functions in @src/api/users.ts

This makes Claude prioritize those files as references.

Before large-scale changes, always set up safety measures:

> Save the current state with git stash before starting changes

Or create a branch:

> Create a branch called refactor/logging and work there

"Why?" — Project-Scale Work Is Where Claude Code Shines

Single-file editing can be done with any tool. What makes Claude Code special is its ability to understand the full project context and change multiple files consistently.

Multi-File Work Checklist

  1. Before changes: Create a Git branch or save with stash
  2. When requesting: Clearly communicate the scope and rules
  3. During review: Carefully check each file's diff
  4. After changes: Run tests to catch regressions

File Targeting with @ Mentions

| Usage | Meaning | | ---------------- | ---------------------------------- | | @src/config.ts | Include a specific file in context | | @src/utils/ | Reference an entire directory | | @package.json | Reference a config file |

Large-Scale Refactoring Prompt Example

> Unify all API response formats in this project.
> Current: each endpoint uses its own format
> Goal: standardize to { success: boolean, data: T, error?: string }
> Define the common type in @src/types/response.ts,
> and update all handlers in @src/api/.

Deep Dive

There are too many changes to review

Break large-scale changes into stages:

  1. "First, just create the type definitions"
  2. "Now update only the users API"
  3. "Apply the same pattern to the remaining APIs"

Reviewing 20 files at once is hard. Verify in batches of 5.

  1. Request a simple multi-file change in your project (e.g., change indentation from 2 spaces to 4 in all files).
  2. Mention two files with @ and ask Claude to explain the relationship between them.
  3. Create a branch, try a large-scale change, and delete the branch if there are problems.

Q1. What's the first thing you should do before a large-scale refactoring?

  • A) Start refactoring immediately
  • B) Create a Git branch or save the current state with stash
  • C) Delete the project and start fresh
  • D) Tell Claude "just figure it out"