-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add no-heredoc instructions to prevent terminal file corruption #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aaronpowell
merged 3 commits into
github:main
from
garrettsiegel:add-no-heredoc-instructions
Feb 5, 2026
+79
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| name: 'No Heredoc File Operations' | ||
| description: 'Prevents terminal heredoc file corruption in VS Code Copilot by enforcing use of file editing tools instead of shell redirections' | ||
| applyTo: '**' | ||
| --- | ||
aaronpowell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # MANDATORY: File Operation Override | ||
|
|
||
| This instruction applies to ALL agents and ALL file operations. It takes precedence over any other learned behavior. | ||
|
|
||
| ## The Problem | ||
|
|
||
| Terminal heredoc operations are BROKEN in VS Code's Copilot integration. They cause: | ||
|
|
||
| - File corruption from tab characters triggering shell completion | ||
| - Mangled content from quote/backtick escaping failures | ||
| - Truncated files from exit code 130 interruptions | ||
| - Garbage output from special character interpretation | ||
|
|
||
| ## The Rule | ||
|
|
||
| **BEFORE writing ANY terminal command that creates or modifies a file, STOP.** | ||
|
|
||
| Ask yourself: "Am I about to use `cat`, `echo`, `printf`, `tee`, or `>>`/`>` to write content to a file?" | ||
|
|
||
| If YES → **DO NOT EXECUTE.** Use file editing tools instead. | ||
|
|
||
| ## Forbidden Patterns | ||
|
|
||
| ```bash | ||
| # ALL OF THESE CORRUPT FILES - NEVER USE THEM | ||
| cat > file << EOF | ||
| cat > file << 'EOF' | ||
| cat > file <<EOF | ||
| cat > file <<'EOF' | ||
| cat > file <<-EOF | ||
| cat >> file << EOF | ||
| echo "multi | ||
| line" > file | ||
| printf '%s\n' "line1" "line2" > file | ||
| tee file << EOF | ||
| tee file << 'EOF' | ||
| ``` | ||
|
|
||
| ## Required Approach | ||
|
|
||
| Instead of terminal commands for file content: | ||
|
|
||
| - **New files** → Use the file creation/editing tool provided by your environment | ||
| - **Modify files** → Use the file editing tool provided by your environment | ||
| - **Delete files** → Use the file deletion tool or `rm` command | ||
|
|
||
| ## Terminal IS Allowed For | ||
|
|
||
| - `npm install`, `pip install`, `cargo add` (package management) | ||
| - `npm run build`, `make`, `cargo build` (builds) | ||
| - `npm test`, `pytest`, `go test` (testing) | ||
| - `git add`, `git commit`, `git push` (version control) | ||
| - `node script.js`, `python app.py` (running existing code) | ||
| - `ls`, `cd`, `mkdir`, `pwd`, `rm` (filesystem navigation) | ||
| - `curl`, `wget` (downloading, but not piping to files with content manipulation) | ||
|
|
||
| ## Terminal is FORBIDDEN For | ||
|
|
||
| - ANY file creation with content | ||
| - ANY file modification with content | ||
| - ANY heredoc syntax (`<<`) | ||
| - ANY multi-line string redirection | ||
|
|
||
| ## Enforcement | ||
|
|
||
| This is not a suggestion. This is a hard technical requirement due to VS Code terminal integration bugs. Ignoring this instruction will result in corrupted files that the user must manually fix. | ||
|
|
||
| When you need to create or edit a file: | ||
|
|
||
| 1. Stop before typing any terminal command | ||
| 2. Use the appropriate file editing tool | ||
| 3. The tool will handle the content correctly without corruption | ||
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.
Uh oh!
There was an error while loading. Please reload this page.