ServicesAboutNotesContact Get in touch →
EN FR
Note

Claude Code Behind the Scenes

What commands Claude Code actually runs when it explores code, searches for patterns, edits files, and manages git — understanding the mechanics builds confidence and helps you learn

Planted
claude codeai

This note documents the categories of operations Claude Code performs and the tools it uses. Claude Code runs the same kinds of commands a developer would run manually — just faster and more systematically. Knowing these patterns makes Claude Code’s output readable with comprehension rather than blind trust.

File Discovery

Rather than running raw find or ls commands, Claude Code uses built-in tools optimized for speed and safety. When searching for files, it uses glob patterns:

**/*.js All JavaScript files recursively
src/**/*.ts TypeScript files in src/
*.{json,yaml} JSON and YAML files in current directory
test/**/*test.js Test files matching pattern

Glob patterns are a concise way to describe sets of files. The ** means “any number of directories deep.” The * means “any characters.” Combined, **/*.sql finds every SQL file in the entire project tree.

For directory listings, Claude Code’s internal tools provide structured output with metadata. You may occasionally see standard ls or ls -la when Claude needs a quick overview, but most file discovery happens through the built-in glob tool.

Content Searching

Claude Code’s search capabilities are powered by ripgrep (rg), a modern search tool that’s dramatically faster than traditional grep on large codebases. When you ask Claude to find something, it might run:

Terminal window
rg "function authenticate" --type js # Find in JavaScript files
rg "TODO" -c # Count occurrences
rg "error" -i -C 2 # Case-insensitive with context lines
rg "import.*React" --glob "*.tsx" # Find React imports in TSX files

The key ripgrep flags Claude Code uses:

FlagPurpose
--typeFilter by file type (js, py, rust, etc.)
-iCase-insensitive search
-C NShow N lines of context around each match
-cCount matches instead of showing them
--globFilter by file pattern
-nShow line numbers

If you know grep, ripgrep is the same idea with better performance and smarter defaults (it respects .gitignore automatically, for instance). The syntax is similar enough that grep knowledge transfers directly.

File Reading and Modification

For reading files, Claude Code uses its built-in Read tool rather than cat. This provides line numbers and handles special files like images, PDFs, and Jupyter notebooks. The Read tool can also read specific sections of large files rather than loading everything into memory.

For modifications, Claude Code uses an Edit tool that makes surgical changes rather than rewriting entire files:

{
"file_path": "/path/to/file.ts",
"old_string": "oldFunctionName",
"new_string": "newFunctionName",
"replace_all": true
}

This approach has two advantages over the sed or awk commands you might use manually. First, it’s precise — it replaces exactly the text specified, with no risk of matching unintended occurrences. Second, it produces clean diffs — the change is visible and reviewable, not buried in a complex sed expression.

When Claude Code needs to create a new file entirely, it uses a Write tool that creates the file with the specified content. Both Edit and Write require your approval before executing.

Git Commands

Git is where you’ll see the most actual bash commands in Claude Code’s output. These are standard git operations that you’d run yourself:

Terminal window
# Checking state (often run in parallel)
git status # What's changed?
git diff # Unstaged changes
git diff --staged # Staged changes
git log --oneline -10 # Recent commits
# Making changes
git add . # Stage all changes
git commit -m "message" # Commit with message
git branch --show-current # Current branch name
# Working with remotes
git push origin main
git pull origin main

Before committing, Claude Code typically runs git status, git diff, and git log in parallel to understand the full state before making changes.

Package Managers and Build Tools

Development workflows involve frequent package manager commands. Claude Code runs these when installing dependencies, building projects, or running tests:

Terminal window
# Node.js/npm
npm install # Install dependencies
npm run build # Build project
npm run dev # Start development server
npm test # Run tests
# Python/pip
pip install -r requirements.txt
pytest # Run tests
# Other ecosystems
cargo build # Rust
go build # Go
yarn install # Yarn

These commands are ecosystem-specific — you’ll see whichever ones match your project’s technology stack. Claude Code detects the project type from configuration files (package.json for Node, requirements.txt for Python, Cargo.toml for Rust) and uses the appropriate tools.

System and Process Commands

Occasionally Claude Code checks system state to understand the environment:

Terminal window
which python # Find where Python is installed
env # List environment variables
ps # Check running processes
file document.pdf # Determine file type
wc -l bigfile.txt # Count lines

These are diagnostic commands — Claude Code uses them to answer questions about the development environment, verify that dependencies are installed, or gather information needed to troubleshoot an issue.

The Pattern: Read, Plan, Execute, Verify

Across all these categories, Claude Code follows a consistent pattern:

  1. Read — gather information about the current state (file contents, git status, directory structure)
  2. Plan — determine what changes are needed based on your request
  3. Execute — make the changes (file edits, git operations, command execution)
  4. Verify — confirm the changes worked (compile, run tests, check output)

This is the same workflow a careful developer follows. The value of Claude Code isn’t that it does something different — it’s that it does the same thing faster and more consistently, without forgetting steps or getting distracted.

The commands Claude Code runs are the same commands a developer uses manually, applied systematically.