AI Tools

Claude Code in PhpStorm: setup, the plugin and the habits that work

Claude Code runs as an agent in PhpStorm's terminal. Here is how to set up the CLI and plugin, and the habits that make it work for me: being specific, small steps, reviews and tests Claude runs itself.

Erik van de Blaak
Erik van de Blaak
7 min read • 1,700 views
Claude Code in PhpStorm: setup, the plugin and the habits that work

Claude Code is not autocomplete peeking over your shoulder in the editor. It is an agent: you start it in your project folder, it reads the code, edits files and runs commands such as your test suite or git. PhpStorm has a built-in terminal, so the two fit together naturally. I have been using Claude Code intensively in PhpStorm for months on my PHP projects. Here is how to set it up, what the JetBrains plugin adds, and which habits make the difference for me.

As of September 2026. Claude Code updates often; shortcuts and menu names may move.

What is Claude Code?

Claude Code is Anthropic's coding agent. You describe what you want in plain language, and Claude finds the relevant files, proposes or applies changes, and checks the result with commands you allow. It runs in the terminal, as an extension in VS Code and JetBrains IDEs, in a desktop app and in the browser. You need a paid Claude plan (Pro, Max, Team or Enterprise) or an API account through the Claude Console.

The difference from a chat window: you don't copy and paste code. Claude opens the files that matter by itself.

Installing Claude Code in PhpStorm

You need two pieces: the command-line tool itself and the PhpStorm plugin. The plugin does not bundle the CLI; it talks to it.

1. Install the CLI. On Windows, in PowerShell:

irm https://claude.ai/install.ps1 | iex

On macOS, Linux or WSL:

curl -fsSL https://claude.ai/install.sh | bash

2. Install the plugin. In PhpStorm, go to Settings → Plugins → Marketplace, search for Claude Code [Beta] and restart the IDE.

3. Start a session. Open PhpStorm's terminal in your project root and type claude. The first time, you log in with your Claude account. After that you can also launch Claude Code with Ctrl+Esc (Windows/Linux) or Cmd+Esc (Mac). Prefer a separate terminal? Run /ide there to connect it to PhpStorm.

One setting saves a lot of irritation. In PhpStorm's terminal, Esc moves focus back to the editor by default, while Claude Code uses Esc to interrupt an action. Under Settings → Tools → Terminal, untick Move focus to the editor with Escape.

What the plugin adds to the terminal

Claude Code works in PhpStorm's terminal without the plugin. The plugin makes it a lot more pleasant:

  • Changes open in PhpStorm's diff viewer. You review an edit the way you review a commit, side by side with syntax highlighting, instead of as text in the terminal.
  • Your selection comes along automatically. Select a method in the editor and ask "why is this slow?" in the terminal. Claude knows which lines you mean.
  • File references with a shortcut. Alt+Ctrl+K (Mac: Cmd+Option+K) inserts a reference such as @src/Service/InvoiceService.php#L40-88 into your prompt.
  • Claude can read PhpStorm's inspections. Syntax errors and warnings that PhpStorm shows in the editor are available to Claude. It doesn't fetch them automatically after every edit, so feel free to ask.

That removes exactly the friction that bothered me about AI chat windows: no switching windows, no pasting code back and forth.

Be careful with sensitive files. If you have a .env open, your selection can travel along. A deny rule for that path in Claude Code's permission settings prevents that. Anthropic also warns that in the mode where Claude applies edits without asking, it can change IDE configuration files too. So let it ask before editing unless you know what you're doing.

What a session looks like for me

I use Claude Code for a range of work: refactoring legacy code, writing complex database queries. The pattern is always the same. I describe the problem or feature, Claude writes the code and explains why it made certain choices. Those explanations have helped me recognise better patterns.

For larger changes I let Claude read first and write later. That is what plan mode is for: press Shift+Tab until the status line shows plan mode on. Claude then reads files and answers questions, but changes nothing. Say you want to split up a six-hundred-line controller with SQL inside it. In plan mode you let Claude work out which other classes call those queries and what it proposes. Only when the plan holds up do you let it build.

Four habits that make the difference

Be specific, and write down fixed rules once

The more precisely you describe what you want, the better the result. Mention the PHP version, the framework and the coding standard. "Add validation" gets you something different from "in StoreOrderRequest, validate that quantity is an integer between 1 and 99, and write a test for it".

Whatever applies to every request, you shouldn't have to type every time. The /init command creates a CLAUDE.md in your project, a file Claude reads at the start of every session. Put your PHP version in it, how to run the tests and the conventions of your codebase. Keep it short: Anthropic itself notes that Claude is more likely to ignore instructions in a file that is too long.

Work in small pieces

Don't ask Claude for a complete application. I split tasks into logical parts: data model first, then the service, then the controller. The result is better and you can still genuinely review each step.

There is a technical reason too. Everything Claude reads in a session takes up room in its context window, and as it fills up, quality drops. Run /clear when you start a task that has nothing to do with the previous one.

Let Claude review your code

Ask for feedback on a piece of code. The suggestions are often surprisingly sharp and have helped me write cleaner code. In Claude Code you don't paste anything: select the code in PhpStorm or point to the file.

A review works better in a fresh session than in the one where Claude just wrote the code. A new session isn't biased towards its own work.

Let Claude write tests, and let it run them

Writing unit tests takes time. Claude Code produces useful test cases from your existing code, which you then refine. That refining is not a formality: a test written after the fact for existing code pins down current behaviour, bugs included.

The biggest gain is that Claude can run those tests itself. Add: "then run vendor/bin/phpunit and fix any failures". Anthropic puts this at the top of its own best-practices guide: without a check Claude can run, it stops as soon as the work looks done, and you are the one who has to find every mistake.

What it gets me

The productivity gain is noticeable. Tasks that used to take me hours now take a fraction of that time. More important to me is that my code has improved: Claude thinks along about edge cases, suggests better names and flags problems before they turn into bugs.

Claude Code doesn't feel like a replacement for my skills but like an amplifier. It's like having an experienced colleague next to you who always has time for a second opinion. And because it runs inside PhpStorm, I keep everything I'm used to in my IDE: inspections, the debugger, version control.

If you want to try it, don't start with a new feature. Open a project you know well and ask Claude to explain a class you haven't touched in a year. If the explanation is right, have it write and run a test for it. Within fifteen minutes you'll know whether you trust it with a refactor.

Share this article

Erik van de Blaak

Written by

Erik van de Blaak

AI Solutions Engineer & Full-Stack Developer

Erik van de Blaak is an AI Solutions Engineer and full-stack developer at CareerValue BV. Here he writes about AI coding tools and agents, such as Claude Code.

Comments (0)

Comment on this article

Never published

I read every comment before it goes online.

No comments on this article yet.

Read next