Jupytext logo

Jupytext

Community
ninehills
jupytext

Jupyter Notebook 创建与格式转换技能。当用户提到以下任何请求时必须使用:新建/创建 notebook、Jupyter notebook、.ipynb、jupytext、py:percent、# %% cell 格式、notebook 版本控制、paired notebook、notebook 转 Python、Python 转 notebook、用纯文本写 notebook。即使用户只说「新建一个 notebook」也应触发此技能——先询问用户选用 .py percent format 还是传统 .ipynb,再按选定格式生成。不用于调试已有 notebook 或写普通 Python 脚本。

Overview

Publisherninehills
Repositoryskills
Skill namejupytext
Stars
278
Forks
26
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ninehills on GitHub. Read the source before you install it.

Installation

Install the Jupytext AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ninehills/skills/tree/main/jupytext
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ninehills/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/jupytext .claude/skills/jupytext
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Jupytext in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Jupytext on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Jupytext is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Jupytext:用纯 Python 写 Jupyter Notebook

本技能帮助用户用纯 Python 脚本编写 Jupyter Notebook,借助 Jupytext 实现 .py ↔ .ipynb 双向转换。

什么时候用这个技能

当用户提出以下请求时触发:

  • 创建新的 Jupyter notebook
  • 要求用 Python 写 notebook
  • 提到 jupytext、paired notebook、notebook 版本控制
  • 想把现有 notebook 转成纯 Python 脚本
  • 提到 # %% cell 分隔符(percent format)

核心流程

第一步:确认格式偏好

必须先问用户想要哪种格式:

格式适用场景
.py(percent format)需要版本控制、纯编辑器开发、code review 友好
.ipynb需要 Jupyter 原生体验、包含大量输出/图表

如果用户只说「新建一个 notebook」,默认推荐 .py(percent format),因为:

  1. Git diff 友好,方便 code review
  2. 编辑器支持好(VS Code、PyCharm、Spyder 原生识别 # %%)
  3. 无需额外工具即可阅读和编辑

第二步:生成文件

A. 创建 .py percent format 文件

一个完整的 percent format Python 文件长这样:

python
# ---
# jupytext:
#   formats: ipynb,py:percent
#   notebook_metadata_filter: -all
# ---

# %% [markdown]
# # 标题
# 这是一段 Markdown 说明

# %% [markdown]
"""
也可以用三引号写多行 Markdown,
这在 Python 中更易读。
"""

# %%
import numpy as np
import pandas as pd

# %%
data = pd.DataFrame({
    "x": np.random.randn(100),
    "y": np.random.randn(100),
})
data.head()

关键语法:

语法含义
# %%代码 cell 开始
# %% [markdown]Markdown cell 开始
# %% 标题文字 [markdown]带标题的 Markdown cell
# %% [markdown] + """..."""用三引号包裹多行 Markdown(推荐)
# %% key="value"带 cell metadata
B. 创建 .ipynb 文件

如果用户选择传统 notebook,使用 nbformat 或直接构造 JSON。参考 references/nbformat-guide.md 了解如何用 Python 构造 .ipynb。

第三步:提供配套操作

根据用户需求,告知或执行:

  1. 安装 Jupytext:pip install jupytext
  2. 转换为 notebook:jupytext --to notebook script.py
  3. 双向同步:先在文件头部加 YAML front matter 声明 formats: ipynb,py:percent,之后 jupytext --sync script.py 即可同步两端
  4. 在 JupyterLab 中打开 .py 为 notebook:右键 → Open With → Notebook(需安装 jupytext 扩展)

YAML Front Matter 详解

YAML front matter 是 .py 文件头部用 # --- 包围的元数据块:

python
# ---
# jupytext:
#   formats: ipynb,py:percent
#   notebook_metadata_filter: -all
#   cell_metadata_filter: -all
# ---

# %% [markdown]
# # My Notebook

常用配置:

配置作用
formats: ipynb,py:percent启用 paired notebook(保存时双向更新)
notebook_metadata_filter: -all不在 .py 中输出 notebook 级元数据
cell_metadata_filter: -all不在 .py 中输出 cell 级元数据
cell_markers: '"""'Markdown cell 用三引号而非 # 注释

配置文件

在项目根目录创建 jupytext.toml 可设置全局默认:

toml
# 所有 notebook 自动 paired
formats = "ipynb,py:percent"

# Markdown cell 用三引号
cell_markers = '"""'

或 pyproject.toml:

toml
[tool.jupytext]
formats = "ipynb,py:percent"
cell_markers = '"""'

常用 CLI 命令

bash
# .py → .ipynb
jupytext --to notebook script.py

# .ipynb → .py (percent format)
jupytext --to py:percent notebook.ipynb

# 启用 paired notebook
jupytext --set-formats ipynb,py:percent notebook.ipynb

# 同步 paired notebook(以较新文件为准)
jupytext --sync notebook.ipynb

# 测试 round-trip 一致性
jupytext --test notebook.ipynb --to py:percent

# 用 black 格式化
jupytext --sync --pipe black notebook.ipynb

# 设置 kernel 信息
jupytext --set-kernel - notebook.py

light format 补充

除了 percent format (# %%),Jupytext 还支持 light format,用 # + / # - 标记 cell 边界:

python
# +
import numpy as np

# + [markdown]
# 这是一段说明

由于 light format 不如 percent format 通用(仅 Jupytext 原生支持),一般不推荐,除非用户明确要求。

注意事项

  1. 永远先问用户要哪种格式,不要默认帮用户做决定
  2. .py 文件中不要混用 percent format 和 light format 的分隔符
  3. 如果用户已有 .ipynb 文件想版本控制,推荐 jupytext --set-formats ipynb,py:percent 转为 paired notebook
  4. 三引号 Markdown 写法更易读,但需要在 front matter 或配置中声明 cell_markers: '"""'
  5. .py percent format 文件可以在 VS Code 中直接作为 Interactive Window cell 运行,无需启动 Jupyter

参考资源

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Jupytext AI skill do?

Jupyter Notebook 创建与格式转换技能。当用户提到以下任何请求时必须使用:新建/创建 notebook、Jupyter notebook、.ipynb、jupytext、py:percent、# %% cell 格式、notebook 版本控制、paired notebook、notebook 转 Python、Python 转 notebook、用纯文本写 notebook。即使用户只说「新建一个 notebook」也应触发此技能——先询问用户选用 .py percent format 还是传统 .ipynb,再按选定格式生成。不用于调试已有 notebook 或写普通 Python 脚本。

Why use Jupytext on TypingMind?

Because you install it once and use it with any model. Jupytext is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Jupytext in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ninehills/skills/tree/main/jupytext. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Jupytext?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Jupytext?

As many as you like. As long as a model supports skills, you can use Jupytext with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Jupytext AI skill free?

It is published on GitHub by ninehills. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇