[Feature Request] Add Configuration Option to Limit File Generation in Git Repos
Bug Description If a user has a git repo, dont create a ton of random variant files. It creates a mess the user has to clean up vs. just reverting to a prior commit. Honestly, you need a vibe coder vs. pro coder config switch for nonsense like this.
Environment Info
- Platform: win32
- Terminal: vscode
- Version: 1.0.113
- Feedback ID: 186a9e39-1622-4587-9c73-66b044b3c8b4
Errors
[{"error":"Error: Diagnostics file path mismatch: expected C:\\Users\\GFxAI\\Desktop\\GameFrame Agent.bat, got file://c:\\users\\gfxai\\desktop\\gameframe agent.bat/)\n at ZE.beforeFileEdited (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1886:18673)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Object.call (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1906:917)\n at async XZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:20655)\n at async s$B (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:17150)\n at async WZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:16013)\n at async YZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:15550)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:12654)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:13502)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:13502)","timestamp":"2025-09-15T15:35:02.907Z"},{"error":"AbortError: The operation was aborted\n at abortChildProcess (node:child_process:749:27)\n at AbortSignal.onAbortListener (node:child_process:819:7)\n at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)\n at AbortSignal.dispatchEvent (node:internal/event_target:762:26)\n at runAbort (node:internal/abort_controller:486:10)\n at abortSignal (node:internal/abort_controller:457:3)\n at AbortController.abort (node:internal/abort_controller:505:5)\n at Timeout._onTimeout (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3512:75)\n at listOnTimeout (node:internal/timers:588:17)\n at process.processTimers (node:internal/timers:523:7)","timestamp":"2025-09-15T15:35:03.921Z"},{"error":"Error: Diagnostics file path mismatch: expected C:\\Users\\GFxAI\\Desktop\\Run GameFrame Agent.ps1, got file://c:\\users\\gfxai\\desktop\\run gameframe agent.ps1/)\n at ZE.beforeFileEdited (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1886:18673)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Object.call (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1906:917)\n at async XZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:20655)\n at async s$B (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:17150)\n at async WZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:16013)\n at async YZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:15550)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:12654)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:13502)\n at async f$ (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:13502)","timestamp":"2025-09-15T15:35:13.453Z"},{"error":"Error: Diagnostics file path mismatch: expected C:\\Users\\GFxAI\\Desktop\\GameFrame Agent.bat, got file://c:\\users\\gfxai\\desktop\\gameframe agent.bat/)\n at ZE.beforeFileEdited (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1886:18673)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Object.call (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1901:620)\n at async XZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:20655)\n at async s$B (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:17150)\n at async WZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:16013)\n at async YZ5 (file:///C:/Users/GFxAI/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3274:15550)\n at async
Note: Error logs were truncated.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/7054
- https://github.com/anthropics/claude-code/issues/1342
- https://github.com/anthropics/claude-code/issues/6261
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Hey, fellow user here.
I've definitely run into that same issue where Claude gets a bit too creative and starts littering the directory with file_v1.js, file_v2.js, etc. It's especially annoying when you're trying to keep a clean git status.
After digging through the docs and playing around with the settings, I found a few ways to get that more controlled, "pro coder" behavior you're talking about, ranging from simple configuration to a more advanced scripting solution. Maybe some of these can help you too.
1. Use Plan Mode for More Control
This has been the biggest game-changer for me. Plan Mode lets Claude analyze the codebase and create a detailed plan of changes without actually writing or editing any files. You get to review the plan, ask for changes, and only when you're happy with it do you let it execute.
You can start a session in plan mode with a flag:
claude --permission-mode plan
Or, even better, you can make it the default for your project by adding this to your .claude/settings.json:
{
"permissions": {
"defaultMode": "plan"
}
}
This forces Claude to think through the entire solution first, which usually results in fewer, more precise file edits instead of a bunch of experimental files.
(Reference: Common Workflows - Use Plan Mode for safe code analysis)
2. Explicitly Deny New File Creation
If you want a really hard stop on new files, you can configure permissions to deny the Write tool. The Write tool is used for creating new files, while the Edit tool modifies existing ones.
You can add this to your .claude/settings.json to prevent Claude from creating new files, forcing it to only suggest edits to existing ones:
{
"permissions": {
"deny": [
"Write"
]
}
}
You can still have it create a file by temporarily removing that rule or just creating the empty file yourself and asking Claude to populate it (which would use the Edit tool).
(Reference: Settings - Tools available to Claude)
3. Guide Claude's Behavior with CLAUDE.md
You can also give Claude standing instructions in a CLAUDE.md file in your project root. This is more of a "soft" control, but it works surprisingly well.
I've added something like this to my project's CLAUDE.md:
# My Coding Preferences
- **File Modifications**: Do not create new files with variant names (e.g., `script_v2.js`, `test_final.js`). Always prefer to modify the existing file in place. If you need to experiment, describe the changes first.
- **Git Workflow**: When making changes, think in terms of a single, clean commit. Propose a set of changes that can be logically grouped together.
This helps steer it away from the "generate a ton of files" approach.
(Reference: Manage Claude's memory)
4. Use Hooks for Fine-Grained Control (Advanced)
This is the most powerful option. You can use a PreToolUse hook to run a script that intercepts any attempt to use the Write tool and programmatically block it if the file doesn't already exist. This creates an unbreakable rule that Claude has to follow.
Step 1: Create a hook script
Create a file like .claude/hooks/prevent-new-files.py:
#!/usr/bin/env python3
import json
import sys
import os
try:
# Read the data Claude Code sends to the hook
input_data = json.load(sys.stdin)
file_path = input_data.get("tool_input", {}).get("file_path", "")
# If the file path is empty, do nothing
if not file_path:
sys.exit(0)
# Block the operation if the file does NOT exist
if not os.path.exists(file_path):
# Print a message to stderr. Claude will see this and learn from it.
print(f"Policy Violation: Blocked creation of new file '{file_path}'. Please modify an existing file.", file=sys.stderr)
# Exit with code 2 to block the tool use
sys.exit(2)
# Allow the operation (overwriting an existing file)
sys.exit(0)
except Exception as e:
print(f"Hook script error: {e}", file=sys.stderr)
sys.exit(1) # Non-blocking error
Make sure the script is executable: chmod +x .claude/hooks/prevent-new-files.py.
Step 2: Configure the hook in .claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/prevent-new-files.py"
}
]
}
]
}
}
Now, whenever Claude tries to create a new file, the hook will block it and tell Claude why. It will be forced to find another way, like editing an existing file.
(Reference: Get started with Claude Code hooks)
Regarding the Errors
Looking at your error logs, that Diagnostics file path mismatch error seems to be a separate bug related to Windows path formats (C:\... vs file://c:/...). The changelog for version 1.0.106 mentions a fix for a similar Windows pathing issue. Since you're on 1.0.113, it's possible this is a regression or a new variant of that bug, especially since it's happening inside VS Code's integrated terminal. The AbortError suggests something is timing out or being cancelled, which could be a symptom of that pathing issue.
As a test, does the file creation problem still happen if you run claude from Git Bash directly, instead of the VS Code terminal? Sometimes the terminal environment makes a difference with those pathing issues.
Hope this helps you get a more predictable workflow! The combination of "Plan Mode" as the default and some clear instructions in CLAUDE.md has made a huge difference for me, and the hook is a great "nuclear" option if you need it.
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.