用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill notebook-writer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Token-efficient tracking for AI orchestration. CLI-first for status updates (~50 tokens), agent fallback for complex ops (~1KB). Use when: updating task status, querying blockers, creating progress files, validating phases.
AshAi extension guidelines for integrating AI capabilities with Ash Framework. Use when implementing vectorization/embeddings, exposing Ash actions as LLM tools, creating prompt-backed actions, or setting up MCP servers. Covers semantic search, LangChain integration, and structured outputs.
This skill should be used when solving hard questions, complex architectural problems, or debugging issues that benefit from GPT-5 Pro or GPT-5.1 thinking models with large file context. Use when standard Claude analysis needs deeper reasoning or extended context windows.
正在显示 SKILL.md
基于 SOC 职业分类
| name | notebook-writer |
| description | Create and document Jupyter notebooks for reproducible analyses |
| success_criteria | ["Notebook structured with clear sections and narrative","Code cells properly documented with explanatory markdown","Reproducibility ensured (can run end-to-end)","Environment requirements documented","Outputs properly displayed and interpreted","Git-friendly format (Jupytext markdown)"] |
You are a specialist in creating well-structured Jupyter notebooks for scientific analyses and documentation.
Use this skill when:
We use Jupytext-compatible Markdown for notebooks to enable git-friendly version control.
# %% on its own line---
jupyter:
kernelspec:
display_name: Python 3
language: python
name: python3
---
# Analysis Title
Brief description of what this notebook does.
## Section 1: Data Loading
# %%
import pandas as pd
import numpy as np
# %%
data = pd.read_csv('data.csv')
data.head()
## Section 2: Analysis
Explanation of the analysis approach.
# %%
# Perform calculation
result = np.mean(data['value'])
print(f"Mean: {result:.2f}")
Many projects provide src/utils/notebook_builder.py with helper functions for programmatic notebook creation.
create_notebook_markdown(
title: str,
cells: List[Dict[str, str]],
output_path: Path,
kernelspec: Optional[Dict] = None
) -> Path
Parameters:
title: Notebook title (becomes H1 header)cells: List of dicts with 'type' ('code' or 'markdown') and 'content'output_path: Where to save .md filekernelspec: Optional kernel specification (defaults to Python 3)Example:
from pathlib import Path
from src.utils.notebook_builder import create_notebook_markdown
cells = [
{'type': 'markdown', 'content': '## Introduction\n\nThis analysis...'},
{'type': 'code', 'content': 'import numpy as np'},
{'type': 'code', 'content': 'x = np.linspace(0, 10)\nprint(x)'}
]
create_notebook_markdown(
title="My Analysis",
cells=cells,
output_path=Path('docs/analysis/my_analysis.md')
)
create_parameter_sweep_notebook(
param_name: str,
param_range: str,
calculation_code: str,
output_path: Path
) -> Path
Creates a notebook with:
Example:
from pathlib import Path
from src.utils.notebook_builder import create_parameter_sweep_notebook
create_parameter_sweep_notebook(
param_name='temperature',
param_range='np.linspace(20, 40, 20)',
calculation_code='''
# Reaction rate calculation
results = []
for T in temperature_values:
rate = arrhenius_equation(T, activation_energy)
results.append(rate)
''',
output_path=Path('analysis/temperature_sweep.md')
)
create_analysis_report_notebook(
analysis_title: str,
sections: List[Dict[str, str]],
output_path: Path
) -> Path
Section dict keys:
title: Section heading (required)description: Explanatory text (optional)code: Code to execute (optional)interpretation: Results interpretation (optional)Example:
from src.utils.notebook_builder import create_analysis_report_notebook
sections = [
{
'title': 'Model Setup',
'description': 'Define parameters',
'code': 'diffusion_coeff = 2.1e-5 # cm²/s'
},
{
'title': 'Calculation',
'code': 'result = compute_model(diffusion_coeff)',
'interpretation': 'Result shows X is dominated by Y'
}
]
create_analysis_report_notebook(
'Transport Analysis',
sections,
Path('analysis/transport.md')
)
validate_notebook(notebook_path: Path) -> bool
Validates .ipynb structure using nbformat. Returns True if valid, raises exception if invalid.
Example:
from pathlib import Path
from src.utils.notebook_builder import validate_notebook
validate_notebook(Path('analysis/notebook.ipynb'))
# Returns True or raises ValidationError
.md file directly (agents write Markdown well).ipynb: python3 -m jupytext --to ipynb notebook.mdjupyter notebook notebook.ipynbpython3 -m jupytext --sync notebook.ipynb (bidirectional)Modern Jupyter environments (JupyterLab 4.0+, JetBrains IDEs) provide AI-powered assistance to enhance productivity and reduce errors.
The %%ai cell magic enables AI-powered code generation and analysis directly in notebooks:
# %%
# %load_ext jupyter_ai_magics
# %%
%%ai chatgpt
Generate a function to calculate the Pearson correlation coefficient between two arrays
Key use cases:
AI assistants work best when given relevant context. Always provide:
API documentation: For specialized libraries (scanpy, pydeseq2, biopython)
# Include relevant API documentation in a markdown cell
# Example: scanpy.pp.filter_cells(data, min_genes=200)
Dataset descriptions: Shape, columns, data types
# Document your data structure:
# RNA-seq counts matrix: 20,000 genes × 5,000 cells
# AnnData object: .X (sparse CSR matrix), .obs (cell metadata), .var (gene metadata)
Domain context: Biological meaning, expected ranges, units
# Oxygen consumption rate: 10-20 pmol/s/million cells
# Temperature: 37°C, pH: 7.4
JupyterLab's chat interface provides conversational help:
Best practices:
Use AI assistance for:
Write code manually for:
Warning: Always verify AI-generated code. Check for:
For notebooks in PyCharm/DataSpell:
Features:
Access: Right-click cell → "AI Assistant" or use AI chat sidebar
Projects should include .jupytext.toml in repository root:
# Jupytext configuration
# Enables git-friendly notebook version control
# Pair markdown and ipynb files
# Use myst format which supports # %% cell markers
formats = "md:myst,ipynb"
This tells Jupytext to:
.md files as notebooks# %% markers).ipynb when either is modifiedRecommended .gitignore configuration:
# Track .md notebooks (Jupytext source), ignore generated .ipynb files
*.ipynb
.ipynb_checkpoints/
What's tracked:
.md notebook files (human-readable source).ipynb files (generated, binary JSON).ipynb_checkpoints/ (Jupyter temp files)Rationale: .md files produce readable git diffs. .ipynb files are JSON with embedded outputs and can be regenerated from .md.
# %% markerspython3 -m jupytext --to ipynb file.mdpython3 -m jupytext --to md:myst notebook.ipynb
Option 1: Edit .md file directly (recommended for agents)
# Edit notebook.md in text editor
# Then convert:
python3 -m jupytext --to ipynb notebook.md
Option 2: Edit in Jupyter, sync back
jupyter notebook notebook.ipynb
# Make changes in Jupyter
# Sync back to .md:
python3 -m jupytext --sync notebook.ipynb
python3 -c "
from pathlib import Path
from src.utils.notebook_builder import validate_notebook
validate_notebook(Path('notebook.ipynb'))
print('✓ Valid')
"
# Convert all .md notebooks in a directory
python3 -m jupytext --to ipynb analysis/*.md
# Or sync all paired notebooks
python3 -m jupytext --sync analysis/*.ipynb
Scientific notebooks must be fully reproducible. Every notebook should enable another researcher to:
Every notebook must include an environment documentation cell:
# %%
# Environment Information
# Run: pip freeze > requirements.txt
# Or: conda env export > environment.yml
import sys
import numpy as np
import pandas as pd
import scanpy as sc # Example for single-cell analysis
print(f"Python: {sys.version}")
print(f"NumPy: {np.__version__}")
print(f"Pandas: {pd.__version__}")
print(f"Scanpy: {sc.__version__}")
# Include this output in your notebook for documentation
Create environment files:
# For pip users:
pip freeze > requirements.txt
# For conda users:
conda env export > environment.yml
# Include these files in your repository
Document kernel selection:
## Computational Environment
- **Kernel**: Python 3.11 (project-env)
- **Dependencies**: See `requirements.txt` for full package list
- **Critical packages**: scanpy==1.10.0, numpy==1.26.3, pandas==2.2.0
For any stochastic process, set random seeds:
# %%
# Set random seeds for reproducibility
import numpy as np
import random
RANDOM_SEED = 42 # Document why this value was chosen (convention, previous analysis, etc.)
np.random.seed(RANDOM_SEED)
random.seed(RANDOM_SEED)
# For machine learning:
import torch
torch.manual_seed(RANDOM_SEED)
# For scanpy:
import scanpy as sc
sc.settings.seed = RANDOM_SEED
print(f"Random seed set to {RANDOM_SEED}")
Stochastic processes requiring seeds:
End every notebook with a session info cell:
# %%
# Session Information (for reproducibility)
import session_info
session_info.show(
dependencies=True,
html=False
)
# Alternative for single-cell analysis:
# import scanpy as sc
# sc.logging.print_versions()
This captures:
Use relative paths and variables:
# %%
from pathlib import Path
# Define paths at the top of the notebook
DATA_DIR = Path("data/raw")
RESULTS_DIR = Path("results/analysis_2025-01-29")
# Ensure output directories exist
RESULTS_DIR.mkdir(parents=True, exist_ok=True)
# Use variables throughout
input_file = DATA_DIR / "counts.csv"
output_file = RESULTS_DIR / "normalized_counts.csv"
Never use hardcoded absolute paths:
# BAD:
data = pd.read_csv("/Users/yourname/project/data.csv")
# GOOD:
data = pd.read_csv(DATA_DIR / "data.csv")
Before sharing or archiving a notebook:
requirements.txt or environment.yml exists and is currentIntegration with other skills:
Many projects have a docs/NOTEBOOK-WORKFLOW.md or similar document with project-specific examples and patterns. Check your project's documentation for:
Error: Format 'percent' is not associated to extension '.md'
Fix: Use md:myst format in .jupytext.toml (not md:percent). MyST Markdown supports # %% markers.
formats = "md:myst,ipynb" # Correct
Symptom: Changes to .ipynb don't appear in .md
Solution:
.jupytext.toml exists and has correct formatpython3 -m jupytext --sync notebook.ipynb.md first if needed)Error: nbformat.ValidationError
Causes:
Solution: Use notebook_builder.py utility functions which handle validation automatically.
Symptom: .ipynb files appearing in git status
Fix: Ensure .gitignore contains *.ipynb. Check with:
git check-ignore -v notebook.ipynb
# %%: Code cells must start with this markerPath objects, ensure directories existnotebook_builder.validate_notebook() after creationBefore finalizing a notebook:
# %% markerRequired packages:
pip3 install jupytext nbformat
Check installation:
pip3 list | grep -E "(jupytext|nbformat)"
Tested versions:
Common patterns for skill integration:
Remember: Notebooks are for interactive exploration and reproducible documentation. For production code, use Python modules in src/.
For project-specific examples and patterns, see your project's documentation (often docs/NOTEBOOK-WORKFLOW.md or similar).