Understanding what context gets sent to Claude and how to control it.
Important: claude-code-mode itself does NOT automatically send context to Claude. It only sets up the infrastructure to enable context sharing when you actively use Claude Code commands.
If you're using Monet integration:
- Current selection is automatically shared when you select text
- Diagnostics (errors/warnings) from the current file are sent
- File metadata (name, cursor position) when you switch files
Without Monet, context is only sent when you explicitly:
- Run
claude-code-send-region- sends selected text or entire buffer - Run
claude-code-send-command-with-context- sends filename and line number - Run
claude-code-send-buffer-file- sends the entire file - Run
claude-code-fix-error-at-point- sends error details and surrounding code
Important safeguards built into the system:
- Project Boundaries: Claude Code uses Emacs built-in
project.elwhich works with most version control systems - Claude only has access to files within the detected project - Explicit Commands: Most context sharing requires deliberate action on your part
- No Background Monitoring: The mode doesn't continuously stream your keystrokes or file contents
;; Enable the mode but don't use Monet
(claude-code-mode 1)
;; This gives you commands but no automatic context sharing;; Use buffer size limits to prevent accidentally sending large files
(setq claude-code-large-buffer-threshold 50000) ; Confirm before sending files >50KB
;; Disable automatic context in commands
;; Always use claude-code-send-command instead of claude-code-send-command-with-context;; Don't enable global mode - only enable per-project
(add-hook 'some-specific-project-hook 'claude-code-mode)
;; Don't use Monet integration
;; Rely only on explicit copy/paste workflows| Scenario | What Gets Sent | When |
|---|---|---|
| Mode enabled only | Nothing | Never (just enables commands) |
| With Monet | Selection, diagnostics, file metadata | Automatically when you select text or change files |
| Manual commands | Only what you explicitly send | When you run send commands |
| Large files | Prompts for confirmation | When buffer exceeds threshold |
- Enable mode but skip Monet
- Use small thresholds for buffer size warnings
- Rely on manual
claude-code-send-commandwithout context
- Use the standard setup with reasonable buffer size limits
- Review what you're sending with
claude-code-send-regionbefore sending
- Full Monet integration for seamless context sharing
- Higher buffer size thresholds
- Trust the project boundary protections
;; Enable Monet globally (for the IDE protocol infrastructure)
(monet-mode 1)
;; But control Claude Code mode per-project
(defun my-enable-claude-for-project ()
(when (my-project-approved-p)
(claude-code-mode 1)))Pros: Monet always ready, but context only shared in approved projects
;; Enable both together only in approved projects
(defun my-enable-claude-with-monet ()
(when (my-project-approved-p)
(claude-code-mode 1)
(monet-mode 1)))Pros: Tighter security boundary, no network servers in unapproved projects Cons: Startup delay when first activating in a project
When Monet is enabled but Claude Code mode is not:
- WebSocket server is running (localhost only)
- No automatic context sharing occurs
- Claude Code commands are not available
- IDE protocol infrastructure is ready but inactive
The actual context sharing depends on which features you use and how you configure them. claude-code-mode is just the enabling infrastructure - you maintain full control over what gets sent to Claude through your choice of commands and Monet activation strategy.