Skip to main content

Running Commands

Module: Core Features | Lesson: 4 of 7 | Time: ~10 minutes

What You Will Learn

  • How Claude runs commands using the Bash tool
  • How to ask Claude to run PowerShell commands
  • How to read and understand command output

Prerequisites

Why This Matters

Sometimes you need more than reading and editing files. You might want to list the contents of a folder, install a program, run a script, or check system information. Claude can do all of this by running commands in your terminal, just as if you typed them yourself. The Bash tool is how Claude executes commands on your computer.

"Bash" on Windows?

The tool is called "Bash" because that is its name in Claude Code, but on Windows it actually runs commands through your system shell (PowerShell or Command Prompt). You do not need to know Linux or Bash to use it. Just ask Claude to do something, and it will use the right Windows commands.

How Claude Runs Commands

When you ask Claude to do something that requires running a command, it uses the Bash tool. You will see output like this:

 ─ Bash: dir

Directory: C:\Users\YourName\claude-practice

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/02/2026 9:30 AM 142 my-notes.txt
-a--- 4/02/2026 9:25 AM 86 shopping-list.txt

Claude chose to run the dir command (the Windows command for listing folder contents) and showed you the results.

Asking Claude to Run Commands

You can ask in plain English. Claude figures out which command to run:

> What files are in this folder?
> How much free disk space do I have?
> What version of Node.js is installed?
> Create a new folder called "backup"
> Show me what processes are currently running

You can also ask Claude to run a specific command if you know what you want:

> Run: dir /s *.txt
> Run the command: python --version
> Execute: Get-ChildItem -Recurse -Filter "*.md"

Permission for Commands

Just like with file edits, Claude asks for your permission before running any command:

Claude wants to run: dir C:\Users\YourName\Documents

Allow? (Y)es / (N)o / (A)lways allow Bash

The same three options apply:

OptionWhat It Does
Y (Yes)Allow this one command. Claude will ask again next time.
N (No)Do not run this command.
A (Always allow)Allow all Bash commands for the rest of this session.
Be Careful with "Always Allow" for Bash

The Bash tool is the most powerful tool Claude has. It can create, delete, move, and modify anything on your computer. While Claude is careful and well-intentioned, it is best to review each command until you are comfortable understanding what they do. Pressing Y each time is the safest approach for beginners.

Understanding Command Output

After a command runs, Claude shows you two things:

  1. The raw output -- exactly what the command printed
  2. An explanation -- Claude translates the output into plain English

For example, if you ask "How much disk space do I have?":

 ─ Bash: Get-PSDrive C

Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
C 234.5 221.3 FileSystem C:\

You have about 221 GB of free space on your C: drive.

Claude does not just run the command and leave you to figure out the result. It explains what the output means in plain language.

Examples of Useful Commands

Here are common things you might ask Claude to do with the Bash tool:

File and Folder Management

> Create a folder called "projects" inside my Documents folder
> Move all .txt files into the "notes" folder
> Copy config.json to config-backup.json
> How many files are in this folder?

System Information

> What version of Windows am I running?
> How much RAM does this computer have?
> What is my current user name?
> Show me my PATH environment variable

Running Scripts and Programs

> Run the Python script main.py
> Start the Node.js server in server.js
> Execute the build script
> Run npm install

Working with Git

> Initialize a git repository here
> What is the git status of this project?
> Show me the recent git log
Chaining Requests

You can ask Claude to do multiple things in sequence:

> Create a folder called "output", then run the Python script main.py, and tell me if there were any errors

Claude will run each step and report back.

Destructive Commands: Be Cautious

Some commands can permanently delete or change things on your computer. Claude is generally cautious about these and will warn you, but it is important to understand the risks:

Destructive Commands

The following types of commands can cause data loss if used incorrectly:

  • Deleting files: del, Remove-Item, rm
  • Formatting drives: Format-Volume
  • Modifying system settings: Registry edits, environment variable changes
  • Force operations: Commands with -Force flags that skip confirmation

Always read the command Claude proposes before pressing Y. If you do not understand what a command does, press N and ask Claude to explain it first.

If you are ever unsure, ask:

> What would that command do? Explain it before running it.

Claude will break down the command for you without executing it.

Common Questions

Q: Can Claude run commands that take a long time? Yes, but there is a timeout. If a command runs for more than two minutes, it will be stopped. For long-running tasks (like installing large packages), Claude will let you know if it gets cut off.

Q: Can Claude run interactive commands that need me to type something? Not directly. Commands that ask for user input (like "Press Y to continue") can cause Claude to get stuck. Claude generally avoids these, but if it happens, you can press Ctrl+C to cancel the command.

Q: What if a command fails? Claude will show you the error message and usually explain what went wrong. You can then work together to fix the issue and try again.

Q: Does Claude remember commands it ran earlier? Yes, within the same session. Claude remembers both the commands it ran and their output, so you can refer back to earlier results.

Try It Yourself

Step 1: Check Your Folder Contents

Start Claude Code in your practice folder:

> What files and folders are in my current directory?

Review the command Claude wants to run, then press Y. Read the output.

Step 2: Get System Information

> What version of PowerShell am I running?

Claude will run a command and explain the result.

Step 3: Create a Folder Structure

> Create the following folder structure inside a new folder called "my-project":
> - src (for source code)
> - docs (for documentation)
> - tests (for test files)

Review each command and approve them.

Step 4: Verify the Result

> Show me the folder structure of my-project as a tree

You should see the folders Claude just created.

Step 5: Practice Rejecting a Command

> Delete the my-project folder and all its contents

When Claude proposes the command, press N to reject it. Then say:

> Actually, keep it. I want to use it later.
Checkpoint

If you successfully ran commands to list files, get system info, and create folders, and you practiced rejecting a destructive command, you understand the Bash tool.

What You Learned

  • Bash tool: How Claude runs commands on your Windows computer
  • Ask naturally: Describe what you want and Claude picks the right command
  • Permission prompts: Claude always asks before running a command
  • Output explained: Claude shows the raw output and explains it in plain English
  • Be cautious: Always review destructive commands before approving
  • Ask first: If you do not understand a command, ask Claude to explain before running it

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Searching with Glob