2.1 How to use AI Code Edit in the Notebook

Notebook

No headings found on page

Drylab's notebook has a built-in AI inline code editor that lets you modify existing cells using natural language — no manual rewriting required.

How to Access It
  1. Click on any code cell in the notebook

  2. Look for the AI edit button (pencil/magic icon) in the cell toolbar

  3. Type your instruction in plain English

  4. The AI rewrites the cell in-place and re-executes it

What You Can Do With It

Task

Example Instruction

Fix a bug

"Fix the KeyError on column 'gene_id'"

Change parameters

"Change the number of clusters from 5 to 10"

Refactor code

"Rewrite this using a for loop instead"

Add comments

"Add inline comments explaining each step"

Optimize

"Make this more memory efficient using chunking"

Extend logic

"Add error handling if the file does not exist"

Under the Hood

When you use AI code edit, it maps to the edit or edit_and_move action:

  • edit — modifies the cell in-place. Best for simple, isolated fixes (typos, parameter tweaks) when no new cells were added after it.

  • edit_and_move — deletes the old cell and appends a corrected version at the end. Used when the cell has been followed by debug/install cells, ensuring the notebook still runs top-to-bottom correctly.

Best Practices
  1. Be specific in your instruction. "Change alpha to 0.05" works better than "fix the stats."

  2. Use it for targeted edits, not full rewrites — for major changes, ask for a new cell instead.

  3. Check the output after edit. The cell re-runs automatically; verify the result matches your intent.

  4. Notebook stays reproducible. Every AI edit is recorded in the .ipynb file, so the full edit history is preserved.

Related Tutorial

Science is ready for a leap forward.
Join us and make it happen.

Science is ready for a leap forward.
Join us and make it happen.

Science is ready for a leap forward. Join us and make it happen.