Agents should detect shell type and prefer editor tools over terminal

Feature request for product/service

Cursor IDE

Describe the request

Agents routinely **ignore the user’s actual shell environment** and **build complex terminal scripts instead of using built-in editor tools** (Read, Write, StrReplace). This causes excessive Run prompts, encoding bugs, and forces babysitting — the opposite of what agent automation should deliver.

### Problem 1: Agents don’t detect or respect the platform shell

My terminal runs **PowerShell 7** (`pwsh`). Agents consistently:

- **Invoke `powershell` (5.1)** instead of using the active PS7 session directly — spawning an unnecessary subprocess with different defaults (PS5.1 writes UTF-8 with BOM, breaking files).

- **Use POSIX commands** (`head`, `grep`, `cat`, `tail`) that aren’t native PowerShell — they sometimes work via aliases but break in scripts and don’t compose with PS pipelines.

- **Use `cmd /c “dir …”`** on Windows instead of `Get-ChildItem`.

- **Use `Get-Date -Format`** (locale-sensitive) instead of `Get-Date -UFormat` (locale-independent) — documented anti-pattern in my rules, yet agents keep doing it.

The system prompt tells agents `Shell: powershell` but doesn’t expose the **version** (5.1 vs 7.x) or whether it’s `powershell.exe` or `pwsh`. Agents default to lowest-common-denominator patterns.

### Problem 2: Agents build shell scripts instead of using editor tools

Cursor provides built-in file tools (Read, Write, StrReplace, Grep, Glob) that require **zero terminal approvals**. Yet agents routinely:

- Build `foreach` loops in PowerShell to insert a row in a markdown table — when `StrReplace` with the right anchor does the same thing with no Shell call.

- Use `[System.IO.File]::WriteAllText` or `New-Object System.Text.UTF8Encoding` instead of `Set-Content` (a PS cmdlet already on the allowlist).

- Split a script across multiple Shell tool calls (`$file = …` in one call, `$lines = Get-Content` in another, `Set-Content` in a third) — each triggering a separate Run prompt. **Why:** Cursor’s allowlist checks the *prefix* of each string submitted to the terminal. Lines starting with `$variable =` never match any allowlist entry, so every bare assignment is treated as an unknown command requiring manual approval. Wrapping the whole script in one `pwsh -NoProfile -Command “…”` block is the workaround — but agents don’t do this reliably either.

- Use `Add-Content` to append at the end of a file that has newest-first ordering — breaking the table.

I’ve documented anti-patterns and preferences in `.cursor/rules/` (always-apply), but LLM compliance is probabilistic — agents follow the rules *most* of the time, not *all* of the time.

### The babysitting cost

These patterns turn the user into a human “Run” button:

- A simple log entry that should use `StrReplace` (0 prompts) instead becomes a 3-step PowerShell script (3 prompts).

- A multi-line `foreach` block triggers 6+ per-line approvals because `$variable =` never matches the allowlist.

- Agents working in parallel on the same file produce **interleaved edits** with unpredictable results.

Users should not be forced to babysit agents. If I have to click Run 10 times for a table insert, the agent isn’t saving me time — it’s wasting it.

### Suggested improvements

1. **Expose shell type + version in the agent system prompt** — e.g. `shell: pwsh 7.5.1` instead of just `powershell`. This lets agents (and rules) target the right syntax.

2. **Add an agent-level preference: “prefer editor tools over terminal”** — a setting or system prompt hint that tells agents to use Read/Write/StrReplace for file operations before reaching for Shell. This would drastically reduce unnecessary terminal commands.

3. **Add an agent-level preference: “prefer allowlisted commands”** — agents should check the Command Allowlist and prefer commands that will auto-run rather than inventing arbitrary shell sequences.

4. **Support a `.cursor/shell-conventions` config** that agents must follow — platform shell, forbidden patterns, cmdlet preferences. Currently rules can only *suggest*; platform-level enforcement would make it reliable.

5. **Single-invocation enforcement** — when an agent needs Shell, guide it to emit one `powershell -NoProfile -Command “…”` block rather than multiple bare calls.

### Related forum threads

- [Agent uses PowerShell when Cmd is default]( Agent/Model Tries Using PowerShell Commands when Cmd is the Default Terminal ) — Dean Rie confirmed known bug: Windows defaults to PowerShell for agent regardless of user’s default terminal

- [Composer 2 Fast — many Run/Skip prompts]( 'Composer 2 Fast' prompting to approve most, if not all, of its internal workings ) — 64 views; multiple users report excessive approval prompts

- [Agent uses PowerShell when Cmd is default]( Agent/Model Tries Using PowerShell Commands when Cmd is the Default Terminal ) — Dean Rie confirmed known bug: Windows defaults to PowerShell for agent regardless of user’s default terminal

- [Composer 2 Fast — many Run/Skip prompts]( 'Composer 2 Fast' prompting to approve most, if not all, of its internal workings ) — 64 views; multiple users report excessive approval prompts

- [PS5.1 used despite PS7 default profile]( Cursor keeps using old Microsoft PowerShell ) — Colin: PATH ordering workaround

- [Agent ignores default terminal profile]( IDE Agent ignores terminal.integrated.defaultProfile.windows -- always uses PowerShell even with Nushell/Bash configured ) — 76 views

- [Agent CLI hardcoded to PowerShell, no config option]( Agent CLI on Windows: No way to configure shell (hardcoded to PowerShell, no --shell flag or config option) )

- [Non-interactive shell config documentation missing]( Cursor terminal documentation missing non-interactive agent shell configuration guidance ) — mohitjain (staff)

- [Agent uses terminal commands instead of edit\_file tool]( Agent not calling edit_file tool, instead generating custom terminal commands for file editing ) — Dean Rie: awaited details; closed

- [Agent edits with Python/shell instead of tools]( Editing with code instead of tools ) — Dean Rie: investigating

1 Like