claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Write tool creates directories with incorrect permissions (doesn't inherit from parent)

Open b-hayes opened this issue 3 months ago • 3 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Write tool creates new files and directories with default permissions (755 for directories, 644 for files) instead of inheriting permissions from the parent directory.

This seems to be a new problem. Ive made a point to make sure new files get the right permissions and this happens correctly if creating files with my IDE or any other tool. But Claude code has recently been creating files with specific permissions that do not work for my applications.

What Should Happen?

It should just create files with the defaults assigned by the file system.

When creating files/directories in a parent with specific permissions and setgid bit, the new files should inherit:

  • The parent's group ownership (via setgid)
  • Similar permission modes as sibling files/directories
  • Any ACLs set on the parent directory

Error Messages/Logs

No errors, just the constant annoyance of having to fix permissions for every file and folder Claude code creates.

Steps to Reproduce

  1. Create a test directory with setgid bit and restrictive permissions:

    mkdir -p /tmp/test-permissions/parent
    chmod 2770 /tmp/test-permissions/parent
    chgrp www-data /tmp/test-permissions/parent
    
  2. Verify the parent directory has correct permissions:

    ls -la /tmp/test-permissions/
    # Should show: drwxrws--- ... www-data ... parent
    
  3. Manually create a subdirectory to confirm inheritance works:

    mkdir /tmp/test-permissions/parent/manual-dir
    ls -la /tmp/test-permissions/parent/
    # Should show: drwxrws--- ... www-data ... manual-dir (inherits correctly)
    
  4. Ask Claude Code to create a file in the parent directory:

    "Please create a file at /tmp/test-permissions/parent/test.txt with the content 'test'"
    
  5. Ask Claude Code to create a directory:

    "Please create a directory at /tmp/test-permissions/parent/claude-dir/"
    
  6. Check the permissions of files created by Claude:

    ls -la /tmp/test-permissions/parent/
    # Claude-created file shows: -rw-r--r-- (644 - wrong, should be 660)
    # Claude-created dir shows: drwxr-xr-x (755 - wrong, should be 2770)
    

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.0.45 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Jetbrains ide terminal.

Additional Information

No response

b-hayes avatar Nov 19 '25 01:11 b-hayes

Why did the anthropic team not immediately rollback critically broken claude-code with such a catastrophic bug?

em avatar Nov 24 '25 01:11 em

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 24 '25 10:12 github-actions[bot]

Hi. This issue is still occurring with v2.0.76

LeoWare avatar Dec 26 '25 23:12 LeoWare

This issue has been fixed in PR anthropics/claude-cli-internal#12383 (commit 80e16ef323).

The fix removes hardcoded permissions (0o600 for files, 0o700 for directories) and now respects the system umask for user-created files. With umask 022, files will now be created with 644 permissions (-rw-r--r--) instead of 600 (-rw-------).

The fix has been merged and will be available in the next release.

whyuan-cc avatar Dec 30 '25 03:12 whyuan-cc

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Jan 06 '26 14:01 github-actions[bot]