claude-code - 💡(How to fix) Fix Add /edit command to open files in external editor from CLI [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48525Fetched 2026-04-16 06:57:44
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2

Fix Action

Fix / Workaround

Current Workarounds

  • ! open -e <file> (macOS TextEdit, doesn't wait)
  • ! code <file> (VS Code, if installed)
  • Switching to external terminal
  • Asking Claude to make edits via Edit tool

Code Example

/edit ~/.claude/statusline-command.sh
RAW_BUFFERClick to expand / collapse

Feature Request

Add a /edit <file> command to the Claude Code CLI that opens files in the user's preferred external editor.

Use Case

When working in the Claude Code CLI, users often need to make manual edits to files (config files, scripts, etc.). Currently, there's no built-in way to open a file in an editor from within the conversation. Users must either:

  • Switch to another terminal window
  • Ask Claude to make the edits (which can be cumbersome for complex multi-line changes)

Proposed Behavior

/edit ~/.claude/statusline-command.sh

This would:

  1. Open the file in the user's configured editor (respecting $EDITOR or a Claude Code setting)
  2. Wait for the user to save and close the editor
  3. Return control to the Claude Code conversation
  4. Optionally show a diff of what changed

Current Workarounds

  • ! open -e <file> (macOS TextEdit, doesn't wait)
  • ! code <file> (VS Code, if installed)
  • Switching to external terminal
  • Asking Claude to make edits via Edit tool

Related Issues

  • #41753 - Plan editor $EDITOR support (closed/not planned, but related concept)
  • #42222 - Desktop app editor dropdown (different platform)

Platform

macOS (but would benefit all platforms)

extent analysis

TL;DR

Implementing a /edit <file> command in the Claude Code CLI to open files in the user's preferred external editor is likely to involve integrating with the system's default editor or respecting the $EDITOR environment variable.

Guidance

  • Investigate how to use the $EDITOR environment variable to open files in the user's preferred editor, potentially using a subprocess or child process to wait for the editor to close.
  • Consider the security implications of executing external editors and ensure that the implementation does not introduce vulnerabilities.
  • Look into existing libraries or frameworks that provide a way to interact with external editors, such as opening a file and waiting for changes.
  • Evaluate the feasibility of adding a Claude Code setting to configure the preferred editor, in case the $EDITOR variable is not set.

Example

# Example of how to open a file in the default editor using $EDITOR
editor=$(echo $EDITOR)
$editor ~/.claude/statusline-command.sh

Notes

The implementation may vary depending on the specific requirements and constraints of the Claude Code CLI, such as handling errors, supporting multiple platforms, and integrating with the existing conversation flow.

Recommendation

Apply a workaround by utilizing the $EDITOR environment variable to open files in the user's preferred editor, as this approach is likely to be more feasible and secure than implementing a custom editor integration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Add /edit command to open files in external editor from CLI [2 comments, 2 participants]