Skip to main content
rule official · GitHub

no-heredoc — GitHub Copilot rule: no heredocs in the terminal

A rule that stops the agent from writing files through terminal heredocs and redirections, because those commands corrupt content in VS Code.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/instructions/no-heredoc.instructions.md
Open on GitHub

What no-heredoc does

Heredoc operations are broken in the VS Code Copilot integration. Tab characters fire shell completion, quote and backtick escaping fails, and the output gets cut off on exit code 130. The file ends up mangled or truncated, and you fix it by hand.

The rule takes precedence over any other learned behaviour. Before any command that creates or modifies a file, the agent has to stop and ask whether it is about to reach for cat, echo, printf, tee or >/>>. If yes, the command does not run; the environment's file editing tool does the work instead. New files are created with it, existing ones are patched with it, and deletion stays with rm.

The terminal is not banned outright. Package installs, builds, tests, git add and git commit, running existing code, filesystem navigation and downloads through curl or wget are all fine. Only heredoc syntax (<<) and multi-line redirections carrying content are off limits. Drop the rule file at .github/instructions/no-heredoc.instructions.md and it applies to every file in the project.

What it helps with

  • create a file with content without getting a corrupted copy
  • keep heredocs and multi-line redirections out of the agent's workflow
  • tell the agent when the terminal is still the right tool
  • protect configs and scripts from truncation on exit code 130
  • move file edits onto editing tools instead of the shell

Example prompts for the agent

  • create .env.example with these variables, not through the terminal
  • add a new build script to package.json
  • edit docker-compose.yml and add a redis service

How to install no-heredoc

Manually: put the files in place

.github/instructions/no-heredoc.instructions.md

The applyTo field sets which files it applies to

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about no-heredoc

How do I install no-heredoc in GitHub Copilot?

Place the rule file at .github/instructions/no-heredoc.instructions.md. It then applies to every file in the project.

What does no-heredoc do?

It blocks the agent from creating or modifying files through the terminal: cat, echo, printf, tee and redirections. File editing tools are used instead.

Which terminal commands are still allowed?

Package installs, builds, tests, git operations, running existing code, filesystem navigation, plus curl and wget when they are not writing content into a file.

Source text

no-heredoc.instructions.md · MIT
---
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: '**'
---

# 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

© github · MIT · github/awesome-copilot

Similar IDE rules

All IDE rules for Agent setup: memory, context, orchestration →

From the same set732

The whole set →
pcf-manifest-schema A rule that feeds Copilot the structure of ControlManifest.Input.xml: which elements and attributes exist and what they do. Useful when editing a PCF component manifest. ★ 40,418repo stars pcf-events A rule that tells Copilot how to declare and handle custom events in Power Apps Component Framework components. ★ 40,418repo stars pcf-code-components A rule that teaches Copilot how Power Apps code components are built: manifest, TypeScript implementation, resources. Useful when editing ControlManifest.Input.xml or index.ts. ★ 40,418repo stars oop-design-patterns A GitHub Copilot rule that steers code generation and refactoring toward GoF design patterns and SOLID principles in object-oriented code. ★ 40,418repo stars nestjs This rule feeds GitHub Copilot a set of NestJS conventions: modules, DI, DTOs and validation. Useful when the agent writes TypeScript server code. ★ 40,418repo stars moodle This rule tells Copilot how to write Moodle code: Frankenstyle namespaces, Mustache templates, mandatory security functions. Useful when you build plugins or themes. ★ 40,418repo stars langchain-python A GitHub Copilot instruction file that steers the agent toward LangChain patterns: Runnable, LCEL, chat models, retrievers and vector stores. Useful when your Python code talks to LangChain. ★ 40,418repo stars java-upgrade A rule that points Copilot at the java-upgrade skill whenever you change the Java version in Maven or Gradle files. Handy for LTS jumps. ★ 40,418repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor