Lesson 27 of 30 ~15 min
Course progress
0%

JetBrains IDE Integration

Integrace Claude s IntelliJ IDEA, PyCharm, WebStorm a dalšími JetBrains IDE.

JetBrains IDE nabízejí silné nástroje pro vývoj. Kombinace s Claude vytváří powerhouse produktivity.

JetBrains AI Assistant vs Claude

FeatureJetBrains AIClaude Opus
Inline suggestions✅ Native⚠️ External
Deep reasoning⚠️ Limited✅ Excellent
Context windowLimited200K tokens
IDE integration✅ Perfect⚠️ Manual
Complex refactoring⚠️ Basic✅ Advanced

Strategie: JetBrains AI pro inline help, Claude pro komplexní úlohy.

External Tools Configuration

Nastavení Claude jako External Tool

Settings → Tools → External Tools → Add

Name: Ask Claude
Program: python3
Arguments: $ProjectFileDir$/scripts/ask-claude.py "$SelectedText$"
Working directory: $ProjectFileDir$

Keyboard shortcut

Settings → Keymap → External Tools → Ask Claude
Assign: Ctrl+Shift+C (nebo dle preference)

Live Templates

Code Review Template

Settings → Editor → Live Templates → New Group: Claude

Abbreviation: clrev
Template text:
"""
Review this code:
$SELECTION$

Focus on:
1. Bugs and edge cases
2. Performance
3. Security
4. Maintainability
"""

Explain Code Template

Abbreviation: clexp
Template text:
"""
Explain this code step by step:
$SELECTION$

Include:
- What each section does
- Why it's implemented this way
- Potential improvements
"""

Scratches pro Claude Workflows

JetBrains Scratches jsou perfektní pro Claude interakci:

# Scratches/claude-workspace.py

from anthropic import Anthropic

client = Anthropic()

# Paste code here
CODE = """
def mystery_function(data):
    result = []
    seen = set()
    for item in data:
        key = item.get('id')
        if key not in seen:
            seen.add(key)
            result.append(item)
    return result
"""

response = client.messages.create(
    model="claude-opus-4-5-20250101",
    max_tokens=2000,
    messages=[{
        "role": "user",
        "content": f"Explain what this function does:\n\n{CODE}"
    }]
)

print(response.content[0].text)

Database Tool Integration

Pro práci s databázemi v DataGrip/IntelliJ:

# scripts/explain-query.py
import sys
from anthropic import Anthropic

query = sys.argv[1]

client = Anthropic()
response = client.messages.create(
    model="claude-opus-4-5-20250101",
    max_tokens=2000,
    messages=[{
        "role": "user",
        "content": f"""Explain this SQL query:

```sql
{query}

Include:

  1. What it does
  2. Performance considerations
  3. Potential optimizations""" }] )

print(response.content[0].text)


External Tool:

Name: Explain SQL Program: python3 Arguments: $ProjectFileDir$/scripts/explain-query.py “$SelectedText$“


## Run Configuration pro Claude Scripts

```xml
<!-- .idea/runConfigurations/Claude_Review.xml -->
<component name="ProjectRunConfigurationManager">
  <configuration name="Claude Review" type="PythonConfigurationType">
    <module name="your-project" />
    <option name="SCRIPT_NAME" value="$PROJECT_DIR$/scripts/claude-review.py" />
    <option name="PARAMETERS" value="$FilePath$" />
    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
  </configuration>
</component>

Plugin Development (Advanced)

Pro hlubší integraci můžete vytvořit vlastní plugin:

// src/main/kotlin/ClaudeAction.kt
class AskClaudeAction : AnAction() {
    override fun actionPerformed(e: AnActionEvent) {
        val editor = e.getData(CommonDataKeys.EDITOR) ?: return
        val selectedText = editor.selectionModel.selectedText ?: return
        
        // Call Claude API
        val response = ClaudeService.ask(selectedText)
        
        // Show in tool window
        ClaudeToolWindow.show(response)
    }
}

Workflow příklad

Refactoring session

  1. Identifikace - Vyberte code smell v IDE
  2. Analýza - Ctrl+Shift+C → Claude vysvětlí problém
  3. Plán - Claude navrhne refactoring strategii
  4. Implementace - Použijte IDE refactoring tools
  5. Review - Claude zkontroluje výsledek
IDE:     [Identify] → [Implement] → [Test]
              ↓            ↑           ↓
Claude:  [Analyze] → [Plan] → [Review]

Kombinace JetBrains IDE s Claude vám dává to nejlepší z obou světů.