Do not symlink .claude into the project directory - #181
Merged
Conversation
symlink-project links every top-level entry except web/, vendor/, .ddev/ and .idea/. Claude Code stores its state in .claude/, including git worktrees under .claude/worktrees/ — each a full checkout of the project with its own vendor/. On one Drupal module that made the symlinked tree 20,047 PHP files and ~300 MB, where the module itself has 108. Anything pointed at web/modules/custom/<project> then walks all of it. The first symptom was 'ddev phpcs' being OOM-killed with exit 137 rather than reporting anything, which reads as a broken tool rather than a tree that should never have been in scope. .claude belongs with .idea: a tool's own directory that happens to sit in the project root and is not part of the project. Verified on a real module — .claude is no longer linked, every module file still is, and the PHP file count under the symlinked path drops from 20,394 to 108. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
weitzman
force-pushed
the
ignore-claude-dir
branch
from
August 25, 2026 02:50
8a25932 to
89d451a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
symlink-projectlinks every top-level entry intoweb/modules/custom/<project>/exceptweb,vendor,symlink_project.php,.ddevand.idea:https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/symlink-project#L18
Claude Code stores its state in
.claude/, and that includes git worktrees under.claude/worktrees/— each one a full checkout of the project, with its ownvendor/. So.claudegets symlinked in, and anything pointed atweb/modules/custom/<project>walks all of it.On one Drupal module I measured:
.phpfiles.claudetestssrc.claudewas ~300 MB.The first symptom was
ddev phpcsdying with exit 137 (OOM-killed) instead of reporting anything — it passes$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATHas a path argument, which overrides the<file>list in the project'sphpcs.xml.dist. That reads as a broken tool rather than as a tree that should never have been in scope, and it took a while to trace back to here.ddev phpstanandddev phpunitare unaffected, since both are scoped by their own config rather than by that path.This is only going to get more common as more Drupal contributors run Claude Code.
The change
One more
--ignore..claudebelongs in the same category as.idea: a tool's own directory that happens to sit in the project root and is not part of the project.Verification
Applied to a real module's copy of the command and re-ran
ddev symlink-project:.claudeno longer appears inweb/modules/custom/<project>/src,config,tests,*.info.yml, …)find -L web/modules/custom -name '*.php' | wc -ldrops from 20,394 to 108ddev phpcscompletes in ~2s over 34 files instead of being killedPossibly worth a follow-up
.vscodeis a comparable gap next to.idea, though it is small and carries no PHP, so it causes nothing like this. I left it out to keep the change to the actual bug.