[BUG] Claude Code Misunderstands NotebookEdit Insert Operation

Resolved 💬 2 comments Opened Jun 17, 2025 by ZEKE320 Closed Jun 18, 2025

## Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: v1.0.25
  • Operating System: Ubuntu 22.04.5 LTS
  • Terminal: Cursor (Integrated Terminal)

## Bug Description
Claude Code misunderstands the NotebookEdit tool's insert operation. When asked to insert a cell after a specific cell, it incorrectly uses that cell's index instead of the next index.

## Steps to Reproduce

  1. Create a Jupyter notebook with cells containing: cell-0 (title), cell-1 (imports), cell-2 (code)
  2. Ask Claude Code: "Insert a new cell after the imports cell"
  3. Claude Code incorrectly uses cell_id="cell-1" thinking this means "after cell-1"
  4. The new cell appears at position 1, pushing imports down to cell-2
  5. Point out that the new cell is now before imports, not after
  6. Claude Code repeats the same mistake when asked to fix it

## Expected Behavior
To insert after cell-1, Claude Code should use cell_id="cell-2" because:

  • Insert operation places the new cell AT the specified index
  • To place something after cell-1, it must go at position 2

## Actual Behavior
Claude Code:

  • Uses cell_id="cell-1" when trying to insert after cell-1
  • Places content before the target cell instead of after
  • Continues making the same error despite corrections

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗