Skip to content

Keep ruff out of the .claude worktrees - #38

Merged
gouwens merged 1 commit into
mainfrom
worktree-ruff-exclude-worktrees
Aug 31, 2026
Merged

gouwens merged 1 commit into
mainfrom
worktree-ruff-exclude-worktrees

Conversation

@gouwens

@gouwens gouwens commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #37. Running uv run --frozen ruff check from the repository root reports 181 errors — every one of them inside .claude/worktrees/, and none in the project itself.

Cause

Claude Code keeps its git worktrees under .claude/worktrees/, each a full copy of this repo at whatever commit it was cut from. Nine of them exist locally, and the ones predating #37 still contain the entire pre-format tree. Ruff was walking into all of them and reporting on a checkout that is not this checkout.

Nothing under .claude is gitignored — it is merely untracked — so ruff's usual .gitignore filtering never applied.

Why #37 did not catch it

Neither place the linter had run can see that directory:

  • the lint CI job runs against a fresh clone, which has no .claude/worktrees;
  • the adoption work itself was done from inside one of those worktrees, where the path does not exist either.

Only a run from the main checkout's root reaches it — which is exactly how it was found.

Fix

extend-exclude = [".claude/worktrees"]

Scoped to worktrees rather than all of .claude so a future .claude/*.py of our own stays in scope. The setting is inert in CI, where the directory is absent.

Verification

Run from the main checkout root, where the failure actually reproduced:

before after
ruff check 181 errors clean
ruff format --check — 39 files already formatted

On the branch itself: ruff check clean, 38 files formatted, 366 passed / 36 skipped.

🤖 Generated with Claude Code

Running `uv run --frozen ruff check` from the repository root reported 181
errors, every one of them inside .claude/worktrees/. Claude Code keeps its
git worktrees there, each a full copy of this repo at whatever commit it was
cut from, and the ones predating the ruff adoption still hold the entire
pre-format tree. Ruff was walking into all nine of them and reporting a
checkout that is not this checkout.

Nothing under .claude is gitignored -- it is merely untracked -- so ruff's
usual .gitignore filtering never applied to it.

This went unnoticed because neither place the linter had run so far can see
that directory: the CI job runs against a fresh clone, which has no
.claude/worktrees, and the adoption work itself was done from inside one of
those worktrees, where the path does not exist either. Only a run from the
main checkout's root reaches it.

Excluding just .claude/worktrees rather than all of .claude keeps a future
.claude/*.py of our own in scope. The setting is inert in CI, where the
directory is absent.

Verified from the main checkout root, where the failure actually reproduced:
`ruff check` clean and 39 files already formatted, against 181 errors before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gouwens
gouwens merged commit a4846d8 into main Aug 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant