Pycharm

From G1Joshi/Agent-Skills · View interactive version

Pycharm is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert PyCharm assistance covering Python interpreters, virtualenv/Poetry/Conda management, scientific notebooks, remote debugging, and database integrations. Use when configuring PyCharm interpreters, setting up pytest test configurations, tuning IDE performance, or debugging Python applications.

How to use this skill

Skill file

PyCharm

PyCharm is the best IDE for serious Python development. It excels in Django support, Data Science (Jupyter), and virtualenv management.

When to Use

Quick Start

1. Launch via Terminal

# Open directory in PyCharm
pycharm .

2. Configure Poetry / Virtualenv Interpreter

# Ensure local virtualenv exists
poetry install
poetry env info --path
# Point PyCharm to .venv/bin/python

Core Concepts

Configuring Poetry / Conda Remote Virtual Environments

Setting up modern Python packaging and interpreter synchronization via pyproject.toml:

[tool.poetry]
name = "enterprise-api"
version = "0.1.0"
description = "FastAPI Enterprise Service"
authors = ["Engineering Team <eng@example.com>"]

[tool.poetry.dependencies]
python = "^3.12"
fastapi = "^0.111.0"
uvicorn = {extras = ["standard"], version = "^0.30.0"}
pydantic = "^2.7.0"
sqlalchemy = "^2.0.30"

[tool.poetry.group.dev.dependencies]
pytest = "^8.2.0"
ruff = "^0.4.0"
mypy = "^1.10.0"

Configure PyCharm Interpreter:

  1. Open Settings -> Project -> Python Interpreter.
  2. Click Add Interpreter -> Add Local Interpreter... -> Select Poetry Environment.
  3. Select Python 3.12 executable path.

Programmatic PyCharm Remote Debugger Setup

Connecting headless Python scripts or Docker containers to PyCharm's visual debugger:

# Install pydevd-pycharm in container: pip install pydevd-pycharm~=241.14494.241
import pydevd_pycharm

def enable_remote_debugging():
    try:
        pydevd_pycharm.settrace(
            'host.docker.internal',
            port=5678,
            stdoutToServer=True,
            stderrToServer=True,
            suspend=False
        )
        print("Connected to PyCharm Remote Debugger!")
    except ConnectionRefusedError:
        print("PyCharm Debugger not listening. Continuing normal execution.")

Fast Code Quality Inspections with Ruff Integration

Configuring Ruff as the primary linter and formatter inside PyCharm:

// External Tools or Ruff Plugin configuration
// Settings -> Tools -> File Watchers -> Add Ruff
{
  "program": "$ProjectFileDir$/.venv/bin/ruff",
  "arguments": "check --fix $FilePath$",
  "workingDir": "$ProjectFileDir$"
}

Common Patterns

Remote Docker Compose Interpreter

Problem: Application dependencies require system libraries or services running inside Docker.

Solution: Configure Docker Compose as remote interpreter in PyCharm Professional.

# docker-compose.yml
services:
  app:
    build: .
    volumes:
      - .:/app
    environment:
      - PYTHONUNBUFFERED=1
    ports:
      - "8000:8000"

Automated File Watcher Configuration

Problem: Automatically format and lint Python files on save with Ruff.

Solution: Define File Watcher configuration in PyCharm.

# Arguments for Ruff File Watcher
format --stdin-filename $FilePath$ -

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| ------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |

| No module named '...' inside PyCharm terminal | PyCharm internal terminal opened outside the project virtualenv | Verify Settings > Tools > Terminal > Activate virtualenv is checked; manually run source .venv/bin/activate. |

| Unresolved reference inspection on local packages | Root source directories not marked as Sources Root | Right-click src or root folder > Mark Directory as > Sources Root. |

| PyCharm sluggish during large indexing | Indexing .venv, node_modules, or data directories | Right-click cache or data directory > Mark Directory as > Excluded. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.