--- name: claude-code-handoff description: | Delegate buffer-editing work to the in-editor Claude Code session managed by `coder/claudecode.nvim`. Use whenever a request would *change code in a buffer*: refactor, generate, explain-and-edit, fix a diagnostic. Opens (or focuses) the Claude Code split, attaches the relevant buffer/selection, sends an instruction, and tells the user how to accept/reject the resulting diff. Avoids duplicating Claude Code's diff UX from outside the editor. Trigger on "refactor this", "fix this in nvim", "generate the function in this buffer", "have Claude edit my file", "send this to Claude in nvim", "let Claude in the editor handle it". disable-model-invocation: false allowed-tools: Bash, Read, Skill, AskUserQuestion --- # claude-code-handoff — let the in-editor Claude do the editing Owner: `nvim-agentic-companion:companion`. This skill is the bridge between *you* (the outer Claude Code session) and the **inner** Claude Code session running in the user's nvim via `coder/claudecode.nvim`. The inner session has the buffer, selection, diagnostics, project root, and the diff-accept/reject UI. It is the right tool for any edit that the user should review before it lands. ## When this skill fires - The user wants buffer contents *modified*: refactor, rename, fix, generate, complete, restructure. - The change is bigger than a one-line vim substitute the user could do themselves. - The user wants a diff to look at before committing. ## When this skill does *not* fire - Pure navigation (`editor-act`). - Pure questions about state (`editor-introspect`). - Edits to *config* files via the declarative NixVim path (those are yours to edit with the `Edit` tool, then run `nix run .#deploy`). ## The configured keymaps (current NixVim setup) These are defined under `a*` in `/home/oleks/projects/servers/emmett/nixos/neovim.nix`: | Mode | Keys | Command | Purpose | | ---- | -------------- | ----------------------------- | ----------------------------- | | n | `ac` | `:ClaudeCode` | Toggle the Claude Code split | | n | `af` | `:ClaudeCodeFocus` | Move cursor to the split | | n | `ar` | `:ClaudeCode --resume` | Resume previous session | | n | `aC` | `:ClaudeCode --continue` | Continue last session | | n | `ab` | `:ClaudeCodeAdd %` | Add current buffer to context | | v | `as` | `:ClaudeCodeSend` | Send visual selection | | n | `aa` | `:ClaudeCodeDiffAccept` | Accept the proposed diff | | n | `ad` | `:ClaudeCodeDiffDeny` | Reject the proposed diff | If the user remaps these, re-introspect via `editor-introspect` before quoting them. ## Handoff procedure 1. **Confirm the split is open.** Either ask `editor-introspect` to check for a Claude Code buffer/window, or just run `:ClaudeCode` via `mcp__neovim__nvim_command` — the command is idempotent (toggles, but if already visible the user sees no surprise). 2. **Attach the right context.** - If a buffer-level change: `:ClaudeCodeAdd %` (current buffer) or `:ClaudeCodeAdd ` (a specific file). - If a selection-level change: the user must have a visual selection. If they don't, ask them to make one, *or* offer `editor-act` to highlight the relevant range first. 3. **Send the instruction.** Phrase it as the user would speak to an agent that already has the file open. Example: instead of "in neovim.nix add a keymap for ...", say "add a `tw` keymap that toggles wrap, next to the existing wrap-toggle block." Send via `:ClaudeCodeSend` (after selection) or by typing the prompt into the Claude Code buffer (`mcp__neovim__nvim_command` plus an explicit feedkeys is overkill — usually the user can type it themselves once focus is in the split). 4. **Brief the user.** One sentence: where the conversation is happening (the split), what to expect (a proposed diff), and the accept/reject keys. Example: > Sent to the Claude Code split. You'll see a proposed diff — > `aa` to accept, `ad` to reject. 5. **Stop.** Don't try to mirror or predict the inner session's output. The user will come back with the result, and you can resume from there. ## Avoiding double-work If the user is already inside the Claude Code split typing to the inner session, **do not also try to do the edit yourself**. Either: - Stay quiet on the editing question and only handle introspection / navigation side requests, or - Acknowledge: "the inner Claude is on it — ping me back if it stalls or you want a second opinion." The whole point of the handoff is to avoid two agents editing the same buffer with different mental models.