---
name: format-and-lint
description: Format and lint Python code in the dev container with black, isort, and ruff. Use when the user asks to clean up code style, format files, or run a linter.
---

# Format & Lint

A fast, opinionated triple: `ruff` for linting, `black` for formatting,
`isort` for import order. Ruff alone can do most of this, but black+isort
is what the rest of this repo standardizes on (see `pyproject.toml`).

## 1. Install

```bash
pip install --quiet black isort ruff
```

## 2. Run on /app

```bash
cd /app && isort . && black . && ruff check .
```

`ruff check . --fix` will auto-apply safe fixes — only use it if the user
has asked you to modify their code, not just to report issues.

## 3. Check without modifying

For a dry run that surfaces issues without rewriting files:

```bash
cd /app && black --check . && isort --check-only . && ruff check .
```

A non-zero exit means at least one tool found something. Inspect the
output and report which tool flagged what.

## Notes

- Match the line length already configured in `pyproject.toml` if present
  (this project uses 88).
- Do not run formatters on files outside `/app` — the dev container's
  scratchpad volume is the only place code should live.
