Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
AI coding agents are becoming a powerful part of modern software development. Instead of only asking questions in a browser, developers now want an AI assistant that can work directly inside the project folder, understand the codebase, read files, suggest fixes, edit code, run commands, and support Git workflows.
Claude Code is Anthropicโs official agentic coding tool. It runs from the terminal and is designed to help developers work directly inside their codebase. According to Anthropic, Claude Code can understand a codebase, edit files, run commands, and help developers ship faster from the terminal or IDE. (Claude)
In this tutorial, we will cover the complete setup process for using Claude Code Agent on a local Windows laptop. We will also cover the exact problems that commonly happen during setup, including:
claude is not recognized as an internal or external command
where claude shows nothing
PowerShell shows >> and does not execute the command
PATH was truncated after using setx
Claude is installed in C:\Users\username\.local\bin but does not run from anywhere
This tutorial is written for developers using Windows, XAMPP, Laravel, Git, VS Code, CMD, and PowerShell.
What Is Claude Code Agent?
Claude Code is a terminal-based AI coding agent created by Anthropic. It is different from the normal Claude chat window because it works directly inside your local project folder.
For example, if you have a Laravel project here:
C:\xampp\htdocs\devopsschool\ds-student-ms
you can open CMD or PowerShell, go to that project folder, and run:
claude
Then Claude Code can help you analyze the Laravel project, understand routes, controllers, models, Blade files, services, migrations, environment files, and other project logic.
Anthropic describes Claude Code as an agentic coding tool that lives in the terminal and helps with coding tasks, code explanation, routine development work, and Git workflows. (GitHub)
Why Set Up Claude Code Locally?
A local Claude Code setup is useful because your coding workflow becomes faster and more practical.
Instead of manually copying files into a chat window, Claude Code can work inside the project directory. This is useful for tasks like:
Analyzing a full Laravel project
Finding controller and route issues
Fixing Blade file problems
Improving validation
Checking Keycloak integration
Reviewing authentication flow
Cleaning unnecessary logs
Preparing SonarQube-friendly code
Writing migration changes
Understanding API flow
Debugging Git changes
For example, in a Laravel project like ds-student-ms, you can ask Claude Code:
Read this Laravel project completely. Understand routes, controllers, models, migrations, Blade files, and Keycloak integration. Do not change anything yet. First explain the current flow and where the issue is.
This kind of workflow is much better than giving small code snippets one by one.
System Requirements for Claude Code on Windows
For Windows users, Anthropicโs terminal guide says Claude Code requires Windows 10 version 1809 or later. It also recommends installing Git for Windows because Claude Code uses Git internally to track changes to your code. (Claude Code)
Before starting, make sure your system has:
Windows 10 or Windows 11
PowerShell or CMD
Git for Windows
Internet connection
Claude paid account or supported Claude access
A local coding project
For Laravel/XAMPP users, you may already have a project path like:
C:\xampp\htdocs\devopsschool\ds-student-ms
Step 1: Install Git for Windows
Claude Code works better when Git is installed. Git helps Claude Code understand code changes and work safely with your project.
Open CMD and check:
git --version
If Git is installed, you will see something like:
git version 2.xx.x.windows.x
If Git is not installed, install Git for Windows first. After installation, close CMD or PowerShell and open it again.
Then check again:
git --version
Step 2: Install Claude Code on Windows
Anthropicโs official quickstart documentation provides different install methods. For Windows PowerShell, the official install command is: (Claude Code)
irm https://claude.ai/install.ps1 | iex
Open PowerShell and run:
irm https://claude.ai/install.ps1 | iex
You do not normally need to run PowerShell as Administrator for a normal user-level installation. Anthropicโs advanced setup page explains that native Windows setup can be done using PowerShell or CMD after installing Git for Windows. (Claude Code)
After installation, close PowerShell and open a new CMD.
Then run:
claude --version
If it works, Claude Code is installed correctly.
Step 3: Install Claude Code Using CMD Alternative
If PowerShell installation does not work, Anthropic also provides a Windows CMD install command in the official quickstart docs: (Claude Code)
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Run this in CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Then close CMD, open it again, and test:
claude --version
Step 4: Confirm Where Claude Is Installed
Sometimes Claude is installed correctly, but Windows cannot find the command because the install folder is not added to PATH.
Run this command:
where claude
If Claude is properly available, you may see something like:
C:\Users\ashwa\.local\bin\claude.exe
In your case, Claude was found inside:
C:\Users\ashwa\.local\bin
You confirmed this by running:
dir "%USERPROFILE%\.local\bin"
The output showed:
claude.exe
That means Claude is installed. The remaining issue is only the Windows PATH configuration.
Step 5: Understand the PATH Problem
PATH is an environment variable in Windows. It tells Windows where to search for commands.
For example, when you type:
claude
Windows searches all folders listed in PATH. If the folder containing claude.exe is not inside PATH, Windows cannot find it.
That is why you may get this error:
'claude' is not recognized as an internal or external command,
operable program or batch file.
This does not always mean Claude is not installed. It usually means the Claude install folder is missing from PATH.
Step 6: Test Claude Directly Without PATH
Before fixing PATH permanently, test Claude directly.
Run this in CMD:
"%USERPROFILE%\.local\bin\claude.exe" --version
If this works, Claude installation is correct.
You can also start Claude directly:
"%USERPROFILE%\.local\bin\claude.exe"
If this opens Claude Code, then the only issue is PATH.
Step 7: Use Claude Temporarily in Current CMD Window
To use Claude immediately in the current CMD window, run:
set "PATH=%USERPROFILE%\.local\bin;%PATH%"
Then check:
where claude
Expected output:
C:\Users\ashwa\.local\bin\claude.exe
Now run:
claude --version
This temporary method works only for the current CMD window. If you close CMD and open it again, the setting may disappear. For permanent setup, follow the next step.
Step 8: Add Claude to PATH Permanently Using PowerShell
This is the safer method.
Open PowerShell and run this complete block:
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$claudePath = "$env:USERPROFILE\.local\bin"
if (($userPath -split ';') -notcontains $claudePath) {
[Environment]::SetEnvironmentVariable("Path", "$claudePath;$userPath", "User")
}
After running this, close all terminals:
CMD
PowerShell
VS Code terminal
Git Bash
Then open a new CMD and test:
where claude
Then:
claude --version
If this works, you can now run claude from any folder.
Step 9: Fix PowerShell >> Continuation Mode
While setting PATH, you may see PowerShell showing this:
>>
>>
>>
This means PowerShell is waiting for the command to finish. It usually happens when a command was pasted incorrectly, or a bracket, quote, or parenthesis is incomplete.
For example, if you paste half of this block:
if (($userPath -split ';') -notcontains $claudePath) {
PowerShell waits for the closing }.
To exit this mode, press:
Ctrl + C
Then you will return to:
PS C:\WINDOWS\system32>
Now paste the full command block again:
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$claudePath = "$env:USERPROFILE\.local\bin"
if (($userPath -split ';') -notcontains $claudePath) {
[Environment]::SetEnvironmentVariable("Path", "$claudePath;$userPath", "User")
}
Make sure you paste the complete block, including the final closing brace:
}
Step 10: Do Not Use setx PATH "%PATH%" Carelessly
A very common mistake is running:
setx PATH "%USERPROFILE%\.local\bin;%PATH%"
This can create a serious problem because setx may truncate long PATH values. In your case, the warning appeared:
WARNING: The data being saved is truncated to 1024 characters.
This means Windows saved only part of the PATH and removed the remaining entries. After this, some commands may stop working.
Avoid using this command:
setx PATH "%USERPROFILE%\.local\bin;%PATH%"
Instead, use the PowerShell method:
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$claudePath = "$env:USERPROFILE\.local\bin"
if (($userPath -split ';') -notcontains $claudePath) {
[Environment]::SetEnvironmentVariable("Path", "$claudePath;$userPath", "User")
}
This method updates the user PATH more safely.
Step 11: Add Claude PATH Manually Using Windows UI
If you do not want to use commands, you can add Claude to PATH manually.
Follow these steps:
Windows Search
Search for Environment Variables
Open Edit the system environment variables
Click Environment Variables
Under User variables, select Path
Click Edit
Click New
Add this path:
%USERPROFILE%\.local\bin
Click OK
Click OK
Close all terminals
Open new CMD
Then test:
where claude
and:
claude --version
Expected result:
C:\Users\ashwa\.local\bin\claude.exe
Step 12: Check NPM Path Also
Sometimes Claude Code may be installed through npm. In that case, the command may exist under:
C:\Users\ashwa\AppData\Roaming\npm
You checked this folder using:
dir "%USERPROFILE%\AppData\Roaming\npm"
Your folder had files like:
npm
npm.cmd
npx
npx.cmd
firebase
firebase.cmd
But it did not show claude.cmd. That means your current Claude install is not using the npm global path. Your Claude executable is here:
C:\Users\ashwa\.local\bin\claude.exe
So the correct PATH for your machine is:
%USERPROFILE%\.local\bin
Still, if you later install Claude using npm, you may also need to add:
%USERPROFILE%\AppData\Roaming\npm
Step 13: Verify Final Claude Setup
After setting PATH, open a fresh CMD and run:
where claude
Expected:
C:\Users\ashwa\.local\bin\claude.exe
Then run:
claude --version
If the version appears, your setup is correct.
Now test from a different folder:
cd C:\
claude --version
If this works from C:\, then Claude can be used from anywhere on your machine.
Step 14: Start Claude in Your Laravel Project
Now go to your Laravel project:
cd C:\xampp\htdocs\devopsschool\ds-student-ms
Start Claude:
claude
This opens Claude Code inside your project folder.
Now Claude can understand the files inside:
routes
app/Http/Controllers
app/Models
resources/views
database/migrations
config
.env
composer.json
Step 15: Create a Project Instruction File for Claude
For serious coding work, create a CLAUDE.md file in your project root.
Go to your project:
cd C:\xampp\htdocs\devopsschool\ds-student-ms
Create the file:
notepad CLAUDE.md
Paste this content:
# Claude Code Instructions for ds-student-ms
You are working on a Laravel project named ds-student-ms.
The goal is to help with safe, clean, and production-quality coding work.
Main project rules:
- Do not break existing functionality.
- Understand the current project flow before making changes.
- Keep changes small, focused, and reversible.
- Follow Laravel best practices.
- Write clean and SonarQube-friendly code.
- Do not add unnecessary logs, debug prints, or hardcoded values.
- Preserve existing business logic unless it is clearly wrong.
- Explain every file change after editing.
Authentication and Keycloak rules:
- Keycloak is the central identity provider.
- Email, name, and identity should come from Keycloak wherever applicable.
- User-specific data should be saved and read using Keycloak user ID.
- Avoid duplicate user records.
- Existing local records should be mapped with Keycloak user ID where required.
- Do not create a separate identity system when Keycloak already provides identity.
Laravel rules:
- Check routes before editing controllers.
- Check controllers before editing models.
- Check migrations before changing database-related logic.
- Validate all request data properly.
- Use services where business logic is reusable.
- Avoid large logic inside Blade files.
- Use clear error handling.
- Do not expose sensitive data.
Testing rules:
- Run syntax checks when possible.
- Suggest Laravel commands after changes.
- Mention if migration, cache clear, config clear, or route clear is required.
- Provide manual testing steps after every fix.
Before editing:
1. Analyze the related routes.
2. Analyze the controller methods.
3. Analyze related models and migrations.
4. Analyze related Blade or API usage.
5. Explain the current flow.
6. Ask for permission only if the change is risky.
After editing:
1. Show changed files.
2. Explain why each file was changed.
3. Provide testing commands.
4. Provide manual testing steps.
5. Mention any remaining risk or pending work.
Save the file.
This file helps Claude follow your project rules every time you run it inside this folder.
Step 16: Best First Prompt for Claude Code
When you first open Claude inside your Laravel project, do not directly ask it to change files.
First ask for analysis:
Read this Laravel project completely. Understand the current authentication flow, Keycloak integration, routes, controllers, models, migrations, Blade files, and API usage. Do not change anything yet. First give me a clear analysis of what is working, what is broken, and where Keycloak user ID is missing.
This is important because AI agents should first understand the project before editing.
Step 17: Best Prompt for Fixing Keycloak-Based Functionality
After Claude analyzes the project, you can give a task like:
Now fix the training requirement functionality end to end. Keycloak should be the central identity. Save and read user-specific data using Keycloak user ID. Do not break existing logic. Make the minimum required changes. After coding, show me changed files, reason for each change, and testing commands.
For bookmark functionality, use:
Now fix the bookmark feature end to end. The feature should use Keycloak user ID for saving and reading bookmarks. Do not use email as the main identity. Do not break existing UI or routes. Make the minimum required changes. After coding, show changed files, explain the logic, and give testing steps.
Step 18: Best Prompt for Claude as a Local Coding Agent
Use this prompt when you want Claude to work like a serious local coding assistant:
You are my local coding agent for this Laravel project.
First understand the complete project structure. Then identify the exact issue. Do not make random changes. Do not remove existing working code. Fix only the required files.
My requirement:
Keycloak must be the central identity system. Email, name, and user identity should come from Keycloak. All user-specific features should save and read data using Keycloak user ID.
Before editing:
1. Find related routes.
2. Find controller methods.
3. Find models and migrations.
4. Find Blade/API usage.
5. Explain the current flow.
After editing:
1. Show changed files.
2. Explain every change.
3. Run syntax checks where possible.
4. Give testing steps.
5. Tell me if any migration or env change is required.
Follow Laravel best practices and write clean, SonarQube-friendly code.
Step 19: Useful Laravel Commands After Claude Makes Changes
After Claude edits code, run these commands manually.
Clear cache:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
Check routes:
php artisan route:list
Check PHP syntax for a specific file:
php -l app\Http\Controllers\YourController.php
Run migration if Claude created a migration:
php artisan migrate
Start local server:
php artisan serve
If you are using XAMPP Apache, you may test directly from your local configured URL instead of php artisan serve.
Step 20: Git Workflow with Claude Code
Before asking Claude to change files, always check Git status:
git status
Create a safe branch:
git checkout -b fix-keycloak-userid-flow
Then start Claude:
claude
After Claude changes files, check:
git status
Review file differences:
git diff
Add files:
git add .
Commit:
git commit -m "Fix Keycloak user ID flow for student feature"
Push manually:
git push origin fix-keycloak-userid-flow
This keeps your work safe and reviewable.
Common Problems and Solutions
Problem 1: claude Is Not Recognized
Error:
'claude' is not recognized as an internal or external command
Reason:
Claude is installed, but its folder is not added to PATH.
Solution:
dir "%USERPROFILE%\.local\bin"
If claude.exe exists, add this folder to PATH:
%USERPROFILE%\.local\bin
Then reopen CMD and test:
where claude
claude --version
Problem 2: Claude Exists but where claude Shows Nothing
Reason:
Windows cannot search the Claude install folder because PATH does not include it.
Solution:
Run direct test:
"%USERPROFILE%\.local\bin\claude.exe" --version
If this works, add PATH permanently:
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$claudePath = "$env:USERPROFILE\.local\bin"
if (($userPath -split ';') -notcontains $claudePath) {
[Environment]::SetEnvironmentVariable("Path", "$claudePath;$userPath", "User")
}
Close and reopen terminal.
Problem 3: PowerShell Shows >>
Reason:
PowerShell is waiting for you to complete an unfinished command.
Solution:
Press:
Ctrl + C
Then paste the full command again.
Problem 4: PATH Truncated After setx
Warning:
WARNING: The data being saved is truncated to 1024 characters.
Reason:
setx can truncate long PATH values.
Solution:
Avoid:
setx PATH "%USERPROFILE%\.local\bin;%PATH%"
Use the PowerShell environment method instead:
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$claudePath = "$env:USERPROFILE\.local\bin"
if (($userPath -split ';') -notcontains $claudePath) {
[Environment]::SetEnvironmentVariable("Path", "$claudePath;$userPath", "User")
}
Problem 5: Claude Works in One Terminal but Not Another
Reason:
The old terminal does not know about the updated PATH.
Solution:
Close all terminals:
CMD
PowerShell
VS Code terminal
Git Bash
Open a new CMD and test:
where claude
claude --version
Problem 6: Claude Installed in .local\bin, Not npm Folder
In your machine, this folder had Claude:
C:\Users\ashwa\.local\bin
And this folder did not have Claude:
C:\Users\ashwa\AppData\Roaming\npm
So your correct PATH is:
%USERPROFILE%\.local\bin
Not:
%USERPROFILE%\AppData\Roaming\npm
unless you install Claude using npm later.
Recommended Daily Workflow
Use this workflow for your Laravel coding tasks.
Open CMD:
cd C:\xampp\htdocs\devopsschool\ds-student-ms
Check Git:
git status
Start Claude:
claude
Ask Claude to analyze first:
Analyze the current issue. Do not edit files yet. First explain the route, controller, model, Blade file, and database flow.
Then ask Claude to fix:
Apply the fix now. Keep changes small and safe. Do not break existing logic. After editing, show changed files and testing steps.
After Claude completes work, test manually:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan route:list
Review changes:
git diff
Commit manually:
git add .
git commit -m "Fix student feature with Keycloak user ID"
Best Practices for Using Claude Code Safely
Claude Code is powerful, but you should use it carefully in real projects.
Follow these rules:
Always use Git before making changes.
Always ask Claude to analyze before editing.
Do not allow large random refactoring.
Do not ask Claude to change many modules at once.
Keep one feature per session.
Review git diff before committing.
Run Laravel commands after changes.
Test login, form submit, validation, and database save flow manually.
Do not expose secrets from .env.
Do not paste production passwords or API keys.
Anthropicโs Claude Code product page notes that Claude Code runs locally in the terminal and asks for permission before making file changes or running commands. (Claude) Even then, you should still review all changes before committing.
Complete Setup Summary
Here is the full setup in simple order:
Install Git for Windows
Install Claude Code using official command
Check claude --version
Find Claude using dir "%USERPROFILE%\.local\bin"
Confirm claude.exe exists
Add %USERPROFILE%\.local\bin to User PATH
Close all terminals
Open new CMD
Run where claude
Run claude --version
Go to Laravel project
Run claude
Create CLAUDE.md
Ask Claude to analyze project
Then ask Claude to fix one feature at a time
Review git diff
Test locally
Push manually
Final Working Commands for Your Machine
Because your Claude executable is here:
C:\Users\ashwa\.local\bin\claude.exe
your final PATH should include:
%USERPROFILE%\.local\bin
Your test command:
where claude
Expected output:
C:\Users\ashwa\.local\bin\claude.exe
Your version check:
claude --version
Your project command:
cd C:\xampp\htdocs\devopsschool\ds-student-ms
claude
Conclusion
Setting up Claude Code Agent on a local Windows machine is straightforward, but most problems happen because of PATH configuration. In your case, Claude was already installed successfully inside:
C:\Users\ashwa\.local\bin
The main issue was that Windows could not find claude.exe from other folders. After adding:
%USERPROFILE%\.local\bin
to the User PATH, the claude command can be used from anywhere.
Once Claude Code is working, it becomes very useful for Laravel, XAMPP, Keycloak, and full-stack coding tasks. The best workflow is to let Claude analyze the project first, then allow it to fix one feature at a time, review the changes using Git, test locally, and only then push manually to GitHub.
