notebook
Notebook Edit Skill
Modify Jupyter notebook cells using jq and bash.
List Cells
# Show all cells with IDs and types
jq -r '.cells | to_entries[] | "\(.key): [\(.value.cell_type)] id=\(.value.id // "none") | \(.value.source[:1] | .[0] // "" | .[0:80])"' NOTEBOOK.ipynb
Replace a Cell's Source
# Replace cell by index (0-based)
jq --arg src "print(\"hello world\")\n" \
'.cells[0].source = ($src | split("\n") | map(if . == "" then . else . + "\n" end) | .[:-1])' \
NOTEBOOK.ipynb > /tmp/nb_tmp.ipynb && mv /tmp/nb_tmp.ipynb NOTEBOOK.ipynb
Insert a New Cell
# Insert a code cell after index 2
jq --arg src "# New cell\nprint(42)\n" \
'.cells |= (.[0:3] + [{
"id": ("new-" + (now | tostring)),
"cell_type": "code",
"source": ($src | split("\n") | map(if . == "" then . else . + "\n" end) | .[:-1]),
"metadata": {},
"outputs": [],
"execution_count": null
}] + .[3:])' \
NOTEBOOK.ipynb > /tmp/nb_tmp.ipynb && mv /tmp/nb_tmp.ipynb NOTEBOOK.ipynb
Delete a Cell
# Delete cell at index 1
jq 'del(.cells[1])' NOTEBOOK.ipynb > /tmp/nb_tmp.ipynb && mv /tmp/nb_tmp.ipynb NOTEBOOK.ipynb
Tips
- Always read the notebook first to understand its structure
- Notebook source lines should end with
\nexcept the last line - Use
jqfor reliable JSON manipulation - Back up the notebook before complex edits
- For simple edits, you can also use the Read/Write tools directly on the JSON
More from naohainezha/skill
reactions
React to the user's Telegram message with an emoji. Use when the message evokes a genuine emotional response.
28self-reflection
Daily self-reflection and personal growth. Triggered by heartbeat at end of day. Review the day's experiences, extract lessons, update personality, and write a diary entry.
6voice
Send voice messages (TTS) to the user via Telegram. Use when replying to voice messages or when a voice reply feels natural.
3scheduler
Create, manage, and delete scheduled tasks (cron jobs) and configure heartbeat. Use when users ask for reminders, recurring tasks, daily summaries, periodic checks, or anything time-based. Also manages HEARTBEAT.md for periodic awareness checks.
3thread-management
Manage chat threads — create, list, switch, delete, and search conversations. Use when users want to organize their chats.
3memory-management
Search and manage Alma's memory and conversation history. Use when the user asks about past conversations, personal facts, preferences, or anything that requires recalling information ("你知道我...吗", "我们之前聊过...", "你还记得...", "帮我找之前说的..."). Also used to store new memories and search through archived chat threads.
3